Re: [PATCH 02/11] scsi: devinfo: rework scsi_strcpy_devinfo()

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

 



On Fri, Mar 29, 2024, at 00:14, Justin Stitt wrote:
>
> On Thu, Mar 28, 2024 at 03:04:46PM +0100, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@xxxxxxxx>
>> 
>> scsi_strcpy_devinfo() appears to work as intended but its semantics are
>> so confusing that gcc warns about it when -Wstringop-truncation is enabled:
>> 
>> In function 'scsi_strcpy_devinfo',
>>     inlined from 'scsi_dev_info_list_add_keyed' at drivers/scsi/scsi_devinfo.c:370:2:
>> drivers/scsi/scsi_devinfo.c:297:9: error: 'strncpy' specified bound 16 equals destination size [-Werror=stringop-truncation]
>>   297 |         strncpy(to, from, to_length);
>>       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> 
>> Reorganize the function to completely separate the nul-terminated from
>> the space-padded/non-terminated case. The former is just strscpy_pad(),
>> while the latter does not have a standard function.
>>
>
> I did the same in a patch sent earlier (few weeks ago):
>
> https://lore.kernel.org/all/20240305-strncpy-drivers-scsi-mpi3mr-mpi3mr_fw-c-v3-5-5b78a13ff984@xxxxxxxxxx/
>
> Maybe reviewers can chime in on which version is preferred and go from
> there.

I'm in favor of your version, it looks nicer and addresses the comment
that Bart had on mine.

     Arnd




[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