git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] test-string-list.c: Fix some sparse warnings
@ 2012-09-15 16:18 Ramsay Jones
  2012-09-15 20:52 ` Junio C Hamano
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Ramsay Jones @ 2012-09-15 16:18 UTC (permalink / raw)
  To: mhagger; +Cc: Junio C Hamano, GIT Mailing-list


In particular, sparse complains as follows:

        SP test-string-list.c
    test-string-list.c:10:6: warning: symbol 'parse_string_list' was not \
        declared. Should it be static?
    test-string-list.c:18:6: warning: symbol 'write_list' was not \
        declared. Should it be static?
    test-string-list.c:25:6: warning: symbol 'write_list_compact' was not \
        declared. Should it be static?
    test-string-list.c:38:5: warning: symbol 'prefix_cb' was not \
        declared. Should it be static?

In order to suppress the warnings, since the above symbols do not
need more than file scope, we simply include the static modifier
in their declaration.

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

Hi Michael,

If you need to re-roll your 'mh/string-list' branch, could you
please squash the relevent parts of this patch into those commits.

Thanks!

ATB,
Ramsay Jones

 test-string-list.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/test-string-list.c b/test-string-list.c
index 5e9631f..4693295 100644
--- a/test-string-list.c
+++ b/test-string-list.c
@@ -7,7 +7,7 @@
  * list (as opposed to "", which indicates a string list containing a
  * single empty string).  list->strdup_strings must be set.
  */
-void parse_string_list(struct string_list *list, const char *arg)
+static void parse_string_list(struct string_list *list, const char *arg)
 {
 	if (!strcmp(arg, "-"))
 		return;
@@ -15,14 +15,14 @@ void parse_string_list(struct string_list *list, const char *arg)
 	(void)string_list_split(list, arg, ':', -1);
 }
 
-void write_list(const struct string_list *list)
+static void write_list(const struct string_list *list)
 {
 	int i;
 	for (i = 0; i < list->nr; i++)
 		printf("[%d]: \"%s\"\n", i, list->items[i].string);
 }
 
-void write_list_compact(const struct string_list *list)
+static void write_list_compact(const struct string_list *list)
 {
 	int i;
 	if (!list->nr)
@@ -35,7 +35,7 @@ void write_list_compact(const struct string_list *list)
 	}
 }
 
-int prefix_cb(struct string_list_item *item, void *cb_data)
+static int prefix_cb(struct string_list_item *item, void *cb_data)
 {
 	const char *prefix = (const char *)cb_data;
 	return !prefixcmp(item->string, prefix);
-- 
1.7.12

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] test-string-list.c: Fix some sparse warnings
  2012-09-15 16:18 [PATCH] test-string-list.c: Fix some sparse warnings Ramsay Jones
@ 2012-09-15 20:52 ` Junio C Hamano
  2012-09-15 21:10 ` [PATCH 1/7] builtin/notes.c: mark file-scope functions as static Junio C Hamano
  2012-09-17  8:15 ` [PATCH] test-string-list.c: Fix some sparse warnings Michael Haggerty
  2 siblings, 0 replies; 15+ messages in thread
From: Junio C Hamano @ 2012-09-15 20:52 UTC (permalink / raw)
  To: Ramsay Jones; +Cc: mhagger, GIT Mailing-list

