lkml.org 
[lkml]   [2021]   [Jul]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v10 4/8] PCI/sysfs: Allow userspace to query and set device reset mechanism
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!

\
 
 \ /
  Last update: 2021-07-28 17:37    [W:2.071 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site