git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sha1_file.c: Fix a sparse warning
@ 2013-02-11 19:02 Ramsay Jones
  0 siblings, 0 replies; only message in thread
From: Ramsay Jones @ 2013-02-11 19:02 UTC (permalink / raw)
  To: Nguyen Thai Ngoc Duy; +Cc: Junio C Hamano, GIT Mailing-list


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

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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-02-11 19:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-11 19:02 [PATCH] sha1_file.c: Fix a sparse warning Ramsay Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).