[PATCH] grep.c: Fix some sparse warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]