{"thread":{"id":"53530","subject":"[PATCH] sparse: allow '{ 0 }' to be used without warnings","startedAt":"2020-05-21T21:45:53Z","lastAt":"2020-05-21T22:08:30Z","messageCount":3,"participants":["Luc Van Oostenryck","Eric Sunshine","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"398401","messageId":"20200521214544.8784-1-luc.vanoostenryck@gmail.com","threadId":"53530","inReplyTo":null,"subject":"[PATCH] sparse: allow '{ 0 }' to be used without warnings","fromName":"Luc Van Oostenryck","fromEmail":"luc.vanoostenryck@gmail.com","sentAt":"2020-05-21T21:45:44Z","receivedAt":"2020-05-21T21:45:53Z","isPatch":true,"sender":{"key":"luc.vanoostenryck@gmail.com","avatar":"https://avatars.githubusercontent.com/u/16168334?v=4"},"body":"In standard C, '{ 0 }' can be used as an universal zero-initializer.\nHowever, Sparse complains if this is used on a type where the first\nmember (possibly nested) is a pointer since Sparse purposely wants\nto warn when '0' is used to initialize a pointer type.\n\nLegitimaly, it's desirable to be able to use '{ 0 }' as an idom\nwithout these warnings [1,2].\n\nAn option have now been added to Sparse to turn off such warnings.\nSo, add this option to the SPARSE_FLAGS variable.\n\n[1] https://lore.kernel.org/r/e6796c60-a870-e761-3b07-b680f934c537@ramsayjones.plus.com\n[2] https://lore.kernel.org/r/xmqqd07xem9l.fsf@gitster.c.googlers.com\n\nSigned-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>\n---\n Makefile | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Makefile b/Makefile\nindex 3d3a39fc19..69f065ef8c 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1189,7 +1189,7 @@ PTHREAD_CFLAGS =\n \n # For the 'sparse' target\n SPARSE_FLAGS ?=\n-SP_EXTRA_FLAGS =\n+SP_EXTRA_FLAGS = -Wno-universal-initializer\n \n # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will\n # usually result in less CPU usage at the cost of higher peak memory.\n-- \n2.26.2\n\n"},{"id":"398402","messageId":"CAPig+cQsYSE30ab9qQO7V+CzAdUodpw64sCnZH+1s3oD-P6msg@mail.gmail.com","threadId":"53530","inReplyTo":"20200521214544.8784-1-luc.vanoostenryck@gmail.com","subject":"Re: [PATCH] sparse: allow '{ 0 }' to be used without warnings","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2020-05-21T21:50:28Z","receivedAt":"2020-05-21T21:50:42Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Thu, May 21, 2020 at 5:46 PM Luc Van Oostenryck\n<luc.vanoostenryck@gmail.com> wrote:\n> In standard C, '{ 0 }' can be used as an universal zero-initializer.\n> However, Sparse complains if this is used on a type where the first\n> member (possibly nested) is a pointer since Sparse purposely wants\n> to warn when '0' is used to initialize a pointer type.\n>\n> Legitimaly, it's desirable to be able to use '{ 0 }' as an idom\n> without these warnings [1,2].\n\ns/idom/idiom/\n\n> An option have now been added to Sparse to turn off such warnings.\n> So, add this option to the SPARSE_FLAGS variable.\n\nDo you have a reference to the commit or Sparse release notes which\nmention this new option? It might be nice to include it here in the\ncommit message. Also, should this minimum Sparse version be mentioned\nsomewhere in documentation so that people invoking the \"sparse\"\nmakefile target aren't greeted with an error about\n-Wno-universal-initializer being an unrecognized option (assuming that\nolder Sparse would complain about it)?\n\n> [1] https://lore.kernel.org/r/e6796c60-a870-e761-3b07-b680f934c537@ramsayjones.plus.com\n> [2] https://lore.kernel.org/r/xmqqd07xem9l.fsf@gitster.c.googlers.com\n>\n> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>\n"},{"id":"398403","messageId":"xmqq4ks9rleu.fsf@gitster.c.googlers.com","threadId":"53530","inReplyTo":"CAPig+cQsYSE30ab9qQO7V+CzAdUodpw64sCnZH+1s3oD-P6msg@mail.gmail.com","subject":"Re: [PATCH] sparse: allow '{ 0 }' to be used without warnings","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-21T22:08:25Z","receivedAt":"2020-05-21T22:08:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> Do you have a reference to the commit or Sparse release notes which\n> mention this new option? It might be nice to include it here in the\n> commit message. Also, should this minimum Sparse version be mentioned\n> somewhere in documentation so that people invoking the \"sparse\"\n> makefile target aren't greeted with an error about\n> -Wno-universal-initializer being an unrecognized option (assuming that\n> older Sparse would complain about it)?\n\nBoth sensible considerations.  Thanks for bringing them up.\n\n>\n>> [1] https://lore.kernel.org/r/e6796c60-a870-e761-3b07-b680f934c537@ramsayjones.plus.com\n>> [2] https://lore.kernel.org/r/xmqqd07xem9l.fsf@gitster.c.googlers.com\n>>\n>> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>\n"}]}