Queued.  Thanks.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/7] builtin/notes.c: mark file-scope functions as static
  2012-09-15 16:18 [PATCH] test-string-list.c: Fix some sparse warnings Ramsay Jones
  2012-09-15 20:52 ` Junio C Hamano
@ 2012-09-15 21:10 ` Junio C Hamano
  2012-09-15 21:10   ` [PATCH 2/7] commit.c: " Junio C Hamano
                     ` (5 more replies)
  2012-09-17  8:15 ` [PATCH] test-string-list.c: Fix some sparse warnings Michael Haggerty
  2 siblings, 6 replies; 15+ messages in thread
From: Junio C Hamano @ 2012-09-15 21:10 UTC (permalink / raw)
  To: git; +Cc: Ramsay Jones

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin.h       | 2 --
 builtin/notes.c | 7 +++++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/builtin.h b/builtin.h
index 8e37752..95116b8 100644
--- a/builtin.h
+++ b/builtin.h
@@ -21,7 +21,6 @@ struct fmt_merge_msg_opts {
 
 extern int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
 			 struct fmt_merge_msg_opts *);
-extern void commit_notes(struct notes_tree *t, const char *msg);
 
 struct notes_rewrite_cfg {
 	struct notes_tree **trees;
@@ -33,7 +32,6 @@ struct notes_rewrite_cfg {
 	int mode_from_env;
 };
 
-combine_notes_fn parse_combine_notes_fn(const char *v);
 struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd);
 int copy_note_for_rewrite(struct notes_rewrite_cfg *c,
 			  const unsigned char *from_obj, const unsigned char *to_obj);
diff --git a/builtin/notes.c b/builtin/notes.c
index 554c801..453457a 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -19,6 +19,9 @@
 #include "string-list.h"
 #include "notes-merge.h"
 
+static void commit_notes(struct notes_tree *t, const char *msg);
+static combine_notes_fn parse_combine_notes_fn(const char *v);
+
 static const char * const git_notes_usage[] = {
 	N_("git notes [--ref <notes_ref>] [list [<object>]]"),
 	N_("git notes [--ref <notes_ref>] add [-f] [-m <msg> | -F <file> | (-c | -C) <object>] [<object>]"),
@@ -288,7 +291,7 @@ static int parse_reedit_arg(const struct option *opt, const char *arg, int unset
 	return parse_reuse_arg(opt, arg, unset);
 }
 
-void commit_notes(struct notes_tree *t, const char *msg)
+static void commit_notes(struct notes_tree *t, const char *msg)
 {
 	struct strbuf buf = STRBUF_INIT;
 	unsigned char commit_sha1[20];
@@ -312,7 +315,7 @@ void commit_notes(struct notes_tree *t, const char *msg)
 	strbuf_release(&buf);
 }
 
-combine_notes_fn parse_combine_notes_fn(const char *v)
+static combine_notes_fn parse_combine_notes_fn(const char *v)
 {
 	if (!strcasecmp(v, "overwrite"))
 		return combine_notes_overwrite;
-- 
1.7.12.508.g4d78187

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/7] commit.c: mark file-scope functions as static
  2012-09-15 21:10 ` [PATCH 1/7] builtin/notes.c: mark file-scope functions as static Junio C Hamano
@ 2012-09-15 21:10   ` Junio C Hamano
  2012-09-15 21:10   ` [PATCH 3/7] diff.c: mark private file-scope symbols " Junio C Hamano
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Junio C Hamano @ 2012-09-15 21:10 UTC (permalink / raw)
  To: git; +Cc: Ramsay Jones

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 commit.c | 7 +++++--
 commit.h | 1 -
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/commit.c b/commit.c
index 0ea441d..0246767 100644
--- a/commit.c
+++ b/commit.c
@@ -9,6 +9,8 @@
 #include "gpg-interface.h"
 #include "mergesort.h"
 
+static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);
+
 int save_commit_buffer = 1;
 
 const char *commit_type = "commit";
@@ -1073,8 +1075,9 @@ static int excluded_header_field(const char *field, size_t len, const char **exc
 	return 0;
 }
 
-struct commit_extra_header *read_commit_extra_header_lines(const char *buffer, size_t size,
-							   const char **exclude)
+static struct commit_extra_header *read_commit_extra_header_lines(
+	const char *buffer, size_t size,
+	const char **exclude)
 {
 	struct commit_extra_header *extra = NULL, **tail = &extra, *it = NULL;
 	const char *line, *next, *eof, *eob;
diff --git a/commit.h b/commit.h
index 6edce87..9f21313 100644
--- a/commit.h
+++ b/commit.h
@@ -204,7 +204,6 @@ extern int commit_tree_extended(const struct strbuf *msg, unsigned char *tree,
 				struct commit_extra_header *);
 
 extern struct commit_extra_header *read_commit_extra_headers(struct commit *, const char **);
-extern struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);
 
 extern void free_commit_extra_headers(struct commit_extra_header *extra);
 
-- 
1.7.12.508.g4d78187

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3/7] diff.c: mark private file-scope symbols as static
  2012-09-15 21:10 ` [PATCH 1/7] builtin/notes.c: mark file-scope functions as static Junio C Hamano
  2012-09-15 21:10   ` [PATCH 2/7] commit.c: " Junio C Hamano
@ 2012-09-15 21:10   ` Junio C Hamano
  2012-09-15 21:10   ` [PATCH 4/7] graph.c: " Junio C Hamano
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Junio C Hamano @ 2012-09-15 21:10 UTC (permalink / raw)
  To: git; +Cc: Ramsay Jones

---
 diff.c | 2 +-
 diff.h | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/diff.c b/diff.c
index 32142db..35d3f07 100644
--- a/diff.c
+++ b/diff.c
@@ -25,7 +25,7 @@
 static int diff_detect_rename_default;
 static int diff_rename_limit_default = 400;
 static int diff_suppress_blank_empty;
