linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/7] lib: string: add functions to case-convert strings
@ 2016-07-08 22:43 Markus Mayer
  2016-07-08 22:43 ` [PATCH v3 1/7] " Markus Mayer
                   ` (7 more replies)
  0 siblings, 8 replies; 24+ messages in thread
From: Markus Mayer @ 2016-07-08 22:43 UTC (permalink / raw)
  To: Andrew Morton, Al Viro, Rasmus Villemoes, Chris Metcalf, Kees Cook
  Cc: Markus Mayer, dri-devel, nouveau, linux-acpi, speakup, devel,
	linux-scsi, target-devel, linux-pm, linux-kernel

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 strlcpy()
    - 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:
    void strlcpytoupper(char *dst, const char *src, size_t len);
    void strlcpytolower(char *dst, const char *src, size_t len);
    void strcpytoupper(char *dst, const char *src);
    void strcpytolower(char *dst, const char *src);
    void strtoupper(char *s);
    void strtolower(char *s);

Several drivers are being modified to make use of the functions above.
Another driver that also makes use of this functionality will be
submitted upstream shortly, which prompted this whole exercise.

The changes made here have been compile-tested, but not tried out, due
to lack of required hardware.

Changes since v2:
  - use strlcpy() semantics not strncpy() semantics, i.e. guarantee
    NULL termination
  - as a result strncpyto<upper|lower> are now called
    strlcpyto<upper|lower>
  - make functions void
  - use len == -1 (SIZE_MAX) as no-limit indicator rather then len == 0
  - change PATCH 2/7 to match strlcpy() semantics
  - change PATCH 4/7 to match strlcpy() semantics

Changes since v1:
  - expanded strtolower() into a family of functions that cover use
    cases when a length argument is or isn't required and that support
    copying the string into a new buffer or changing it in-place 
  - changed the function semantics to return a pointer to the
    terminating '\0' character of the modified string
  - added strtoupper() functionality mirroring the above
  - dropped the ACPICA patch, since that code is OS independent and
    can't rely on a Linux library function (see [2])
  - Added two new patches replacing strtoupper() implementations

[1] https://lkml.org/lkml/2016/6/30/727
[2] https://lkml.org/lkml/2016/7/1/9



Markus Mayer (7):
  lib: string: add functions to case-convert strings
  drm/nouveau/core: make use of new strlcpytolower() function
  ACPI / device_sysfs: make use of new strtolower() function
  staging: speakup: replace spk_strlwr() with strlcpytolower()
  iscsi-target: replace iscsi_initiatorname_tolower() with strtolower()
  drm/nouveau/fifo/gk104: make use of new strcpytoupper() function
  power_supply: make use of new strcpytoupper() function

 drivers/acpi/device_sysfs.c                      |  4 +--
 drivers/gpu/drm/nouveau/nvkm/core/firmware.c     |  9 +-----
 drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c |  5 +--
 drivers/power/power_supply_sysfs.c               | 13 +++-----
 drivers/staging/speakup/kobjects.c               |  3 +-
 drivers/staging/speakup/main.c                   |  3 +-
 drivers/staging/speakup/speakup.h                |  1 -
 drivers/staging/speakup/varhandlers.c            | 12 -------
 drivers/target/iscsi/iscsi_target_nego.c         | 17 +---------
 include/linux/string.h                           | 40 ++++++++++++++++++++++++
 lib/string.c                                     | 38 ++++++++++++++++++++++
 11 files changed, 90 insertions(+), 55 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2016-07-20 21:19 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-08 22:43 [PATCH v3 0/7] lib: string: add functions to case-convert strings Markus Mayer
2016-07-08 22:43 ` [PATCH v3 1/7] " Markus Mayer
2016-07-09 12:04   ` Luis de Bethencourt
2016-07-09 15:30     ` Markus Mayer
2016-07-11 22:46       ` Markus Mayer
2016-07-13 17:19         ` Luis de Bethencourt
2016-07-13 22:26           ` Markus Mayer
2016-07-13 22:53             ` Luis de Bethencourt
2016-07-13 23:04               ` Markus Mayer
2016-07-08 22:43 ` [PATCH v3 2/7] drm/nouveau/core: make use of new strlcpytolower() function Markus Mayer
2016-07-08 22:43 ` [PATCH v3 3/7] ACPI / device_sysfs: make use of new strtolower() function Markus Mayer
2016-07-08 23:22   ` Rafael J. Wysocki
2016-07-08 22:43 ` [PATCH v3 4/7] staging: speakup: replace spk_strlwr() with strlcpytolower() Markus Mayer
2016-07-13 20:57   ` Samuel Thibault
2016-07-08 22:43 ` [PATCH v3 5/7] iscsi-target: replace iscsi_initiatorname_tolower() with strtolower() Markus Mayer
2016-07-20 21:16   ` Nicholas A. Bellinger
2016-07-20 21:17     ` Nicholas A. Bellinger
2016-07-20 21:19       ` Markus Mayer
2016-07-08 22:43 ` [PATCH v3 6/7] drm/nouveau/fifo/gk104: make use of new strcpytoupper() function Markus Mayer
2016-07-08 22:43 ` [PATCH v3 7/7] power_supply: " Markus Mayer
2016-07-10  3:13 ` [PATCH v3 0/7] lib: string: add functions to case-convert strings Chris Metcalf
2016-07-10  4:11   ` Markus Mayer
2016-07-13 22:52     ` Markus Mayer
2016-07-20 20:28       ` Markus Mayer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).