# [PATCH] repository.c: fix sparse warning

3 messages from 2019-01-17 to 2019-01-17. Participants: Ramsay Jones, Duy Nguyen.
Thread: https://gitlist.dev/t/50246

## Ramsay Jones, 2019-01-17 01:07

Subject: [PATCH] repository.c: fix sparse warning
Message-ID: <419519f9-1b48-93bb-eead-eacf6b383f70@ramsayjones.plus.com>
URL: https://gitlist.dev/e/419519f9-1b48-93bb-eead-eacf6b383f70%40ramsayjones.plus.com

```

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---

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

diff --git a/repository.c b/repository.c
index 0c6814627e..3ecbb1b6e3 100644
--- a/repository.c
+++ b/repository.c
@@ -1,3 +1,4 @@
+#define USE_THE_INDEX_COMPATIBILITY_MACROS
 #include "cache.h"
 #include "repository.h"
 #include "object-store.h"
-- 
2.20.0

```

## Duy Nguyen, 2019-01-17 10:06

Subject: Re: [PATCH] repository.c: fix sparse warning
Message-ID: <CACsJy8BWfdCwFwhfKku-AqP5sGpB7CN4O-Qu0b1cm3iTbW8Z_Q@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8BWfdCwFwhfKku-AqP5sGpB7CN4O-Qu0b1cm3iTbW8Z_Q%40mail.gmail.com
In-Reply-To: <419519f9-1b48-93bb-eead-eacf6b383f70@ramsayjones.plus.com>

```
On Thu, Jan 17, 2019 at 8:21 AM Ramsay Jones
<ramsay@ramsayjones.plus.com> wrote:
>
>
> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
> ---
>
> 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?

>
> Thanks!
>
> ATB,
> Ramsay Jones
>
>  repository.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/repository.c b/repository.c
> index 0c6814627e..3ecbb1b6e3 100644
> --- a/repository.c
> +++ b/repository.c
> @@ -1,3 +1,4 @@
> +#define USE_THE_INDEX_COMPATIBILITY_MACROS
>  #include "cache.h"
>  #include "repository.h"
>  #include "object-store.h"
> --
> 2.20.0



-- 
Duy

```

## Ramsay Jones, 2019-01-17 16:51

Subject: Re: [PATCH] repository.c: fix sparse warning
Message-ID: <b6aaaa72-03cd-2b3d-7328-f7a2fb0d85a2@ramsayjones.plus.com>
URL: https://gitlist.dev/e/b6aaaa72-03cd-2b3d-7328-f7a2fb0d85a2%40ramsayjones.plus.com
In-Reply-To: <CACsJy8BWfdCwFwhfKku-AqP5sGpB7CN4O-Qu0b1cm3iTbW8Z_Q@mail.gmail.com>

```


On 17/01/2019 10:06, Duy Nguyen wrote:
> On Thu, Jan 17, 2019 at 8:21 AM Ramsay Jones
> <ramsay@ramsayjones.plus.com> wrote:
>>
>>
>> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
>> ---
>>
>> 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?

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

```