-int diff_use_color_default = -1;
+static int diff_use_color_default = -1;
 static const char *diff_word_regex_cfg;
 static const char *external_diff_cmd_cfg;
 int diff_auto_refresh_index = 1;
diff --git a/diff.h b/diff.h
index e25addb..a658f85 100644
--- a/diff.h
+++ b/diff.h
@@ -243,7 +243,6 @@ extern int parse_long_opt(const char *opt, const char **argv,
 
 extern int git_diff_basic_config(const char *var, const char *value, void *cb);
 extern int git_diff_ui_config(const char *var, const char *value, void *cb);
-extern int diff_use_color_default;
 extern void diff_setup(struct diff_options *);
 extern int diff_opt_parse(struct diff_options *, const char **, int);
 extern void diff_setup_done(struct diff_options *);
-- 
1.7.12.508.g4d78187

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 4/7] graph.c: mark private file-scope symbols as static
  2012-09-15 21:10 ` [PATCH 1/7] builtin/notes.c: mark file-scope functions as static Junio C Hamano
  2012-09-15 21:10   ` [PATCH 2/7] commit.c: " Junio C Hamano
  2012-09-15 21:10   ` [PATCH 3/7] diff.c: mark private file-scope symbols " Junio C Hamano
@ 2012-09-15 21:10   ` Junio C Hamano
  2012-09-15 21:10   ` [PATCH 5/7] grep.c: " Junio C Hamano
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Junio C Hamano @ 2012-09-15 21:10 UTC (permalink / raw)
  To: git; +Cc: Ramsay Jones

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 graph.c | 32 ++++++++++++++++++++++++++++++--
 graph.h | 27 ---------------------------
 2 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/graph.c b/graph.c
index 7e0a099..e864fe2 100644
--- a/graph.c
+++ b/graph.c
@@ -8,6 +8,34 @@
 /* Internal API */
 
 /*
+ * Output the next line for a graph.
+ * This formats the next graph line into the specified strbuf.  It is not
+ * terminated with a newline.
+ *
+ * Returns 1 if the line includes the current commit, and 0 otherwise.
+ * graph_next_line() will return 1 exactly once for each time
+ * graph_update() is called.
+ */
+static int graph_next_line(struct git_graph *graph, struct strbuf *sb);
+
+/*
+ * Set up a custom scheme for column colors.
+ *
+ * The default column color scheme inserts ANSI color escapes to colorize
+ * the graph. The various color escapes are stored in an array of strings
+ * where each entry corresponds to a color, except for the last entry,
+ * which denotes the escape for resetting the color back to the default.
+ * When generating the graph, strings from this array are inserted before
+ * and after the various column characters.
+ *
+ * This function allows you to enable a custom array of color escapes.
+ * The 'colors_max' argument is the index of the last "reset" entry.
+ *
+ * This functions must be called BEFORE graph_init() is called.
+ */
+static void graph_set_column_colors(const char **colors, unsigned short colors_max);
+
+/*
  * Output a padding line in the graph.
  * This is similar to graph_next_line().  However, it is guaranteed to
  * never print the current commit line.  Instead, if the commit line is
@@ -62,7 +90,7 @@ enum graph_state {
 static const char **column_colors;
 static unsigned short column_colors_max;
 
-void graph_set_column_colors(const char **colors, unsigned short colors_max)
+static void graph_set_column_colors(const char **colors, unsigned short colors_max)
 {
 	column_colors = colors;
 	column_colors_max = colors_max;
@@ -1116,7 +1144,7 @@ static void graph_output_collapsing_line(struct git_graph *graph, struct strbuf
 		graph_update_state(graph, GRAPH_PADDING);
 }
 
-int graph_next_line(struct git_graph *graph, struct strbuf *sb)
+static int graph_next_line(struct git_graph *graph, struct strbuf *sb)
 {
 	switch (graph->state) {
 	case GRAPH_PADDING:
diff --git a/graph.h b/graph.h
index aff960c..19b0f66 100644
--- a/graph.h
+++ b/graph.h
@@ -4,22 +4,6 @@
 /* A graph is a pointer to this opaque structure */
 struct git_graph;
 
-/*
- * Set up a custom scheme for column colors.
- *
- * The default column color scheme inserts ANSI color escapes to colorize
- * the graph. The various color escapes are stored in an array of strings
- * where each entry corresponds to a color, except for the last entry,
- * which denotes the escape for resetting the color back to the default.
- * When generating the graph, strings from this array are inserted before
- * and after the various column characters.
- *
- * This function allows you to enable a custom array of color escapes.
- * The 'colors_max' argument is the index of the last "reset" entry.
- *
- * This functions must be called BEFORE graph_init() is called.
- */
-void graph_set_column_colors(const char **colors, unsigned short colors_max);
 
 /*
  * Create a new struct git_graph.
@@ -49,17 +33,6 @@ void graph_update(struct git_graph *graph, struct commit *commit);
  */
 int graph_is_commit_finished(struct git_graph const *graph);
 
-/*
- * Output the next line for a graph.
- * This formats the next graph line into the specified strbuf.  It is not
- * terminated with a newline.
- *
- * Returns 1 if the line includes the current commit, and 0 otherwise.
- * graph_next_line() will return 1 exactly once for each time
- * graph_update() is called.
- */
-int graph_next_line(struct git_graph *graph, struct strbuf *sb);
-
 
 /*
  * graph_show_*: helper functions for printing to stdout
-- 
1.7.12.508.g4d78187

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 5/7] grep.c: mark private file-scope symbols as static
  2012-09-15 21:10 ` [PATCH 1/7] builtin/notes.c: mark file-scope functions as static Junio C Hamano
                     ` (2 preceding siblings ...)
  2012-09-15 21:10   ` [PATCH 4/7] graph.c: " Junio C Hamano
