[PATCH] sha1_file.c: Fix a sparse warning

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

 



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

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(-)

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

--
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]