git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / Atom feed
* [PATCH] sparse: allow '{ 0 }' to be used without warnings
@ 2020-05-21 21:45 Luc Van Oostenryck
  2020-05-21 21:50 ` Eric Sunshine
  0 siblings, 1 reply; 3+ messages in thread
From: Luc Van Oostenryck @ 2020-05-21 21:45 UTC (permalink / raw)
  To: GIT Mailing-list
  Cc: Junio C Hamano, Ramsay Jones,
	Đoàn Trần Công Danh, Luc Van Oostenryck

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@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>
---
 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sparse: allow '{ 0 }' to be used without warnings
  2020-05-21 21:45 [PATCH] sparse: allow '{ 0 }' to be used without warnings Luc Van Oostenryck
@ 2020-05-21 21:50 ` Eric Sunshine
  2020-05-21 22:08   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Sunshine @ 2020-05-21 21:50 UTC (permalink / raw)
  To: Luc Van Oostenryck
  Cc: GIT Mailing-list, Junio C Hamano, Ramsay Jones,
	Đoàn Trần Công Danh

On Thu, May 21, 2020 at 5:46 PM Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
> 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].

s/idom/idiom/

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

Do you have a reference to the commit or Sparse release notes which
mention this new option? It might be nice to include it here in the
commit message. Also, should this minimum Sparse version be mentioned
somewhere in documentation so that people invoking the "sparse"
makefile target aren't greeted with an error about
-Wno-universal-initializer being an unrecognized option (assuming that
older Sparse would complain about it)?

> [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>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sparse: allow '{ 0 }' to be used without warnings
  2020-05-21 21:50 ` Eric Sunshine
@ 2020-05-21 22:08   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2020-05-21 22:08 UTC (permalink / raw)
  To: Eric Sunshine
  Cc: Luc Van Oostenryck, GIT Mailing-list, Ramsay Jones,
	Đoàn Trần Công Danh

Eric Sunshine <sunshine@sunshineco.com> writes:

> Do you have a reference to the commit or Sparse release notes which
> mention this new option? It might be nice to include it here in the
> commit message. Also, should this minimum Sparse version be mentioned
> somewhere in documentation so that people invoking the "sparse"
> makefile target aren't greeted with an error about
> -Wno-universal-initializer being an unrecognized option (assuming that
> older Sparse would complain about it)?

Both sensible considerations.  Thanks for bringing them up.

>
>> [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>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-21 21:45 [PATCH] sparse: allow '{ 0 }' to be used without warnings Luc Van Oostenryck
2020-05-21 21:50 ` Eric Sunshine
2020-05-21 22:08   ` Junio C Hamano

git@vger.kernel.org list mirror (unofficial, one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git