@ 2012-09-15 21:10   ` Junio C Hamano
  2012-09-19 18:02     ` Ramsay Jones
  2012-09-15 21:10   ` [PATCH 6/7] rerere.c: " Junio C Hamano
  2012-09-15 21:10   ` [PATCH 7/7] notes.c: " Junio C Hamano
  5 siblings, 1 reply; 15+ messages in thread
From: Junio C Hamano @ 2012-09-15 21:10 UTC (permalink / raw)
  To: git; +Cc: Ramsay Jones

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 grep.c | 6 +++++-
 grep.h | 3 +--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/grep.c b/grep.c
index 925aa92..c7f8a47 100644
--- a/grep.c
+++ b/grep.c
@@ -3,6 +3,10 @@
 #include "userdiff.h"
 #include "xdiff-interface.h"
 
+static int grep_source_load(struct grep_source *gs);
+static int grep_source_is_binary(struct grep_source *gs);
+
+
 static struct grep_pat *create_grep_pat(const char *pat, size_t patlen,
 					const char *origin, int no,
 					enum grep_pat_token t,
@@ -403,7 +407,7 @@ static void dump_grep_expression_1(struct grep_expr *x, int in)
 	}
 }
 
-void dump_grep_expression(struct grep_opt *opt)
+static void dump_grep_expression(struct grep_opt *opt)
 {
 	struct grep_expr *x = opt->pattern_expression;
 
diff --git a/grep.h b/grep.h
index 00d71f7..8a28a67 100644
--- a/grep.h
+++ b/grep.h
@@ -159,11 +159,10 @@ struct grep_source {
 
 void grep_source_init(struct grep_source *gs, enum grep_source_type type,
 		      const char *name, const void *identifier);
-int grep_source_load(struct grep_source *gs);
 void grep_source_clear_data(struct grep_source *gs);
 void grep_source_clear(struct grep_source *gs);
 void grep_source_load_driver(struct grep_source *gs);
-int grep_source_is_binary(struct grep_source *gs);
+
 
 int grep_source(struct grep_opt *opt, struct grep_source *gs);
 
-- 
1.7.12.508.g4d78187

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 6/7] rerere.c: mark private file-scope symbols as static
  2012-09-15 21:10 ` [PATCH 1/7] builtin/notes.c: mark file-scope functions as static Junio C Hamano
                     ` (3 preceding siblings ...)
  2012-09-15 21:10   ` [PATCH 5/7] grep.c: " Junio C Hamano
@ 2012-09-15 21:10   ` Junio C Hamano
  2012-09-15 21:10   ` [PATCH 7/7] notes.c: " Junio C Hamano
  5 siblings, 0 replies; 15+ messages in thread
From: Junio C Hamano @ 2012-09-15 21:10 UTC (permalink / raw)
  To: git; +Cc: Ramsay Jones

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 rerere.c | 2 +-
 rerere.h | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/rerere.c b/rerere.c
index b57a34d..a6a5cd5 100644
--- a/rerere.c
+++ b/rerere.c
@@ -25,7 +25,7 @@ const char *rerere_path(const char *hex, const char *file)
 	return git_path("rr-cache/%s/%s", hex, file);
 }
 
-int has_rerere_resolution(const char *hex)
+static int has_rerere_resolution(const char *hex)
 {
 	struct stat st;
 	return !stat(rerere_path(hex, "postimage"), &st);
diff --git a/rerere.h b/rerere.h
index fcd8bc1..156d2aa 100644
--- a/rerere.h
+++ b/rerere.h
@@ -16,7 +16,6 @@ extern void *RERERE_RESOLVED;
 extern int setup_rerere(struct string_list *, int);
 extern int rerere(int);
 extern const char *rerere_path(const char *hex, const char *file);
-extern int has_rerere_resolution(const char *hex);
 extern int rerere_forget(const char **);
 extern int rerere_remaining(struct string_list *);
 extern void rerere_clear(struct string_list *);
-- 
1.7.12.508.g4d78187

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 7/7] notes.c: mark private file-scope symbols as static
  2012-09-15 21:10 ` [PATCH 1/7] builtin/notes.c: mark file-scope functions as static Junio C Hamano
                     ` (4 preceding siblings ...)
  2012-09-15 21:10   ` [PATCH 6/7] rerere.c: " Junio C Hamano
@ 2012-09-15 21:10   ` Junio C Hamano
  5 siblings, 0 replies; 15+ messages in thread
From: Junio C Hamano @ 2012-09-15 21:10 UTC (permalink / raw)
  To: git; +Cc: Ramsay Jones

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 notes.c | 14 ++++++++++++--
 notes.h | 14 --------------
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/notes.c b/notes.c
index 93e9868..bc454e1 100644
--- a/notes.c
+++ b/notes.c
@@ -1196,8 +1196,18 @@ void free_notes(struct notes_tree *t)
 	memset(t, 0, sizeof(struct notes_tree));
 }
 
-void format_note(struct notes_tree *t, const unsigned char *object_sha1,
-		struct strbuf *sb, const char *output_encoding, int flags)
+/*
+ * Fill the given strbuf with the notes associated with the given object.
+ *
+ * If the given notes_tree structure is not initialized, it will be auto-
+ * initialized to the default value (see documentation for init_notes() above).
+ * If the given notes_tree is NULL, the internal/default notes_tree will be
+ * used instead.
+ *
+ * 'flags' is a bitwise combination of the flags for format_display_notes.
+ */
+static void format_note(struct notes_tree *t, const unsigned char *object_sha1,
+			struct strbuf *sb, const char *output_encoding, int flags)
 {
 	static const char utf8[] = "utf-8";
 	const unsigned char *sha1;
diff --git a/notes.h b/notes.h
index c716694..3592b19 100644
--- a/notes.h
+++ b/notes.h
@@ -241,20 +241,6 @@ void free_notes(struct notes_tree *t);
 #define NOTES_SHOW_HEADER 1
 #define NOTES_INDENT 2
 
-/*
- * Fill the given strbuf with the notes associated with the given object.
- *
- * If the given notes_tree structure is not initialized, it will be auto-
- * initialized to the default value (see documentation for init_notes() above).
- * If the given notes_tree is NULL, the internal/default notes_tree will be
- * used instead.
- *
- * 'flags' is a bitwise combination of the above formatting flags.
- */
-void format_note(struct notes_tree *t, const unsigned char *object_sha1,
-		struct strbuf *sb, const char *output_encoding, int flags);
-
-
 struct string_list;
 
 struct display_notes_opt {
-- 
1.7.12.508.g4d78187

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] test-string-list.c: Fix some sparse warnings
  2012-09-15 16:18 [PATCH] test-string-list.c: Fix some sparse warnings Ramsay Jones
  2012-09-15 20:52 ` Junio C Hamano
  2012-09-15 21:10 ` [PATCH 1/7] builtin/notes.c: mark file-scope functions as static Junio C Hamano
@ 2012-09-17  8:15 ` Michael Haggerty
  2012-09-19 19:07   ` Ramsay Jones
  2 siblings, 1 reply; 15+ messages in thread
From: Michael Haggerty @ 2012-09-17  8:15 UTC (permalink / raw)
  To: Ramsay Jones; +Cc: Junio C Hamano, GIT Mailing-list

On 09/15/2012 06:18 PM, Ramsay Jones wrote:
> 
> In particular, sparse complains as follows:
> 
>         SP test-string-list.c
>     test-string-list.c:10:6: warning: symbol 'parse_string_list' was not \
>         declared. Should it be static?
>     test-string-list.c:18:6: warning: symbol 'write_list' was not \
>         declared. Should it be static?
>     test-string-list.c:25:6: warning: symbol 'write_list_compact' was not \
>         declared. Should it be static?
>     test-string-list.c:38:5: warning: symbol 'prefix_cb' was not \
>         declared. Should it be static?
> 
> In order to suppress the warnings, since the above symbols do not
> need more than file scope, we simply include the static modifier
> in their declaration.

Thanks for fixing this.

Is there some documentation about how to run sparse on the git codebase?
 I naively tried "make sparse" and ended up with zillions of errors like

/usr/include/unistd.h:288:54: error: attribute '__leaf__': unknown attribute
/usr/include/unistd.h:294:6: error: attribute '__leaf__': unknown attribute
/usr/include/unistd.h:298:6: error: attribute '__leaf__': unknown attribute
/usr/include/unistd.h:306:6: error: attribute '__leaf__': unknown attribute
/usr/include/unistd.h:338:18: error: attribute '__leaf__': unknown attribute
/usr/include/unistd.h:347:6: error: attribute '__leaf__': unknown attribute
/usr/include/unistd.h:418:36: error: attribute '__leaf__': unknown attribute
/usr/include/unistd.h:423:50: error: attribute '__leaf__': unknown attribute

Michael

-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 5/7] grep.c: mark private file-scope symbols as static
  2012-09-15 21:10   ` [PATCH 5/7] grep.c: " Junio C Hamano
@ 2012-09-19 18:02     ` Ramsay Jones
  2012-09-19 20:46       ` Junio C Hamano
  0 siblings, 1 reply; 15+ messages in thread
From: Ramsay Jones @ 2012-09-19 18:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano wrote:
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  grep.c | 6 +++++-
>  grep.h | 3 +--
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/grep.c b/grep.c
> index 925aa92..c7f8a47 100644
> --- a/grep.c
> +++ b/grep.c
> @@ -3,6 +3,10 @@
>  #include "userdiff.h"
>  #include "xdiff-interface.h"
>  
> +static int grep_source_load(struct grep_source *gs);
> +static int grep_source_is_binary(struct grep_source *gs);
> +
> +
>  static struct grep_pat *create_grep_pat(const char *pat, size_t patlen,
>  					const char *origin, int no,
>  					enum grep_pat_token t,
> @@ -403,7 +407,7 @@ static void dump_grep_expression_1(struct grep_expr *x, int in)
>  	}
>  }
>  
> -void dump_grep_expression(struct grep_opt *opt)
> +static void dump_grep_expression(struct grep_opt *opt)
>  {
>  	struct grep_expr *x = opt->pattern_expression;
>  
> diff --git a/grep.h b/grep.h
> index 00d71f7..8a28a67 100644
> --- a/grep.h
> +++ b/grep.h
> @@ -159,11 +159,10 @@ struct grep_source {
>  
>  void grep_source_init(struct grep_source *gs, enum grep_source_type type,
>  		      const char *name, const void *identifier);
> -int grep_source_load(struct grep_source *gs);
>  void grep_source_clear_data(struct grep_source *gs);
>  void grep_source_clear(struct grep_source *gs);
>  void grep_source_load_driver(struct grep_source *gs);
> -int grep_source_is_binary(struct grep_source *gs);
> +
>  
>  int grep_source(struct grep_opt *opt, struct grep_source *gs);

Heh, so I obviously didn't see this before sending the patch yesterday! :-D

Yes, this solves the problem addressed by yesterday's patch, so please
ignore that. However, this tickles sparse to complain as well ... ;-)

New patch on it's way.

[I have a funny feeling that I'm about to download an email, in response
to yesterday's patch, that says something like: "does commit 07a7d656 not
fix it for you ..." :-P ]

ATB,
Ramsay Jones

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] test-string-list.c: Fix some sparse warnings
  2012-09-17  8:15 ` [PATCH] test-string-list.c: Fix some sparse warnings Michael Haggerty
@ 2012-09-19 19:07   ` Ramsay Jones
  2012-09-20  7:13     ` Michael Haggerty
  0 siblings, 1 reply; 15+ messages in thread
From: Ramsay Jones @ 2012-09-19 19:07 UTC (permalink / raw)
  To: Michael Haggerty; +Cc: Junio C Hamano, GIT Mailing-list, Christopher Li

Michael Haggerty wrote:
> On 09/15/2012 06:18 PM, Ramsay Jones wrote:
>>
>> In particular, sparse complains as follows:
>>
>>         SP test-string-list.c
>>     test-string-list.c:10:6: warning: symbol 'parse_string_list' was not \
>>         declared. Should it be static?
>>     test-string-list.c:18:6: warning: symbol 'write_list' was not \
>>         declared. Should it be static?
>>     test-string-list.c:25:6: warning: symbol 'write_list_compact' was not \
>>         declared. Should it be static?
>>     test-string-list.c:38:5: warning: symbol 'prefix_cb' was not \
>>         declared. Should it be static?
>>
>> In order to suppress the warnings, since the above symbols do not
>> need more than file scope, we simply include the static modifier
>> in their declaration.
> 
> Thanks for fixing this.
> 
> Is there some documentation about how to run sparse on the git codebase?
>  I naively tried "make sparse" and ended up with zillions of errors like
> 
> /usr/include/unistd.h:288:54: error: attribute '__leaf__': unknown attribute
> /usr/include/unistd.h:294:6: error: attribute '__leaf__': unknown attribute
> /usr/include/unistd.h:298:6: error: attribute '__leaf__': unknown attribute
> /usr/include/unistd.h:306:6: error: attribute '__leaf__': unknown attribute
> /usr/include/unistd.h:338:18: error: attribute '__leaf__': unknown attribute
> /usr/include/unistd.h:347:6: error: attribute '__leaf__': unknown attribute
> /usr/include/unistd.h:418:36: error: attribute '__leaf__': unknown attribute
> /usr/include/unistd.h:423:50: error: attribute '__leaf__': unknown attribute

Yep, "make sparse" is the correct way to run sparse over git.

This looks like you are running sparse on a 64-bit system. I have heard that
it has (or *had*) problems running on 64-bit systems. Unfortunately, I am
currently confined to 32-bit. (I'm looking at getting a new laptop soon, before
Windows 8 causes boot-time problems, so I will then have the same problem!)

How did you obtain/build/install sparse? The current release (v0.4.4) was
released about Nov 2011 and I think you need a more up to date version.
i.e. you need to build the latest, directly from the sparse repo.

Note that the repo on kernel.org is currently dormant. Christopher moved the
active development to github: http://github.com/sparsecli/sparse

In particular, I *think* that the following commits (among others) may improve
your experience of running sparse on git:

    b0b4886 sparse: Add 'leaf' to ignored attributes.
    7aa79f8 Adding default for m64/m32 handle
    2313167 sparse: Add '__vector_size__' to ignored attributes
    0a04210 sparse: Add 'error' to ignored attributes

(These are all post v0.4.4)

Note that I "make sparse" on Linux, cygwin and MinGW. (All 32-bit, of course)
Only cygwin is "sparse clean". :-D

Linux has a handfull of warnings, mainly due to the system header files
using features not supported by sparse; e.g. transparent unions. (It's on
my TODO list!). I have a few patches which I keep forgetting to push back
upstream ...

I "ported" sparse to MinGW about three years ago. I have yet to "tidy up"
the patches and push them upstream. (*ahem*) I have a shed-load of patches
to fix sparse warnings on git. However, since (as far as I know) nobody can
confirm they actually fix anything ... ;-)

HTH

ATB,
Ramsay Jones

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 5/7] grep.c: mark private file-scope symbols as static
  2012-09-19 18:02     ` Ramsay Jones
@ 2012-09-19 20:46       ` Junio C Hamano
  2012-09-20 20:43         ` Ramsay Jones
  0 siblings, 1 reply; 15+ messages in thread
From: Junio C Hamano @ 2012-09-19 20:46 UTC (permalink / raw)
  To: Ramsay Jones; +Cc: git

Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:

> Heh, so I obviously didn't see this before sending the patch yesterday! :-D
>
> Yes, this solves the problem addressed by yesterday's patch, so please
> ignore that. However, this tickles sparse to complain as well ... ;-)
>
> New patch on it's way.

