Re: [PATCH 02/11] submodule--helper: replace memset() with { 0 }-initialization

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

 



Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> writes:

> On Wed, Jul 13 2022, Glen Choo wrote:
> Anyway, I was curious about this so I tried the following locally:
> 	
> 	@@
> 	type T;
> 	identifier I;
> 	@@
> 	- T I;
> 	+ T I = { 0 };
> 	... when strict
> 	    when != \( I \| &I \)
> 	(
> 	- memset(&I, 0, sizeof(I));
> 	|
> 	- memset(&I, 0, sizeof(T));
> 	)
> 	
>
> Which aside from whitespace issues (that I've asked the cocci ML about)
> yields a sane result...
>> ....... If I have time I'll send that proposal to CodingGuidelines, or
>> someone else can send it (I don't mind either way).

Adding an extra cocci check sounds like a great addition alongside the
CodingGuidelines change (automatically checking the rule is way better
than doing it manually of course). The fact that { 0 } is wrapped around
two lines is annoying, e.g.

  -	struct update_callback_data data;
  +	struct update_callback_data data = {
  +		0
  +	};
    struct rev_info rev;

  -	memset(&data, 0, sizeof(data));
    data.flags = flags;

but since it goes away with "make style", I'm tempted to say that this
check is worth having. Is it too confusing to have coccinelle recommend
something that we expect users to fix afterwards?




[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