From: Jani Nikula <jani.nikula@linux.intel.com>
To: Markus Mayer <markus.mayer@broadcom.com>
Cc: devel@driverdev.osuosl.org, Kees Cook <keescook@chromium.org>,
linux-scsi@vger.kernel.org, linux-acpi@vger.kernel.org,
nouveau@lists.freedesktop.org,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Linux Kernel <linux-kernel@vger.kernel.org>,
dri-devel@lists.freedesktop.org, speakup@linux-speakup.org,
Chris Metcalf <cmetcalf@ezchip.com>,
target-devel@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
devel@acpica.org
Subject: Re: [PATCH 1/6] lib: string: add function strtolower()
Date: Fri, 01 Jul 2016 20:33:18 +0300 [thread overview]
Message-ID: <87vb0pqn4x.fsf@intel.com> (raw)
In-Reply-To: <CAGt4E5teRyMJMfxz3s6PHmTgCApBWWdAiNu1VwQtdJybST3RTw@mail.gmail.com>
On Fri, 01 Jul 2016, Markus Mayer <markus.mayer@broadcom.com> wrote:
> On 1 July 2016 at 03:52, Jani Nikula <jani.nikula@linux.intel.com> wrote:
>> On Fri, 01 Jul 2016, Markus Mayer <mmayer@broadcom.com> wrote:
>>> Add a function called strtolower() to convert strings to lower case
>>> in-place, overwriting the original string.
>>>
>>> This seems to be a recurring requirement in the kernel that is
>>> currently being solved by several duplicated implementations doing the
>>> same thing.
>>>
>>> Signed-off-by: Markus Mayer <mmayer@broadcom.com>
>>> ---
>>> include/linux/string.h | 1 +
>>> lib/string.c | 14 ++++++++++++++
>>> 2 files changed, 15 insertions(+)
>>>
>>> diff --git a/include/linux/string.h b/include/linux/string.h
>>> index 26b6f6a..aad605e 100644
>>> --- a/include/linux/string.h
>>> +++ b/include/linux/string.h
>>> @@ -116,6 +116,7 @@ extern void * memchr(const void *,int,__kernel_size_t);
>>> #endif
>>> void *memchr_inv(const void *s, int c, size_t n);
>>> char *strreplace(char *s, char old, char new);
>>> +char *strtolower(char *s);
>>>
>>> extern void kfree_const(const void *x);
>>>
>>> diff --git a/lib/string.c b/lib/string.c
>>> index ed83562..6e3b560 100644
>>> --- a/lib/string.c
>>> +++ b/lib/string.c
>>> @@ -952,3 +952,17 @@ char *strreplace(char *s, char old, char new)
>>> return s;
>>> }
>>> EXPORT_SYMBOL(strreplace);
>>> +
>>
>> This needs a kernel-doc comment right here.
>
> Will add it.
>
>>> +char *strtolower(char *s)
>>> +{
>>> + char *p;
>>> +
>>> + if (unlikely(!s))
>>> + return NULL;
>>
>> Using spaces for indentation? See scripts/checkpatch.pl.
>
> Not on purpose. Thanks for spotting it.
>
>>> +
>>> + for (p = s; *p; p++)
>>> + *p = tolower(*p);
>>> +
>>> + return s;
>>
>> Why does it return a value? Could be void?
>
> It could be void, but I thought that would make the function's use
> less flexible. As is, the return value is there if anybody wants it,
> but it can be ignored if it is not needed. Also, it seems customary
> for string functions to be returning the string that was passed in.
>
> I'll change it to void if there are strong opinions leaning that way.
> Personally, I like that it returns a char * better.
I don't have strong opinions on this. Just a general aversion to
returning something redundant. Avoids questions like, does it allocate a
new string, should I use the return value instead of the string I passed
in, should I check the return value or can I ignore it, should I check
both the string I pass in and the return value for != NULL, etc. But I
could be persuaded either way.
BR,
Jani.
>
>> BR,
>> Jani.
>>
>>> +}
>>> +EXPORT_SYMBOL(strtolower);
>>
>> --
>> Jani Nikula, Intel Open Source Technology Center
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
WARNING: multiple messages have this Message-ID (diff)
From: Jani Nikula <jani.nikula@linux.intel.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>,
devel@driverdev.osuosl.org, linux-scsi@vger.kernel.org,
nouveau@lists.freedesktop.org, speakup@linux-speakup.org,
Linux Kernel <linux-kernel@vger.kernel.org>,
dri-devel@lists.freedesktop.org, linux-acpi@vger.kernel.org,
target-devel@vger.kernel.org, devel@acpica.org
Subject: Re: [PATCH 1/6] lib: string: add function strtolower()
Date: Fri, 01 Jul 2016 20:33:18 +0300 [thread overview]
Message-ID: <87vb0pqn4x.fsf@intel.com> (raw)
In-Reply-To: <CAGt4E5teRyMJMfxz3s6PHmTgCApBWWdAiNu1VwQtdJybST3RTw@mail.gmail.com>
On Fri, 01 Jul 2016, Markus Mayer <markus.mayer@broadcom.com> wrote:
> On 1 July 2016 at 03:52, Jani Nikula <jani.nikula@linux.intel.com> wrote:
>> On Fri, 01 Jul 2016, Markus Mayer <mmayer@broadcom.com> wrote:
>>> Add a function called strtolower() to convert strings to lower case
>>> in-place, overwriting the original string.
>>>
>>> This seems to be a recurring requirement in the kernel that is
>>> currently being solved by several duplicated implementations doing the
>>> same thing.
>>>
>>> Signed-off-by: Markus Mayer <mmayer@broadcom.com>
>>> ---
>>> include/linux/string.h | 1 +
>>> lib/string.c | 14 ++++++++++++++
>>> 2 files changed, 15 insertions(+)
>>>
>>> diff --git a/include/linux/string.h b/include/linux/string.h
>>> index 26b6f6a..aad605e 100644
>>> --- a/include/linux/string.h
>>> +++ b/include/linux/string.h
>>> @@ -116,6 +116,7 @@ extern void * memchr(const void *,int,__kernel_size_t);
>>> #endif
>>> void *memchr_inv(const void *s, int c, size_t n);
>>> char *strreplace(char *s, char old, char new);
>>> +char *strtolower(char *s);
>>>
>>> extern void kfree_const(const void *x);
>>>
>>> diff --git a/lib/string.c b/lib/string.c
>>> index ed83562..6e3b560 100644
>>> --- a/lib/string.c
>>> +++ b/lib/string.c
>>> @@ -952,3 +952,17 @@ char *strreplace(char *s, char old, char new)
>>> return s;
>>> }
>>> EXPORT_SYMBOL(strreplace);
>>> +
>>
>> This needs a kernel-doc comment right here.
>
> Will add it.
>
>>> +char *strtolower(char *s)
>>> +{
>>> + char *p;
>>> +
>>> + if (unlikely(!s))
>>> + return NULL;
>>
>> Using spaces for indentation? See scripts/checkpatch.pl.
>
> Not on purpose. Thanks for spotting it.
>
>>> +
>>> + for (p = s; *p; p++)
>>> + *p = tolower(*p);
>>> +
>>> + return s;
>>
>> Why does it return a value? Could be void?
>
> It could be void, but I thought that would make the function's use
> less flexible. As is, the return value is there if anybody wants it,
> but it can be ignored if it is not needed. Also, it seems customary
> for string functions to be returning the string that was passed in.
>
> I'll change it to void if there are strong opinions leaning that way.
> Personally, I like that it returns a char * better.
I don't have strong opinions on this. Just a general aversion to
returning something redundant. Avoids questions like, does it allocate a
new string, should I use the return value instead of the string I passed
in, should I check the return value or can I ignore it, should I check
both the string I pass in and the return value for != NULL, etc. But I
could be persuaded either way.
BR,
Jani.
>
>> BR,
>> Jani.
>>
>>> +}
>>> +EXPORT_SYMBOL(strtolower);
>>
>> --
>> Jani Nikula, Intel Open Source Technology Center
--
Jani Nikula, Intel Open Source Technology Center
next prev parent reply other threads:[~2016-07-01 17:33 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-30 23:50 [PATCH 0/6] lib: string: add function strtolower() Markus Mayer
2016-06-30 23:50 ` [PATCH 1/6] " Markus Mayer
2016-07-01 10:52 ` Jani Nikula
2016-07-01 10:52 ` Jani Nikula
2016-07-01 17:14 ` Markus Mayer
2016-07-01 17:33 ` Jani Nikula [this message]
2016-07-01 17:33 ` Jani Nikula
2016-07-01 21:08 ` Rasmus Villemoes
2016-07-04 20:18 ` Markus Mayer
[not found] ` <1467330612-26242-2-git-send-email-mmayer-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2016-07-03 8:22 ` Michel Hermier
2016-06-30 23:50 ` [PATCH 2/6] drm/nouveau/core: make use of new strtolower() function Markus Mayer
2016-07-02 1:18 ` [Nouveau] " Alexandre Courbot
2016-07-02 1:18 ` Alexandre Courbot
2016-07-02 15:21 ` Markus Mayer
[not found] ` <CAGt4E5uusNK3vtBo5N9FyUTuWCpMtQS1KC1mHVCq5iFzFJpJFg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-04 1:37 ` Alexandre Courbot
2016-07-04 1:37 ` [Nouveau] " Alexandre Courbot
2016-07-04 3:39 ` Alexandre Courbot
2016-07-04 3:39 ` Alexandre Courbot
2016-06-30 23:50 ` [PATCH 3/6] ACPICA: " Markus Mayer
2016-07-01 1:11 ` [Devel] " Moore, Robert
2016-07-01 1:11 ` Moore, Robert
[not found] ` <CAGt4E5uqbjaubPWE4rq-T7MvqAmwpUhvakM+jv+Sen8est9U5g@mail.gmail.com>
2016-07-01 2:59 ` [Devel] " Moore, Robert
2016-07-01 4:13 ` Markus Mayer
2016-06-30 23:50 ` [PATCH 4/6] ACPI / device_sysfs: " Markus Mayer
2016-07-01 20:44 ` Rafael J. Wysocki
2016-06-30 23:50 ` [PATCH 5/6] staging: speakup: replace spk_strlwr() with strtolower() Markus Mayer
2016-06-30 23:53 ` Samuel Thibault
2016-06-30 23:50 ` [PATCH 6/6] iscsi-target: replace iscsi_initiatorname_tolower() " Markus Mayer
-- strict thread matches above, loose matches on Subject: below --
2016-07-01 4:32 [Devel] [PATCH 3/6] ACPICA: make use of new strtolower() function Moore, Robert
2016-07-01 4:32 ` Moore, Robert
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=87vb0pqn4x.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=cmetcalf@ezchip.com \
--cc=devel@acpica.org \
--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-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.