Are you sure the patch you are responding to really "tickles
sparse"?

You have another grep.c patch timestamped two minutes after the
message I am responding to, and as far as I can see, it is a subset
of the patch you are responding to with the message I am responding
to.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] test-string-list.c: Fix some sparse warnings
  2012-09-19 19:07   ` Ramsay Jones
@ 2012-09-20  7:13     ` Michael Haggerty
  0 siblings, 0 replies; 15+ messages in thread
From: Michael Haggerty @ 2012-09-20  7:13 UTC (permalink / raw)
  To: Ramsay Jones; +Cc: Junio C Hamano, GIT Mailing-list, Christopher Li

On 09/19/2012 09:07 PM, Ramsay Jones wrote:
> Michael Haggerty wrote:
>> Is there some documentation about how to run sparse on the git codebase?
>>  I naively tried "make sparse" and ended up with zillions of errors like
>>
>> /usr/include/unistd.h:288:54: error: attribute '__leaf__': unknown attribute
>> /usr/include/unistd.h:294:6: error: attribute '__leaf__': unknown attribute
>> /usr/include/unistd.h:298:6: error: attribute '__leaf__': unknown attribute
>> /usr/include/unistd.h:306:6: error: attribute '__leaf__': unknown attribute
>> /usr/include/unistd.h:338:18: error: attribute '__leaf__': unknown attribute
>> /usr/include/unistd.h:347:6: error: attribute '__leaf__': unknown attribute
>> /usr/include/unistd.h:418:36: error: attribute '__leaf__': unknown attribute
>> /usr/include/unistd.h:423:50: error: attribute '__leaf__': unknown attribute
> 
> Yep, "make sparse" is the correct way to run sparse over git.
> 
> This looks like you are running sparse on a 64-bit system. I have heard that
> it has (or *had*) problems running on 64-bit systems. Unfortunately, I am
> currently confined to 32-bit. (I'm looking at getting a new laptop soon, before
> Windows 8 causes boot-time problems, so I will then have the same problem!)
> 
> How did you obtain/build/install sparse? The current release (v0.4.4) was
> released about Nov 2011 and I think you need a more up to date version.
> i.e. you need to build the latest, directly from the sparse repo.

