lkml.org 
[lkml]   [2016]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Use existing helper to convert "on/off" to boolean
On 04/29/16 at 10:04P, Michal Hocko wrote:
> On Fri 29-04-16 13:47:04, Minfei Huang wrote:
> > It's more convenient to use existing function helper to convert string
> > "on/off" to boolean.
>
> But kstrtobool in linux-next only does "This routine returns 0 iff the
> first character is one of 'Yy1Nn0'" so it doesn't know about on/off.
> Or am I missing anything?

Hi, Michal.

Thanks for your reply.

Following is the kstrtobool comment from linus tree, which has explained
that this function can parse "on"/"off" string. Also Kees Cook has
posted such patch to fix this issue as well. So I think it's safe to fix
it.

"
This routine returns 0 if the first character is one of 'Yy1Nn0', or
[oO][NnFf] for "on" and "off". Otherwise it will return -EINVAL. Value
pointed to by res is updated upon finding a match.
"

commit 4cc7ecb7f2a60e8deb783b8fbf7c1ae467acb920
Author: Kees Cook <keescook@chromium.org>
Date: Thu Mar 17 14:23:00 2016 -0700

param: convert some "on"/"off" users to strtobool

This changes several users of manual "on"/"off" parsing to use
strtobool.

Some side-effects:
- these uses will now parse y/n/1/0 meaningfully too
- the early_param uses will now bubble up parse errors

Thanks
Minfei

\
 
 \ /
  Last update: 2016-04-29 11:21    [W:0.106 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site