Skip to contentSkip to conversation

repository.c: fix sparse warning

PATCH In review Ramsay Jones 2 participants 3 messages Jan 17, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 repository.c: fix sparse warning

---

Hi Duy,

If you need to re-roll your 'nd/the-index-final' branch, could you please squash this into the relevant patch (commit 4478671442, "cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch", 2019-01-12).

[the warning is caused by the lack of the extern declaration of the 'the_index' symbol.]

Thanks!

ATB,
Ramsay Jones

 repository.c | 1 +
 1 file changed, 1 insertion(+)
repository.c +1 -0
index 0c6814627e..3ecbb1b6e3 100644
@@ -1,3 +1,4 @@
+#define USE_THE_INDEX_COMPATIBILITY_MACROS
 #include "cache.h"
 #include "repository.h"
 #include "object-store.h"
Signature · 1 line
2.20.0
#1 lore raw
Quoted 5 lines · Ramsay Jones

---

Quoted 8 lines

Hi Duy,

If you need to re-roll your 'nd/the-index-final' branch, could you please squash this into the relevant patch (commit 4478671442, "cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch", 2019-01-12).

[the warning is caused by the lack of the extern declaration of the 'the_index' symbol.]

Is it a false alarm? The variable is actually defined in this file now which should also function as a declaration, yes?

Quoted 20 lines

Thanks!

ATB,
Ramsay Jones

 repository.c | 1 +
 1 file changed, 1 insertion(+)
repository.c +1 -1
index 0c6814627e..3ecbb1b6e3 100644
@@ -1,3 +1,4 @@
+#define USE_THE_INDEX_COMPATIBILITY_MACROS
 #include "cache.h"
 #include "repository.h"
 #include "object-store.h"
--

2.20.0

Signature · 1 line
Duy
#2 lore raw
Quoted 13 lines · Duy Nguyen
Quoted 11 lines · Ramsay Jones

---

Hi Duy,

If you need to re-roll your 'nd/the-index-final' branch, could you please squash this into the relevant patch (commit 4478671442, "cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch", 2019-01-12).

Quoted 5 lines
Quoted 2 lines

[the warning is caused by the lack of the extern declaration of the 'the_index' symbol.]

Is it a false alarm? The variable is actually defined in this file now which should also function as a declaration, yes?

Ah, no, absolutely not! :( (er, well yes, but no! :-D ).

I hope you agree that _all_ uses of a symbol should be within the scope of the same declaration of that symbol (by #include-ing the same header/interface file). This is _especially_ true of the file which has the definition of that symbol - how else do you expect the compiler to detect a mismatch between the declaration and definition?

ATB,
Ramsay Jones