Yes, I'm running 64-bit Ubuntu 12.04 "precise".  I installed sparse from
the Ubuntu "multiverse" repository.  It is package version
0.4.3+20110419-1 in Ubuntu's notation.

Thanks very much for all the info.  I hadn't heard of sparse before and
thought that using it might help me avoid submitting patches with
problems like the ones you detected.  It does seem promising!  But since
it seems a bit fiddly to get it running, and even then has some
problems, it doesn't sound like the simple pre-submit checklist item
that I had imagined.

Michael

-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 5/7] grep.c: mark private file-scope symbols as static
  2012-09-19 20:46       ` Junio C Hamano
@ 2012-09-20 20:43         ` Ramsay Jones
  0 siblings, 0 replies; 15+ messages in thread
From: Ramsay Jones @ 2012-09-20 20:43 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano wrote:
> Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:
> 
>> Heh, so I obviously didn't see this before sending the patch yesterday! :-D
>>
>> Yes, this solves the problem addressed by yesterday's patch, so please
>> ignore that. However, this tickles sparse to complain as well ... ;-)
>>
>> New patch on it's way.
> 
> Are you sure the patch you are responding to really "tickles
> sparse"?

Yes.

> You have another grep.c patch timestamped two minutes after the
> message I am responding to, and as far as I can see, it is a subset
> of the patch you are responding to with the message I am responding
> to.

