diff options
author | Bernhard Voelker <mail@bernhard-voelker.de> | 2022-01-05 21:59:34 +0100 |
---|---|---|
committer | Bernhard Voelker <mail@bernhard-voelker.de> | 2022-01-06 03:28:38 +0100 |
commit | 841aa66f1e447aa5db0b8800b121d0321dfa6ba2 (patch) | |
tree | 365d3e78cd76b95f7bea5d43829a7376988062bc /lib | |
parent | 2e6c701850b1f3b4bdf710ddaa9ca6a1e38396d1 (diff) | |
download | findutils-841aa66f1e447aa5db0b8800b121d0321dfa6ba2.tar.gz |
maint: avoid warnings from sparse tool
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/regexprops.c | 6 | ||||
-rw-r--r-- | lib/regextype.c | 2 |
2 files changed, 4 insertions, 4 deletions
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 }, |