Re: [PATCH v2 5/8] fwctl: FWCTL_RPC to execute a Remote Procedure Call to device firmware

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

 



On Thu, 1 Aug 2024 20:26:31 +0300
Leon Romanovsky <leon@xxxxxxxxxx> wrote:

> On Thu, Aug 01, 2024 at 09:58:29AM -0300, Jason Gunthorpe wrote:
> > On Tue, Jul 30, 2024 at 11:00:38AM +0300, Leon Romanovsky wrote:  
> > > > +
> > > > +	void *inbuf __free(kvfree) =
> > > > +		kvzalloc(cmd->in_len, GFP_KERNEL | GFP_KERNEL_ACCOUNT);  
> > > 
> > > 
> > > <...>
> > >   
> > > > +	out_len = cmd->out_len;
> > > > +	void *outbuf __free(kvfree_errptr) = fwctl->ops->fw_rpc(
> > > > +		ucmd->uctx, cmd->scope, inbuf, cmd->in_len, &out_len);  
> > > 
> > > I was under impression that declaration of variables in C should be at the beginning
> > > of block. Was it changed for the kernel?  
> > 
> > Yes, the compiler check blocking variables in the body was disabled to
> > allow cleanup.h
> > 
> > Jonathan said this is the agreed coding style to use for this  
> 
> I'm said to hear that.

Was passing on a statement Linus made (not digging it out right now)
that he really wanted to be able see constructors and destructors
together.

The other part is that in some cases you can end up with non
obvious ordering bugs because the cleanup is the reverse of the
declarations, not the constructors being called.
Whilst it is fairly easy to review for this, future code reorganization
may well lead to subtle bugs, typically in error paths etc.

Putting the declaration inline avoids this potential problem

Dan wrote a style guide proposal.
https://lore.kernel.org/all/171175585714.2192972.12661675876300167762.stgit@xxxxxxxxxxxxxxxxxxxxxxxxx/
[PATCH v3] cleanup: Add usage and style documentation

seems it died out without anyone applying it.  I've poked.

Jonathan

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