Re: [PATCH v10 4/8] PCI/sysfs: Allow userspace to query and set device reset mechanism

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

 



On Wed, Jul 28, 2021 at 03:27:40AM +0200, Krzysztof Wilczyński wrote:

> > > +	options = kstrndup(buf, count, GFP_KERNEL);
> > 
> > I assume the kstrndup() is because strsep() writes into the buffer?
> 
> Yes, Amey added kstrndup() in v6 following my recommendation as per:
> 
>   https://lore.kernel.org/linux-pci/20210606125800.GA76573@rocinante.localdomain/
> 
> This was to avoid removing the const quantifier through a type cast
> given that the signature of the function denotes that the buffer is
> a pointer to immutable string, as per:
> 
>   https://elixir.bootlin.com/linux/v5.14-rc3/source/include/linux/device/driver.h#L137

Ah, right, thanks!  Definitely prefer not to cast away the constness.

I guess the strings here are short (<100 chars max), so no big deal to
duplicate them.  Sorry for the noise!



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux