threads / patch / 31610

patchtest-wildmatch.c: Fix some sparse warnings

Subject: [PATCH] test-wildmatch.c: Fix some sparse warnings

## tl;dr

One message between Sep 19, 2012 and Sep 19, 2012. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Ramsay Jones· Sep 19, 2012, 18:13 UTC · lore
In particular, sparse complains as follows:
        SP test-wildmatch.c
    test-wildmatch.c:40:5: warning: symbol 'wildmatch_errors' was not \
        declared. Should it be static?
    test-wildmatch.c:41:6: warning: symbol 'number_separator' was not \
        declared. Should it be static?
    test-wildmatch.c:45:5: warning: symbol 'explode_mod' was not \
        declared. Should it be static?
    test-wildmatch.c:46:5: warning: symbol 'empties_mod' was not \
        declared. Should it be static?
    test-wildmatch.c:47:5: warning: symbol 'empty_at_start' was not \
        declared. Should it be static?
    test-wildmatch.c:48:5: warning: symbol 'empty_at_end' was not \
        declared. Should it be static?
    test-wildmatch.c:49:6: warning: symbol 'empties' was not \
        declared. Should it be static?

In order to suppress the warnings, we simply add the static modifier to the declaration of (most of) the above symbols. Note that the 'number_separator' symbol was not actually used, so we removed the declaration instead. Also, we add the static modifier to the 'fnmatch_errors' variable (not noted above because it was #ifdef-ed out).

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---
Hi Nguyen,

If you need to re-roll your 'nd/wildmatch' branch, could you please squash this patch into the relevent commit(s). Also, I note that two commits have "compat/wildmatch" in the subject, but the files are at the top level.

Thanks!

ATB, Ramsay Jones

 test-wildmatch.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
Show changes to test-wildmatch.c +7 −8
diff --git a/test-wildmatch.c b/test-wildmatch.c
index b94921b..bb726c8 100644
--- a/test-wildmatch.c
+++ b/test-wildmatch.c
@@ -34,19 +34,18 @@
 #ifdef COMPARE_WITH_FNMATCH
 #include <fnmatch.h>
 
-int fnmatch_errors = 0;
+static int fnmatch_errors = 0;
 #endif
 
-int wildmatch_errors = 0;
-char number_separator = ',';
+static int wildmatch_errors = 0;
 
 typedef char bool;
 
-int explode_mod = 0;
-int empties_mod = 0;
-int empty_at_start = 0;
-int empty_at_end = 0;
-char *empties;
+static int explode_mod = 0;
+static int empties_mod = 0;
+static int empty_at_start = 0;
+static int empty_at_end = 0;
+static char *empties;
 
 static struct option options[] = {
   OPT_STRING('e', "empties", &empties, "", ""),
-- 
1.7.12

← back to recent threads