{"thread":{"id":"31609","subject":"[PATCH] grep.c: Fix some sparse warnings","startedAt":"2012-09-19T18:04:57Z","lastAt":"2012-09-19T18:04:57Z","messageCount":1,"participants":["Ramsay Jones"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"199515","messageId":"505A0949.4090006@ramsay1.demon.co.uk","threadId":"31609","inReplyTo":null,"subject":"[PATCH] grep.c: Fix some sparse warnings","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2012-09-19T18:04:57Z","receivedAt":"2012-09-19T18:04:57Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nIn particular, sparse complains as follows:\n\n        SP grep.c\n    grep.c:1472:5: warning: symbol 'grep_source_load' was not \\\n        declared. Should it be static?\n    grep.c:1500:5: warning: symbol 'grep_source_is_binary' was not \\\n        declared. Should it be static?\n\nThese warnings actually illustrate a known bug in sparse. The forward\ndeclarations of these functions (on lines 6-7) include the static\nmodifier. These forward declarations convey the file scope property to\nthe later function definitions. Note that the function definition does\nnot have to include the static modifier for this to take effect.\n\nIn order to suppress the warnings, we simply include the (redundant)\nstatic modifier in the function definitions. Note that repeating the\nmodifier, while not needed by the definition of C, does make it clear\nto the human reader, at the point of definition, that the symbol has\nfile scope.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n grep.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex c7f8a47..898be6e 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -1469,7 +1469,7 @@ static int grep_source_load_file(struct grep_source *gs)\n \treturn 0;\n }\n \n-int grep_source_load(struct grep_source *gs)\n+static int grep_source_load(struct grep_source *gs)\n {\n \tif (gs->buf)\n \t\treturn 0;\n@@ -1497,7 +1497,7 @@ void grep_source_load_driver(struct grep_source *gs)\n \tgrep_attr_unlock();\n }\n \n-int grep_source_is_binary(struct grep_source *gs)\n+static int grep_source_is_binary(struct grep_source *gs)\n {\n \tgrep_source_load_driver(gs);\n \tif (gs->driver->binary != -1)\n-- \n1.7.12\n"}]}