threads / patch / 32878

patchsha1_file.c: Fix a sparse warning

Subject: [PATCH] sha1_file.c: Fix a sparse warning

## tl;dr

One message between Feb 11, 2013 and Feb 11, 2013. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Ramsay Jones· Feb 11, 2013, 19:02 UTC · lore

Sparse issues an "... was not declared. Should it be static?" warning against the 'report_pack_garbage' symbol. In order to suppress the warning, since this symbol requires more than file scope, we add an extern declaration to the cache.h header file (and remove the now redundant extern declaration in builtin/count-objects.c).

[As an alternative solution, make the variable a (static) file scope variable and add an extern function set_report_pack_garbage(), which would take a function pointer, to set the local variable ... etc.]

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

If you need to re-roll your 'nd/count-garbage' patches, could you please squash this (or something like it) into commit c2071d7a ("count-objects: report garbage files in pack directory too", 08-02-2013).

Thanks! 

[BTW, I have an unsettling feeling that the above salutation should read "Hi Duy," and I'm being (unintentionally) offensive. If so, please let me know and accept my apologies. ;-) ]

ATB, Ramsay Jones

 builtin/count-objects.c | 1 -
 cache.h                 | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)
Show changes to 2 files +3 −1

builtin/count-objects.c, cache.h

diff --git a/builtin/count-objects.c b/builtin/count-objects.c
index 118b2ae..605c215 100644
--- a/builtin/count-objects.c
+++ b/builtin/count-objects.c
@@ -11,7 +11,6 @@
 
 static unsigned long garbage;
 
-extern void (*report_pack_garbage)(const char *path, int len, const char *name);
 static void real_report_pack_garbage(const char *path, int len, const char *name)
 {
 	if (len && name)
diff --git a/cache.h b/cache.h
index 6818d87..0d687b4 100644
--- a/cache.h
+++ b/cache.h
@@ -779,6 +779,9 @@ extern int has_pack_index(const unsigned char *sha1);
 
 extern void assert_sha1_type(const unsigned char *sha1, enum object_type expect);
 
+/* A hook for count-objects to report invalid files in pack directory */
+extern void (*report_pack_garbage)(const char *path, int len, const char *name);
+
 extern const signed char hexval_table[256];
 static inline unsigned int hexval(unsigned char c)
 {
-- 
1.8.1

← back to recent threads