[PATCH] sparse: allow '{ 0 }' to be used without warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 idom
without these warnings [1,2].

An option have now been added to Sparse to turn off such warnings.
So, add this option to the SPARSE_FLAGS variable.

[1] https://lore.kernel.org/r/e6796c60-a870-e761-3b07-b680f934c537@xxxxxxxxxxxxxxxxxxxx
[2] https://lore.kernel.org/r/xmqqd07xem9l.fsf@xxxxxxxxxxxxxxxxxxxxxx

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 3d3a39fc19..69f065ef8c 100644
--- a/Makefile
+++ b/Makefile
@@ -1189,7 +1189,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.
-- 
2.26.2




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux