git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] repository.c: fix sparse warning

From
Ramsay Jones <ramsay@ramsayjones.plus.com>
Date
Jan 17, 2019, 16:51 UTC
Message-ID
<b6aaaa72-03cd-2b3d-7328-f7a2fb0d85a2@ramsayjones.plus.com>
In-Reply-To
<CACsJy8BWfdCwFwhfKku-AqP5sGpB7CN4O-Qu0b1cm3iTbW8Z_Q@mail.gmail.com>
On 17/01/2019 10:06, Duy Nguyen wrote:
Show 18 quoted lines
> 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

Previous: Duy Nguyen
Message 3 of 3 in “repository.c: fix sparse warning”
  1. repository.c: fix sparse warningRamsay Jones, Jan 17, 2019
  2. Duy NguyenJan 17, 2019
  3. Ramsay JonesJan 17, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.