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

Re: [PATCH] repository: fix a sparse 'using integer a NULL pointer' warning

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 22, 2017, 18:12 UTC
Message-ID
<xmqqwp5v320m.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<9e45674c-bdc2-003e-daa4-79a3903dde8f@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 19 quoted lines
>> diff --git a/repository.c b/repository.c
>> index 01af20dee..ceef73614 100644
>> --- a/repository.c
>> +++ b/repository.c
>> @@ -5,7 +5,7 @@
>>   
>>   /* The main repository */
>>   static struct repository the_repo = {
>> -	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &the_index, 0, 0
>> +	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &the_index, NULL, 0, 0
>
> This line yells out "designated initializer" to me:
>
> +	.index = &the_index
>
>>   };
>>   struct repository *the_repository = &the_repo;
>>   
>> 

Yes, but let's hold it off for a while, until at least what is already in the tip of 'master' graduates to a released version at the end of the current cycle. We picked reasonably quiecent parts of the codebase and implanted uses of a few C99 features to ensure that we get complaints and requests for revert from people on exotic platforms, so that we can back them out easily.

cbc0f81d ("strbuf: use designated initializers in STRBUF_INIT", 2017-07-10) does the designated initializer for struct members.

512f41cf ("clean.c: use designated initializer", 2017-07-14) does the same for array elements.

In addition, e1327023 ("grep: refactor the concept of "grep source" into an object", 2012-02-02) inadvertently introduced the use of trailing comma in enum definition about 5 years ago, so we know that one is safe to use.

Previous: René Scharfe
Message 4 of 4 in “repository: fix a sparse 'using integer a NULL pointer' warning”
  1. repository: fix a sparse 'using integer a NULL pointer' warningRamsay Jones, Aug 21, 2017
  2. brian m. carlsonAug 22, 2017
  3. René ScharfeAug 22, 2017
  4. Junio C HamanoAug 22, 2017

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.