Re: [PATCH 2/4] SCSI-QLA4...: Less function calls in qla4xxx_is_session_exists() after error detection

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

 



On Sat, Feb 07, 2015 at 11:11:03AM +0100, Julia Lawall wrote:
> On Sat, 7 Feb 2015, Dan Carpenter wrote:
> 
> > On Fri, Feb 06, 2015 at 11:15:13PM +0100, SF Markus Elfring wrote:
> > > diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
> > > index 2a00fd3..a7ca479 100644
> > > --- a/drivers/scsi/qla4xxx/ql4_os.c
> > > +++ b/drivers/scsi/qla4xxx/ql4_os.c
> > > @@ -6327,17 +6327,15 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha,
> > >  				     uint32_t *index)
> > >  {
> > >  	struct ddb_entry *ddb_entry;
> > > -	struct ql4_tuple_ddb *fw_tddb = NULL;
> > > -	struct ql4_tuple_ddb *tmp_tddb = NULL;
> > >  	int idx;
> > >  	int ret = QLA_ERROR;
> > > +	struct ql4_tuple_ddb *tmp_tddb;
> > > +	struct ql4_tuple_ddb *fw_tddb = vzalloc(sizeof(*fw_tddb));
> > >  
> > 
> > Don't do allocations in the initializers.  Same for patches 3 and 4 as
> > well.
> 
> Why not?  I can think of some reasons, but I am wondering what is the 
> precise one.

1)  People gloss over initializers without reading them.  You shouldn't
    put complicated code in initializers.  Sarah Sharp is more strict on
    this than I am.  http://www.spinics.net/lists/linux-usb/msg44389.html

2)  It means you have to put a line of separation between the allocation
    and the NULL check, but they should be next to each other.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux