Re: [PATCH v1 1/4] fsck: introduce "FSCK_REF_REPORT_DEFAULT" macro

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

 



On Tue, Aug 20, 2024 at 09:25:56AM -0700, Junio C Hamano wrote:
> >  	if (check_refname_format(iter->basename, REFNAME_ALLOW_ONELEVEL)) {
> > -		struct fsck_ref_report report = { .path = NULL };
> > +		struct fsck_ref_report report = FSCK_REF_REPORT_DEFAULT;
> 
> ... the code without this patch is already doing so.
> 
> When designated initializers are used to initialize a struct, all
> members that are not initialized explicitly are implicitly
> initialized the same as for objects that have static storage
> duration (meaning: pointers are initialized to NULL, arithmetics are
> initialized to zero).
> 
> So I do not quite see why this change is needed.  By hiding the fact
> that the "report" structure is zero-initialized behind the macro, it
> makes it less obvious that we are clearing everything.
> 
> If the patch were to rewrite the above like so:
> 
> 		struct fsck_ref_report report = { 0 }
> 
> it would make it even more clear that everything is zero
> initialized, and also makes it obvious that .path member is not any
> special.
> 

Yes, I should use this way. Thanks.

> Thanks.




[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