Re: [RFC PATCH rdma-next v2] RDMA/srp: Rename SRP sysfs name after IB device rename trigger

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

 



On Wed, May 15, 2019 at 07:32:35PM +0200, Bart Van Assche wrote:
> On 5/15/19 7:06 PM, Leon Romanovsky wrote:
> > +	list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) {
> > +		char name[IB_DEVICE_NAME_MAX * 2] = {};
>                           ^^^^^^^^^^^^^^^^^^^^^^
> I think this should be IB_DEVICE_NAME_MAX + 8 instead of ... * 2. Please
> also consider to leave out the initialization of the char array since
> snprintf() overwrites the array whether or not it has been initialized.

Any reason why shoud we care for this micro optimizations?

>
> > +		snprintf(name, IB_DEVICE_NAME_MAX * 2, "srp-%s-%d",
>                                ^^^^^^^^^^^^^^^^^^^^^^
> Please change this into sizeof(name) such that the size expression only
> occurs once.

The same as sizeof it is calculated once at the stage of defines
expansion.

>
> Thanks,
>
> Bart.
>



[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