git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] grep.c: Fix some sparse warnings

From
Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Date
Sep 19, 2012, 18:04 UTC
Message-ID
<505A0949.4090006@ramsay1.demon.co.uk>
In particular, sparse complains as follows:
        SP grep.c
    grep.c:1472:5: warning: symbol 'grep_source_load' was not \
        declared. Should it be static?
    grep.c:1500:5: warning: symbol 'grep_source_is_binary' was not \
        declared. Should it be static?

These warnings actually illustrate a known bug in sparse. The forward declarations of these functions (on lines 6-7) include the static modifier. These forward declarations convey the file scope property to the later function definitions. Note that the function definition does not have to include the static modifier for this to take effect.

In order to suppress the warnings, we simply include the (redundant) static modifier in the function definitions. Note that repeating the modifier, while not needed by the definition of C, does make it clear to the human reader, at the point of definition, that the symbol has file scope.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---
 grep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/grep.c b/grep.c
index c7f8a47..898be6e 100644
--- a/grep.c
+++ b/grep.c
@@ -1469,7 +1469,7 @@ static int grep_source_load_file(struct grep_source *gs)
 	return 0;
 }
 
-int grep_source_load(struct grep_source *gs)
+static int grep_source_load(struct grep_source *gs)
 {
 	if (gs->buf)
 		return 0;
@@ -1497,7 +1497,7 @@ void grep_source_load_driver(struct grep_source *gs)
 	grep_attr_unlock();
 }
 
-int grep_source_is_binary(struct grep_source *gs)
+static int grep_source_is_binary(struct grep_source *gs)
 {
 	grep_source_load_driver(gs);
 	if (gs->driver->binary != -1)
-- 
1.7.12
Message 1 of 1 in “grep.c: Fix some sparse warnings”
  1. grep.c: Fix some sparse warningsRamsay Jones, Sep 19, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.