Re: [PATCH 1/1] RDMA/rtrs: Fix the problem of variable not initialized fully

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

 



On Wed, Sep 20, 2023 at 10:47:53AM +0300, Leon Romanovsky wrote:

> > >> About this problem, I think we discussed it previously in RDMA maillist.
> > >>
> > >> And at that time, IIRC, you shared a link with me. The link is as below.
> > >>
> > >> https://www.ex-parrot.com/~chris/random/initialise.html
> > >>
> > >>  From what we discussed and the above link, I think it is not initialized
> > >> fully.
> > > 
> > > I remember that discussion and it was about slightly different thing:
> > > {} vs {0} in Linux kernel.
> > 
> > 
> > Well, in my mind, I thought they are the same. see: https://www.gnu.org/software/gnu-c-manual/gnu-c-manual.html#Initializing-Structure-Members
> 
> It is GCC specific implementation, the original discussion was about C-standard.

Yes, the C standard says they are different constructs and
pedantically only {} is required to fully zero the struct, padding and
all.

{0} says 'zero initialize the first member of the struct', it is a
terrible construct because the first member may not be an integer,
don't use it.

Jason



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux