diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2011-10-10 00:03:37 +0200 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2011-10-26 13:10:39 +1030 |
commit | b1e4d20cbf2ef8e27515da032b95fdcbb5b06bf1 (patch) | |
tree | f080e839635fa36f55d22d147baa12ae64d4c181 /kernel/params.c | |
parent | 37252db6aa576c34fd794a5a54fb32d7a8b3a07a (diff) | |
download | lwn-b1e4d20cbf2ef8e27515da032b95fdcbb5b06bf1.tar.gz lwn-b1e4d20cbf2ef8e27515da032b95fdcbb5b06bf1.zip |
params: make dashes and underscores in parameter names truly equal
The user may use "foo-bar" for a kernel parameter defined as "foo_bar".
Make sure it works the other way around too.
Apply the equality of dashes and underscores on early_params and __setup
params as well.
The example given in Documentation/kernel-parameters.txt indicates that
this is the intended behaviour.
With the patch the kernel accepts "log-buf-len=1M" as expected.
https://bugzilla.redhat.com/show_bug.cgi?id=744545
Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (neatened implementations)
Diffstat (limited to 'kernel/params.c')
-rw-r--r-- | kernel/params.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/kernel/params.c b/kernel/params.c index 22df3e0d142a..821788947e40 100644 --- a/kernel/params.c +++ b/kernel/params.c @@ -67,20 +67,27 @@ static void maybe_kfree_parameter(void *param) } } -static inline char dash2underscore(char c) +static char dash2underscore(char c) { if (c == '-') return '_'; return c; } -static inline int parameq(const char *input, const char *paramname) +bool parameqn(const char *a, const char *b, size_t n) { - unsigned int i; - for (i = 0; dash2underscore(input[i]) == paramname[i]; i++) - if (input[i] == '\0') - return 1; - return 0; + size_t i; + + for (i = 0; i < n; i++) { + if (dash2underscore(a[i]) != dash2underscore(b[i])) + return false; + } + return true; +} + +bool parameq(const char *a, const char *b) +{ + return parameqn(a, b, strlen(a)+1); } static int parse_one(char *param, |