Re: [PATCH v7 1/3] mm: add kstrdup_trimnl function
From: Andrew Morton
Date: Wed Feb 05 2014 - 18:01:17 EST
On Wed, 05 Feb 2014 14:55:52 -0800 Sebastian Capella <sebastian.capella@xxxxxxxxxx> wrote:
> Quoting Andrew Morton (2014-02-05 13:50:52)
> > On Tue, 4 Feb 2014 12:43:49 -0800 Sebastian Capella <sebastian.capella@xxxxxxxxxx> wrote:
> >
> > > kstrdup_trimnl creates a duplicate of the passed in
> > > null-terminated string. If a trailing newline is found, it
> > > is removed before duplicating. This is useful for strings
> > > coming from sysfs that often include trailing whitespace due to
> > > user input.
> >
> > hm, why? I doubt if any caller of this wants to retain leading and/or
> > trailing spaces and/or tabs.
>
> Hi Andrew,
>
> I agree the common case doesn't usually need leading or trailing whitespace.
>
> Pavel and others pointed out that a valid filename could contain
> newlines/whitespace at any position.
The number of cases in which we provide the kernel with a filename via
sysfs will be very very small, or zero.
If we can go through existing code and find at least a few sites which
can usefully employ kstrdup_trimnl() then fine, we have evidence. But
I doubt if we can do that?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/