From: Joe Perches <joe@perches.com>
To: Markus Mayer <markus.mayer@broadcom.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Chris Metcalf <cmetcalf@ezchip.com>,
Kees Cook <keescook@chromium.org>,
dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org,
linux-acpi@vger.kernel.org, speakup@linux-speakup.org,
devel@driverdev.osuosl.org, linux-scsi@vger.kernel.org,
target-devel@vger.kernel.org, linux-pm@vger.kernel.org,
Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 0/7] lib: string: add functions to case-convert strings
Date: Tue, 05 Jul 2016 15:56:17 -0700 [thread overview]
Message-ID: <1467759377.8360.12.camel@perches.com> (raw)
In-Reply-To: <CAGt4E5vqiUOVmgqY8OvRPNpoS54hZMOHid6ND4CRyb5p9y5ndw@mail.gmail.com>
On Tue, 2016-07-05 at 15:36 -0700, Markus Mayer wrote:
> On 5 July 2016 at 15:14, Joe Perches <joe@perches.com> wrote:
> > On Tue, 2016-07-05 at 13:47 -0700, Markus Mayer wrote:
> > > This series introduces a family of generic string case conversion
> > > functions. This kind of functionality is needed in several places in
> > > the kernel. Right now, everybody seems to be implementing their own
> > > copy of this functionality.
> > >
> > > Based on the discussion of the previous version of this series[1] and
> > > the use cases found in the kernel, it does look like having several
> > > flavours of case conversion functions is beneficial. The use cases fall
> > > into three categories:
> > > - copying a string and converting the case while specifying a
> > > maximum length to mimic strncpy()
> > > - copying a string and converting the case without specifying a
> > > length to mimic strcpy()
> > > - converting the case of a string in-place (i.e. modifying the
> > > string that was passed in)
> > >
> > > Consequently, I am proposing these new functions:
> > > char *strncpytoupper(char *dst, const char *src, size_t len);
> > > char *strncpytolower(char *dst, const char *src, size_t len);
> > > char *strcpytoupper(char *dst, const char *src);
> > > char *strcpytolower(char *dst, const char *src);
> > > char *strtoupper(char *s);
> > > char *strtolower(char *s);
> > I think there isn't much value in anything other
> > than strto.
> >
> > Using str[n]cpy followed by strto is
> > pretty obvious and rarely used anyway.
> First time around, folks were proposing the "copy" variants when I
> submitted just strtolower() by itself[1]. They just asked for source
> and destination parameters to strtolower(), but looking at the use
> cases that wouldn't have worked so well. Hence it evolved into these 6
> functions.
>
> Here's a breakdown of how the functions are being used (patches 2-7),
> see also [2]:
>
> Patch 2: strncpytolower()
> Patch 3: strtolower()
> Patch 4: strncpytolower() and strtolower()
> Patch 5: strtolower()
> Patch 6: strcpytoupper()
> Patch 7: strcpytoupper()
>
> So it does look like the copy + change case variant is more frequently
> used than just strto.
Are these functions useful? <shrug> Not to me, not so much.
None of the functions would have the strcpy performance of
the arch / asm
versions of strcpy and the savings in overall
code isn't significant (or
measured?).
Of course none of the uses are runtime performance important.
This patch also adds always compiled functions that aren't used
in many .configs.
next prev parent reply other threads:[~2016-07-05 22:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-05 20:47 [PATCH v2 0/7] lib: string: add functions to case-convert strings Markus Mayer
2016-07-05 20:47 ` [PATCH v2 1/7] " Markus Mayer
2016-07-07 11:04 ` Eric Engestrom
2016-07-08 0:19 ` Rasmus Villemoes
2016-07-08 18:04 ` Markus Mayer
2016-07-05 20:47 ` [PATCH v2 2/7] drm/nouveau/core: make use of new strncpytolower() function Markus Mayer
2016-07-05 20:47 ` [PATCH v2 3/7] ACPI / device_sysfs: make use of new strtolower() function Markus Mayer
2016-07-05 20:47 ` [PATCH v2 4/7] staging: speakup: replace spk_strlwr() with strncpytolower() Markus Mayer
2016-07-05 20:47 ` [PATCH v2 5/7] iscsi-target: replace iscsi_initiatorname_tolower() with strtolower() Markus Mayer
2016-07-05 20:47 ` [PATCH v2 6/7] drm/nouveau/fifo/gk104: make use of new strcpytoupper() function Markus Mayer
2016-07-05 20:47 ` [PATCH v2 7/7] power_supply: " Markus Mayer
2016-07-05 22:14 ` [PATCH v2 0/7] lib: string: add functions to case-convert strings Joe Perches
2016-07-05 22:36 ` Markus Mayer
2016-07-05 22:56 ` Joe Perches [this message]
2016-07-06 4:32 ` Markus Mayer
2016-07-07 5:05 ` [Nouveau] " Alexandre Courbot
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=1467759377.8360.12.camel@perches.com \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=cmetcalf@ezchip.com \
--cc=devel@driverdev.osuosl.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=keescook@chromium.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=markus.mayer@broadcom.com \
--cc=nouveau@lists.freedesktop.org \
--cc=speakup@linux-speakup.org \
--cc=target-devel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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