{"thread":{"id":"53532","subject":"[PATCH v2] sparse: allow '{ 0 }' to be used without warnings","startedAt":"2020-05-22T00:25:15Z","lastAt":"2020-05-31T16:48:47Z","messageCount":4,"participants":["Luc Van Oostenryck","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"398409","messageId":"20200522002502.9010-1-luc.vanoostenryck@gmail.com","threadId":"53532","inReplyTo":null,"subject":"[PATCH v2] sparse: allow '{ 0 }' to be used without warnings","fromName":"Luc Van Oostenryck","fromEmail":"luc.vanoostenryck@gmail.com","sentAt":"2020-05-22T00:25:02Z","receivedAt":"2020-05-22T00:25:15Z","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 idiom\nwithout these warnings [1,2]. To allow this, an option have now\nbeen added to Sparse:\n    537e3e2dae univ-init: conditionally accept { 0 } without warnings\n\nSo, add this option to the SPARSE_FLAGS variable.\n\nNote: The option have just been added to Sparse. So, to benefit\n      now from this patch it's needed to use the latest Sparse\n      source from kernel.org. The option will simply be ignored\n      by older versions of Sparse.\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\nChange since v1:\n* adapt the commit message to:\n  - fix a typo\n  - give a reference to the Spatch patch\n  - add a note telling the latest Sparse source is needed to\n    benefit from the patch but older versions won't complain.\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":"398472","messageId":"xmqqa71xqpd2.fsf@gitster.c.googlers.com","threadId":"53532","inReplyTo":"20200522002502.9010-1-luc.vanoostenryck@gmail.com","subject":"Re: [PATCH v2] sparse: allow '{ 0 }' to be used without warnings","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-24T16:17:29Z","receivedAt":"2020-05-24T16:17:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Luc Van Oostenryck <luc.vanoostenryck@gmail.com> writes:\n\n> Note: The option have just been added to Sparse. So, to benefit\n>       now from this patch it's needed to use the latest Sparse\n>       source from kernel.org. The option will simply be ignored\n>       by older versions of Sparse.\n\nThe last sentence in this paragraph is very very much appreciated\n;-)\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> ---\n>\n> Change since v1:\n> * adapt the commit message to:\n>   - fix a typo\n>   - give a reference to the Spatch patch\n>   - add a note telling the latest Sparse source is needed to\n>     benefit from the patch but older versions won't complain.\n>\n>  Makefile | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/Makefile b/Makefile\n> index 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"},{"id":"398936","messageId":"20200530162432.a7fitzjc53hsn2ej@ltop.local","threadId":"53532","inReplyTo":"xmqqa71xqpd2.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v2] sparse: allow '{ 0 }' to be used without warnings","fromName":"Luc Van Oostenryck","fromEmail":"luc.vanoostenryck@gmail.com","sentAt":"2020-05-30T16:24:32Z","receivedAt":"2020-05-30T16:24:37Z","isPatch":true,"sender":{"key":"luc.vanoostenryck@gmail.com","avatar":"https://avatars.githubusercontent.com/u/16168334?v=4"},"body":"Hi Junio,\n\nI've now changed Sparse's default to not warn when using '{ 0 }'.\nThis flag is thus now unneeded for Git and can be dropped\n(but it won't hurt to keep it).\n\n-- Luc\n"},{"id":"398954","messageId":"xmqqh7vwvymv.fsf@gitster.c.googlers.com","threadId":"53532","inReplyTo":"20200530162432.a7fitzjc53hsn2ej@ltop.local","subject":"Re: [PATCH v2] sparse: allow '{ 0 }' to be used without warnings","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-31T16:48:40Z","receivedAt":"2020-05-31T16:48:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Luc Van Oostenryck <luc.vanoostenryck@gmail.com> writes:\n\n> I've now changed Sparse's default to not warn when using '{ 0 }'.\n> This flag is thus now unneeded for Git and can be dropped\n> (but it won't hurt to keep it).\n\nNice.  Thanks.\n"}]}