Le 05/06/2017 14:06, Eric Blake a écrit :
On 06/04/2017 11:39 AM, Nicola Spanti wrote:
Hi.

I used that:
cppcheck --verbose --quiet --enable=all --force --language=c --std=c89 .

I fixed some errors that were reported by cppcheck. I published that on
GitLab.com.
https://gitlab.com/RyDroid/bash

The git remote is: https://rydr...@gitlab.com/RyDroid/bash.git
The branch is cppcheck-fix
Can you also post the patches directly to this list, rather than making
us chase a URL to see what the patch includes?
I attached it. I dit it on top of commit "bc007799f0e1362100375bb95d952d28de4c62fb".
Feel to merge it upstream. I don't ask credit for this tiny thing. Of
course, I give the copyright to the FSF.
Copyright assignment is more formal than that, if your patch is deemed
significant (small patches can be taken without assignment, but large
patches require actual paperwork and signatures, although these days
there are various countries where the paperwork is all electronic).
It is noting significant in the patch.
diff --git a/array.c b/array.c
index 6a6db77..4a930d0 100644
--- a/array.c
+++ b/array.c
@@ -391,7 +391,6 @@ array_remove_quoted_nulls(array)
 ARRAY  *array;
 {
        ARRAY_ELEMENT   *a;
-       char    *t;
 
        if (array == 0 || array_head(array) == 0 || array_empty(array))
                return (ARRAY *)NULL;
diff --git a/arrayfunc.c b/arrayfunc.c
index 47c595e..76db4b6 100644
--- a/arrayfunc.c
+++ b/arrayfunc.c
@@ -258,9 +258,6 @@ bind_assoc_variable (entry, name, key, value, flags)
      char *value;
      int flags;
 {
-  SHELL_VAR *dentry;
-  char *newval;
-
   if ((readonly_p (entry) && (flags&ASS_FORCE) == 0) || noassign_p (entry))
     {
       if (readonly_p (entry))
@@ -280,7 +277,7 @@ assign_array_element (name, value, flags)
 {
   char *sub, *vname;
   int sublen;
-  SHELL_VAR *entry, *nv;
+  SHELL_VAR *entry;
 
   vname = array_variable_name (name, &sub, &sublen);
 
@@ -450,7 +447,6 @@ expand_compound_array_assignment (var, value, flags)
      int flags;
 {
   WORD_LIST *list, *nlist;
-  WORD_LIST *hd, *tl, *t, *n;
   char *val;
   int ni;
 
diff --git a/bashline.c b/bashline.c
index 0275844..e2951e2 100644
--- a/bashline.c
+++ b/bashline.c
@@ -751,14 +751,14 @@ snarf_hosts_from_file (filename)
      char *filename;
 {
   FILE *file;
-  char *temp, buffer[256], name[256];
+  char buffer[256], name[256];
   register int i, start;
 
   file = fopen (filename, "r");
   if (file == 0)
     return;
 
-  while (temp = fgets (buffer, 255, file))
+  while (fgets (buffer, 255, file))
     {
       /* Skip to first character. */
       for (i = 0; buffer[i] && cr_whitespace (buffer[i]); i++)
@@ -1056,7 +1056,7 @@ bash_forward_shellword (count, key)
      int count, key;
 {
   size_t slen;
-  int sindex, c, p;
+  int c, p;
   DECLARE_MBSTATE;
 
   if (count < 0)
@@ -1165,7 +1165,7 @@ bash_backward_shellword (count, key)
      int count, key;
 {
   size_t slen;
-  int sindex, c, p;
+  int c, p;
   DECLARE_MBSTATE;
   
   if (count < 0)
@@ -2705,9 +2705,10 @@ shell_expand_line (count, ignore)
   char *new_line;
   WORD_LIST *expanded_string;
 
-  new_line = 0;
 #if defined (BANG_HISTORY)
   new_line = history_expand_line_internal (rl_line_buffer);
+#else
+  new_line = 0;
 #endif
 
 #if defined (ALIAS)
@@ -3138,7 +3139,6 @@ bash_filename_stat_hook (dirname)
   int should_expand_dirname, return_value;
   int global_nounset;
   WORD_LIST *wl;
-  struct stat sb;
 
   local_dirname = *dirname;
   should_expand_dirname = return_value = 0;
@@ -3216,10 +3216,9 @@ bash_directory_completion_hook (dirname)
      char **dirname;
 {
   char *local_dirname, *new_dirname, *t;
-  int return_value, should_expand_dirname, nextch, closer, changed;
+  int return_value, should_expand_dirname, nextch, closer;
   size_t local_dirlen;
   WORD_LIST *wl;
-  struct stat sb;
 
   return_value = should_expand_dirname = nextch = closer = 0;
   local_dirname = *dirname;
@@ -4059,8 +4058,11 @@ static int
 putx(c)
      int c;
 {
+#ifndef _MINIX
   int x;
-  x = putc (c, rl_outstream);
+  x =
+#endif
+    putc (c, rl_outstream);
 #ifndef _MINIX
   return x;
 #endif
@@ -4071,9 +4073,6 @@ bash_execute_unix_command (count, key)
      int count;        /* ignored */
      int key;
 {
-  Keymap ckmap;                /* current keymap */
-  Keymap xkmap;                /* unix command executing keymap */
-  rl_command_func_t *func;
   int type;
   register int i, r;
   intmax_t mi;
diff --git a/braces.c b/braces.c
index 7f31dd5..8744da5 100644
--- a/braces.c
+++ b/braces.c
@@ -383,7 +383,7 @@ mkseq (start, end, incr, type, width)
      int type, width;
 {
   intmax_t n, prevn;
-  int i, j, nelem;
+  int i, nelem;
   char **result, *t;
 
   if (incr == 0)
@@ -494,7 +494,7 @@ expand_seqterm (text, tlen)
      size_t tlen;
 {
   char *t, *lhs, *rhs;
-  int i, lhs_t, rhs_t, lhs_l, rhs_l, width;
+  int lhs_t, rhs_t, lhs_l, rhs_l, width;
   intmax_t lhs_v, rhs_v, incr;
   intmax_t tl, tr;
   char **result, *ep, *oep;
diff --git a/examples/loadables/finfo.c b/examples/loadables/finfo.c
index 00833f6..5a9e2fb 100644
--- a/examples/loadables/finfo.c
+++ b/examples/loadables/finfo.c
@@ -102,7 +102,7 @@ int argc;
 char   **argv;
 {
        register int    i;
-       int     mode, flags, opt;
+       int     flags, opt;
 
        sh_optind = 0;  /* XXX */
        prog = base_pathname(argv[0]);
@@ -310,8 +310,6 @@ int flags;
        struct stat *st;
        struct passwd *pw;
        struct group *gr;
-       int     p;
-       char    *b;
 
        st = getstat(f);
        if (st == NULL)
@@ -390,7 +388,6 @@ finfo_builtin(list)
 {
   int c, r;
   char **v;
-  WORD_LIST *l;
 
   v = make_builtin_argv (list, &c);
   r = finfo_main (c, v);
@@ -492,7 +489,7 @@ size_t      s;
        ret = malloc(s);
        if (ret)
                return (ret);
-       fprintf(stderr, "%s: cannot malloc %d bytes\n", prog, s);
+       fprintf(stderr, "%s: cannot malloc %z bytes\n", prog, s);
        exit(1);
 }
 

Reply via email to