{"thread":{"id":"32878","subject":"[PATCH] sha1_file.c: Fix a sparse warning","startedAt":"2013-02-11T19:02:17Z","lastAt":"2013-02-11T19:02:17Z","messageCount":1,"participants":["Ramsay Jones"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"209290","messageId":"51194039.4010407@ramsay1.demon.co.uk","threadId":"32878","inReplyTo":null,"subject":"[PATCH] sha1_file.c: Fix a sparse warning","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2013-02-11T19:02:17Z","receivedAt":"2013-02-11T19:02:17Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nSparse issues an \"... was not declared. Should it be static?\" warning\nagainst the 'report_pack_garbage' symbol. In order to suppress the\nwarning, since this symbol requires more than file scope, we add an\nextern declaration to the cache.h header file (and remove the now\nredundant extern declaration in builtin/count-objects.c).\n\n[As an alternative solution, make the variable a (static) file scope\nvariable and add an extern function set_report_pack_garbage(), which\nwould take a function pointer, to set the local variable ... etc.]\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n\nHi Nguyen,\n\nIf you need to re-roll your 'nd/count-garbage' patches, could you\nplease squash this (or something like it) into commit c2071d7a\n(\"count-objects: report garbage files in pack directory too\",\n08-02-2013).\n\nThanks! \n\n[BTW, I have an unsettling feeling that the above salutation should\nread \"Hi Duy,\" and I'm being (unintentionally) offensive. If so,\nplease let me know and accept my apologies. ;-) ]\n\nATB,\nRamsay Jones\n\n builtin/count-objects.c | 1 -\n cache.h                 | 3 +++\n 2 files changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/count-objects.c b/builtin/count-objects.c\nindex 118b2ae..605c215 100644\n--- a/builtin/count-objects.c\n+++ b/builtin/count-objects.c\n@@ -11,7 +11,6 @@\n \n static unsigned long garbage;\n \n-extern void (*report_pack_garbage)(const char *path, int len, const char *name);\n static void real_report_pack_garbage(const char *path, int len, const char *name)\n {\n \tif (len && name)\ndiff --git a/cache.h b/cache.h\nindex 6818d87..0d687b4 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -779,6 +779,9 @@ extern int has_pack_index(const unsigned char *sha1);\n \n extern void assert_sha1_type(const unsigned char *sha1, enum object_type expect);\n \n+/* A hook for count-objects to report invalid files in pack directory */\n+extern void (*report_pack_garbage)(const char *path, int len, const char *name);\n+\n extern const signed char hexval_table[256];\n static inline unsigned int hexval(unsigned char c)\n {\n-- \n1.8.1\n"}]}