Hmm, that sentence has too many twists for me! :-D

Let me see if I can clear up the misunderstanding:

    - the "patch from yesterday" (18-09-2021) fixed a complaint from
      sparse regarding symbol 'dump_grep_expression'. This was before
      I had seen this patch email, or the resulting commit 07a7d656.
      Since my "patch from yesterday" is a strict subset of your patch,
      then your patch also fixes the complaint from sparse regarding
      the 'dump_grep_expression' symbol.

    - this patch (commit 07a7d656) causes sparse to complain about the
      symbols 'grep_source_load' and 'grep_source_is_binary'. The new
      patch from me ("timestamped two minutes after ...") also titled
      "grep.c: Fix some sparse warnings" on 19-09-2012 at 7:04 PM, is
      *not* a subset of commit 07a7d656. This patch addresses the new
      sparse warnings regarding 'grep_source_load' and
      'grep_source_is_binary'.

Hopefully that addresses the confusion! ;-)

HTH

ATB,
Ramsay Jones

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2012-09-20 20:46 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-15 16:18 [PATCH] test-string-list.c: Fix some sparse warnings Ramsay Jones
2012-09-15 20:52 ` Junio C Hamano
2012-09-15 21:10 ` [PATCH 1/7] builtin/notes.c: mark file-scope functions as static Junio C Hamano
2012-09-15 21:10   ` [PATCH 2/7] commit.c: " Junio C Hamano
2012-09-15 21:10   ` [PATCH 3/7] diff.c: mark private file-scope symbols " Junio C Hamano
2012-09-15 21:10   ` [PATCH 4/7] graph.c: " Junio C Hamano
2012-09-15 21:10   ` [PATCH 5/7] grep.c: " Junio C Hamano
2012-09-19 18:02     ` Ramsay Jones
2012-09-19 20:46       ` Junio C Hamano
2012-09-20 20:43         ` Ramsay Jones
2012-09-15 21:10   ` [PATCH 6/7] rerere.c: " Junio C Hamano
2012-09-15 21:10   ` [PATCH 7/7] notes.c: " Junio C Hamano
2012-09-17  8:15 ` [PATCH] test-string-list.c: Fix some sparse warnings Michael Haggerty
2012-09-19 19:07   ` Ramsay Jones
2012-09-20  7:13     ` Michael Haggerty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).