{"thread":{"id":"46641","subject":"[PATCH] repository: fix a sparse 'using integer a NULL pointer' warning","startedAt":"2017-08-21T15:48:51Z","lastAt":"2017-08-22T18:12:32Z","messageCount":4,"participants":["Ramsay Jones","brian m. carlson","René Scharfe","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"326880","messageId":"91150cfc-3271-16b0-33d3-9a4e149dc9fe@ramsayjones.plus.com","threadId":"46641","inReplyTo":null,"subject":"[PATCH] repository: fix a sparse 'using integer a NULL pointer' warning","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2017-08-21T15:48:42Z","receivedAt":"2017-08-21T15:48:51Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nCommit 67a9dfcc00 (\"hash-algo: integrate hash algorithm support with\nrepo setup\", 21-08-2017) added a 'const struct git_hash_algo *hash_algo'\nfield to the repository structure, without modifying the initializer\nof the 'the_repo' variable. This does not actually introduce a bug,\nsince the '0' initializer for the 'ignore_env:1' bit-field is\ninterpreted as a NULL pointer (hence the warning), and the final field\n(now with no initializer) receives a default '0'.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n\nHi Brian,\n\nIf you need to re-roll your 'bc/hash-algo' branch, could you please\nsquash this into the relevant patch.\n\nThanks!\n\nATB,\nRamsay Jones\n\n repository.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/repository.c b/repository.c\nindex 01af20dee..ceef73614 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -5,7 +5,7 @@\n \n /* The main repository */\n static struct repository the_repo = {\n-\tNULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &the_index, 0, 0\n+\tNULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &the_index, NULL, 0, 0\n };\n struct repository *the_repository = &the_repo;\n \n-- \n2.14.0\n"},{"id":"326920","messageId":"20170822021124.4bmlzpdocgheo55b@genre.crustytoothpaste.net","threadId":"46641","inReplyTo":"91150cfc-3271-16b0-33d3-9a4e149dc9fe@ramsayjones.plus.com","subject":"Re: [PATCH] repository: fix a sparse 'using integer a NULL pointer' warning","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-08-22T02:11:24Z","receivedAt":"2017-08-22T02:11:35Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Mon, Aug 21, 2017 at 04:48:42PM +0100, Ramsay Jones wrote:\n> \n> Commit 67a9dfcc00 (\"hash-algo: integrate hash algorithm support with\n> repo setup\", 21-08-2017) added a 'const struct git_hash_algo *hash_algo'\n> field to the repository structure, without modifying the initializer\n> of the 'the_repo' variable. This does not actually introduce a bug,\n> since the '0' initializer for the 'ignore_env:1' bit-field is\n> interpreted as a NULL pointer (hence the warning), and the final field\n> (now with no initializer) receives a default '0'.\n> \n> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n> ---\n> \n> Hi Brian,\n> \n> If you need to re-roll your 'bc/hash-algo' branch, could you please\n> squash this into the relevant patch.\n\nOf course, thanks.  I'll almost certainly be doing a reroll since it's\nan RFC series and I expect to get more feedback on it.\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\nhttps://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"326946","messageId":"9e45674c-bdc2-003e-daa4-79a3903dde8f@web.de","threadId":"46641","inReplyTo":"91150cfc-3271-16b0-33d3-9a4e149dc9fe@ramsayjones.plus.com","subject":"Re: [PATCH] repository: fix a sparse 'using integer a NULL pointer' warning","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2017-08-22T17:35:58Z","receivedAt":"2017-08-22T17:36:21Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 21.08.2017 um 17:48 schrieb Ramsay Jones:\n> \n> Commit 67a9dfcc00 (\"hash-algo: integrate hash algorithm support with\n> repo setup\", 21-08-2017) added a 'const struct git_hash_algo *hash_algo'\n> field to the repository structure, without modifying the initializer\n> of the 'the_repo' variable. This does not actually introduce a bug,\n> since the '0' initializer for the 'ignore_env:1' bit-field is\n> interpreted as a NULL pointer (hence the warning), and the final field\n> (now with no initializer) receives a default '0'.\n> \n> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n> ---\n> \n> Hi Brian,\n> \n> If you need to re-roll your 'bc/hash-algo' branch, could you please\n> squash this into the relevant patch.\n> \n> Thanks!\n> \n> ATB,\n> Ramsay Jones\n> \n>   repository.c | 2 +-\n>   1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/repository.c b/repository.c\n> index 01af20dee..ceef73614 100644\n> --- a/repository.c\n> +++ b/repository.c\n> @@ -5,7 +5,7 @@\n>   \n>   /* The main repository */\n>   static struct repository the_repo = {\n> -\tNULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &the_index, 0, 0\n> +\tNULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &the_index, NULL, 0, 0\n\nThis line yells out \"designated initializer\" to me:\n\n+\t.index = &the_index\n\n>   };\n>   struct repository *the_repository = &the_repo;\n>   \n> \n"},{"id":"326951","messageId":"xmqqwp5v320m.fsf@gitster.mtv.corp.google.com","threadId":"46641","inReplyTo":"9e45674c-bdc2-003e-daa4-79a3903dde8f@web.de","subject":"Re: [PATCH] repository: fix a sparse 'using integer a NULL pointer' warning","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-08-22T18:12:25Z","receivedAt":"2017-08-22T18:12:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <l.s.r@web.de> writes:\n\n>> diff --git a/repository.c b/repository.c\n>> index 01af20dee..ceef73614 100644\n>> --- a/repository.c\n>> +++ b/repository.c\n>> @@ -5,7 +5,7 @@\n>>   \n>>   /* The main repository */\n>>   static struct repository the_repo = {\n>> -\tNULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &the_index, 0, 0\n>> +\tNULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &the_index, NULL, 0, 0\n>\n> This line yells out \"designated initializer\" to me:\n>\n> +\t.index = &the_index\n>\n>>   };\n>>   struct repository *the_repository = &the_repo;\n>>   \n>> \n\nYes, but let's hold it off for a while, until at least what is\nalready in the tip of 'master' graduates to a released version at\nthe end of the current cycle.  We picked reasonably quiecent parts\nof the codebase and implanted uses of a few C99 features to ensure\nthat we get complaints and requests for revert from people on exotic\nplatforms, so that we can back them out easily.\n\ncbc0f81d (\"strbuf: use designated initializers in STRBUF_INIT\",\n2017-07-10) does the designated initializer for struct members.\n\n512f41cf (\"clean.c: use designated initializer\", 2017-07-14) does\nthe same for array elements.\n\nIn addition, e1327023 (\"grep: refactor the concept of \"grep source\"\ninto an object\", 2012-02-02) inadvertently introduced the use of\ntrailing comma in enum definition about 5 years ago, so we know that\none is safe to use.\n"}]}