aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/params.c
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2011-10-09 18:03:37 -0400
committerRusty Russell <rusty@rustcorp.com.au>2011-10-25 22:40:39 -0400
commitb1e4d20cbf2ef8e27515da032b95fdcbb5b06bf1 (patch)
treef080e839635fa36f55d22d147baa12ae64d4c181 /kernel/params.c
parent37252db6aa576c34fd794a5a54fb32d7a8b3a07a (diff)
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.c21
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)
67 } 67 }
68} 68}
69 69
70static inline char dash2underscore(char c) 70static char dash2underscore(char c)
71{ 71{
72 if (c == '-') 72 if (c == '-')
73 return '_'; 73 return '_';
74 return c; 74 return c;
75} 75}
76 76
77static inline int parameq(const char *input, const char *paramname) 77bool parameqn(const char *a, const char *b, size_t n)
78{ 78{
79 unsigned int i; 79 size_t i;
80 for (i = 0; dash2underscore(input[i]) == paramname[i]; i++) 80
81 if (input[i] == '\0') 81 for (i = 0; i < n; i++) {
82 return 1; 82 if (dash2underscore(a[i]) != dash2underscore(b[i]))
83 return 0; 83 return false;
84 }
85 return true;
86}
87
88bool parameq(const char *a, const char *b)
89{
90 return parameqn(a, b, strlen(a)+1);
84} 91}
85 92
86static int parse_one(char *param, 93static int parse_one(char *param,