From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750916AbcGJELM (ORCPT ); Sun, 10 Jul 2016 00:11:12 -0400 Received: from mail-vk0-f43.google.com ([209.85.213.43]:36328 "EHLO mail-vk0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750758AbcGJELI (ORCPT ); Sun, 10 Jul 2016 00:11:08 -0400 MIME-Version: 1.0 In-Reply-To: <9b88baed-a067-fcfd-d087-66e36f3060d7@mellanox.com> References: <1468017794-4818-1-git-send-email-mmayer@broadcom.com> <9b88baed-a067-fcfd-d087-66e36f3060d7@mellanox.com> From: Markus Mayer Date: Sat, 9 Jul 2016 21:11:05 -0700 Message-ID: Subject: Re: [PATCH v3 0/7] lib: string: add functions to case-convert strings To: Chris Metcalf Cc: Andrew Morton , Al Viro , Rasmus Villemoes , Kees Cook , 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 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9 July 2016 at 20:13, Chris Metcalf wrote: > On 7/8/2016 6:43 PM, 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 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); > > > You may want to read the article here: > > https://lwn.net/Articles/659214/ I'll read that. Thanks. > and follow up some of the discussion threads on LKML about the best > semantics to advertise for the strlcpy/strscpy variants. It might be > helpful to return some kind of overflow/truncation error from your > copy functions so people can error-check the result. I am inclined to agree. However, everybody has been telling me that these functions should be void. Originally they weren't. Regards, -Markus