Re: [PATCH 4.19 105/116] bpf: Explicitly memset the bpf_attr structure

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

 



On Thu, Apr 02, 2020 at 09:53:24PM +0200, Pavel Machek wrote:
> Hi!
> 
> > > Should we fix gcc, instead?
> > 
> > Also, this is allowed in the C standard, and both clang and gcc
> > sometimes emit code that does not clear padding in structures.  Changing
> > the compiler to not do this would be wonderful, but we still have to
> > live with this for the next 10 years as those older compilers age-out.
> 
> I agree C standard allows this. It allows to even worse stuff.
> 
> I was just surprised that gcc does that.. and that I did not know
> about this trap. I was probably telling people to do = {} for
> structure init...
> 
> Should we get "= {}" warning for checkpatch?

Only if the structure has padding, and it is data to be sent to
userspace, or to be intrepreted in a way from userspace.

Good luck trying to write a checkpatch rule for that.

greg k-h



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux