]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sparse: allow '{ 0 }' to be used without warnings
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
Fri, 22 May 2020 00:25:02 +0000 (02:25 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 24 May 2020 23:41:21 +0000 (16:41 -0700)
In standard C, '{ 0 }' can be used as an universal zero-initializer.
However, Sparse complains if this is used on a type where the first
member (possibly nested) is a pointer since Sparse purposely wants
to warn when '0' is used to initialize a pointer type.

Legitimaly, it's desirable to be able to use '{ 0 }' as an idiom
without these warnings [1,2]. To allow this, an option have now
been added to Sparse:
    537e3e2dae univ-init: conditionally accept { 0 } without warnings

So, add this option to the SPARSE_FLAGS variable.

Note: The option have just been added to Sparse. So, to benefit
      now from this patch it's needed to use the latest Sparse
      source from kernel.org. The option will simply be ignored
      by older versions of Sparse.

[1] https://lore.kernel.org/r/e6796c60-a870-e761-3b07-b680f934c537@ramsayjones.plus.com
[2] https://lore.kernel.org/r/xmqqd07xem9l.fsf@gitster.c.googlers.com

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile

index 9804a0758b2458f0ba3d7130c83d7d22d9570879..c58b781105496c4b498433fb9ab8b55405b46e40 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1188,7 +1188,7 @@ PTHREAD_CFLAGS =
 
 # For the 'sparse' target
 SPARSE_FLAGS ?=
-SP_EXTRA_FLAGS =
+SP_EXTRA_FLAGS = -Wno-universal-initializer
 
 # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will
 # usually result in less CPU usage at the cost of higher peak memory.