Re: [PATCH 3/3] maint: avoid warnings from sparse tool

2022-01-12 Thread Bernhard Voelker
On 1/12/22 21:35, Eric Blake wrote:
> On Thu, Jan 06, 2022 at 04:47:40PM +0100, Bernhard Voelker wrote:
>> https://sparse.docs.kernel.org/
>> Running the tool against unviled the following warnings:
> 
> unveiled

thanks, I saw that right after pushing. ;-/

Have a nice day,
Berny



Re: [PATCH 3/3] maint: avoid warnings from sparse tool

2022-01-12 Thread Eric Blake
On Thu, Jan 06, 2022 at 04:47:40PM +0100, Bernhard Voelker wrote:
> https://sparse.docs.kernel.org/
> Running the tool against unviled the following warnings:

unveiled

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3266
Virtualization:  qemu.org | libvirt.org




[PATCH 3/3] maint: avoid warnings from sparse tool

2022-01-06 Thread Bernhard Voelker
https://sparse.docs.kernel.org/
Running the tool against unviled the following warnings:

  find/parser.c:328:7: warning: Using plain integer as NULL pointer
  find/parser.c:328:10: warning: Using plain integer as NULL pointer
  find/parser.c:328:13: warning: Using plain integer as NULL pointer
  find/parser.c:466:49: warning: Using plain integer as NULL pointer
  find/parser.c:656:45: warning: Using plain integer as NULL pointer
  find/print.c:1024:30: warning: Using plain integer as NULL pointer
  lib/regexprops.c:531:7: warning: symbol 'options' shadows an earlier one
  lib/regextype.c:48:24: warning: symbol 'regex_map' was not declared. Should 
it be static?
  locate/locate.c:131:25: warning: symbol 'check_existence' was not declared. 
Should it be static?
  locate/locate.c:207:12: warning: symbol 'metacharacters' was not declared. 
Should it be static?
  xargs/xargs.c:902:24: warning: symbol 'state' shadows an earlier one
  xargs/xargs.c:542:23: warning: Using plain integer as NULL pointer

The fixes for these findings are all trivial, so let's apply them.

* find/parser.c (parse_table): Initialize pointer-type members of
the last element with NULL instead of 0.
(get_noop): Compare to NULL as end condition of for-loop.
(find_parser): Likewise.
* find/print.c (do_fprintf): Initialize linkname with NULL instead of 0.
* lib/regexprops.c (describe_all): Rename local variable options
to regopts to avoid name shadowing.
* lib/regextype.c (regex_map): Declare static.
* locate/locate.c (check_existence): Likewise.
(metacharacters): Likewise.
* xargs/xargs.c (main): Set eof_str to NULL instead of 0.
---
 find/parser.c| 6 +++---
 find/print.c | 2 +-
 lib/regexprops.c | 6 +++---
 lib/regextype.c  | 2 +-
 locate/locate.c  | 4 ++--
 xargs/xargs.c| 2 +-
 6 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/find/parser.c b/find/parser.c
index 152f0fcd..c728fd6b 100644
--- a/find/parser.c
+++ b/find/parser.c
@@ -325,7 +325,7 @@ static struct parser_table const parse_table[] =
   {ARG_TEST, "-help", parse_help,NULL},   /* GNU */
   {ARG_TEST, "version",   parse_version, NULL},  /* GNU */
   {ARG_TEST, "-version",  parse_version, NULL},  /* GNU */
-  {0, 0, 0, 0}
+  {0, NULL, NULL, NULL}
 };
 
 
@@ -463,7 +463,7 @@ get_noop (void)
   int i;
   if (NULL == noop)
 {
-  for (i = 0; parse_table[i].parser_name != 0; i++)
+  for (i = 0; parse_table[i].parser_name != NULL; i++)
{
  if (ARG_NOOP ==parse_table[i].type)
{
@@ -653,7 +653,7 @@ find_parser (const char *search_name)
   if (*search_name == '-')
 search_name++;
 
-  for (i = 0; parse_table[i].parser_name != 0; i++)
+  for (i = 0; parse_table[i].parser_name != NULL; i++)
 {
   if (strcmp (parse_table[i].parser_name, search_name) == 0)
{
diff --git a/find/print.c b/find/print.c
index 62f7d22b..e7f0ba37 100644
--- a/find/print.c
+++ b/find/print.c
@@ -1021,7 +1021,7 @@ do_fprintf (struct format_val *dest,
   /* sanitised */
 #ifdef S_ISLNK
   {
-char *linkname = 0;
+char *linkname = NULL;
 
 if (S_ISLNK (stat_buf->st_mode))
   {
diff --git a/lib/regexprops.c b/lib/regexprops.c
index 7cc49b78..f7adbd3a 100644
--- a/lib/regexprops.c
+++ b/lib/regexprops.c
@@ -528,7 +528,7 @@ describe_all (const char *contextname,
  const char *up)
 {
   const char *name, *next, *previous;
-  int options;
+  int regopts;
   int i, parent;
 
   copying ();
@@ -542,7 +542,7 @@ describe_all (const char *contextname,
   previous = "";
 
   for (i=0;
-   options = get_regex_type_flags (i),
+   regopts = get_regex_type_flags (i),
 name=get_regex_type_name (i);
++i)
 {
@@ -568,7 +568,7 @@ describe_all (const char *contextname,
}
   else
{
- describe_regex_syntax (options);
+ describe_regex_syntax (regopts);
}
   previous = name;
 }
diff --git a/lib/regextype.c b/lib/regextype.c
index c87c5e70..9765b9b2 100644
--- a/lib/regextype.c
+++ b/lib/regextype.c
@@ -45,7 +45,7 @@ struct tagRegexTypeMap
   int  option_val;
 };
 
-struct tagRegexTypeMap regex_map[] =
+static struct tagRegexTypeMap regex_map[] =
   {
{ "findutils-default", CONTEXT_FINDUTILS, 
RE_SYNTAX_EMACS|RE_DOT_NEWLINE  },
{ "ed",CONTEXT_GENERIC,   RE_SYNTAX_ED  
  },
diff --git a/locate/locate.c b/locate/locate.c
index 84705e90..da161ff7 100644
--- a/locate/locate.c
+++ b/locate/locate.c
@@ -128,7 +128,7 @@ enum ExistenceCheckType
   };
 
 /* Check for existence of files before printing them out? */
-enum ExistenceCheckType check_existence = ACCEPT_EITHER;
+static enum ExistenceCheckType check_existence = ACCEPT_EITHER;
 
 static int follow_symlinks = 1;
 
@@ -204,7 +204,7 @@ get_short (FILE *fp)
   return x;
 }
 
-const char * const metacharacters = "*?[]\\";
+static const char * const metacharacters