From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Arnd Bergmann <arnd@arndb.de>, Martin Wilck <mwilck@suse.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-kernel@vger.kernel.org,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Subject: Re: [RFC][PATCH] lib/string: introduce sysfs_strncpy() and sysfs_strlcpy()
Date: Wed, 22 Aug 2018 14:13:14 +0900 [thread overview]
Message-ID: <20180822051314.GB6876@jagdpanzerIV> (raw)
In-Reply-To: <4bef099f-b2e1-0327-271d-75662b366c07@rasmusvillemoes.dk>
Hi,
On (08/21/18 14:43), Rasmus Villemoes wrote:
> > I think that sysfs input is always properly NULL-terminated. It may or
> > may not contain \n, but \0 is expected to be there.
>
> Maybe. But it shouldn't hurt to make it accept a src size (the caller
> can always pass -1 is he's sure the input is nul-terminated) - I'm
> thinking a new interface might also have uses outside sysfs.
Makes sense.
> > E.g.
> > channel_dimm_label_store()
> > dimmdev_label_store()
> > pmbus_add_label()
> > axp20x_store_attr()
> > cmdline_store()
>
> Hm, do any of those actually want the skipping of leading whitespace?
Hm, that's a good question. I'd probably say "mostly yes". The input
usually goes to strcmp/strcpy/strtol/etc. But we don't have to trim
leading whitespaces and can just let the driver error out [hopefully
the driver has a well tested error-out path].
> pmbus_add_label doesn't even seem to kill a trailing newline?
Sorry, I think pmbus_add_label() made it to the list by mistake. It doesn't
appear to be a ->store() callback.
> It's probably hard to create one interface that will work for all cases.
Agreed, that's why I targeted sysfs input data only ;)
> Dunno, looking at your examples above I'm a bit more skeptical that
> there is a lot of common ground. But of course there are hundreds of
> other store callbacks, so surely one can simplify some with a new helper.
Yep.
-ss
next prev parent reply other threads:[~2018-08-22 5:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-21 6:24 [RFC][PATCH] lib/string: introduce sysfs_strncpy() and sysfs_strlcpy() Sergey Senozhatsky
2018-08-21 7:59 ` Rasmus Villemoes
2018-08-21 9:50 ` Sergey Senozhatsky
2018-08-21 9:54 ` Sergey Senozhatsky
2018-08-21 11:44 ` Sergey Senozhatsky
2018-08-21 12:00 ` Andy Shevchenko
2018-08-22 0:32 ` Sergey Senozhatsky
2018-08-21 12:43 ` Rasmus Villemoes
2018-08-22 5:13 ` Sergey Senozhatsky [this message]
2018-08-21 13:57 ` Greg Kroah-Hartman
2018-08-22 4:58 ` Sergey Senozhatsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180822051314.GB6876@jagdpanzerIV \
--to=sergey.senozhatsky.work@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mwilck@suse.com \
--cc=sergey.senozhatsky@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox