It is currently Mon, 26 Oct 2020 03:11:31 GMT



 
Author Message
 Don't turn - to _ when parsing params
.... since they might not be boot parameters afterall (and hence need
to get passed to init or the environment intact).

Thanks,
Rusty.
--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

Name: Avoid mangling - in parameters
Author: Rusty Russell
Status: Trivial (tested in userspace framework)

D: Mikael Pettersson points out that "-s" gets mangled to "_s" on the
D: kernel command line, even though it turns out not to be a
D: parameter.

diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.59/kernel/params.c working-2.5.59-underscore/kernel/params.c
--- linux-2.5.59/kernel/params.c        2003-01-02 14:48:01.000000000 +1100
+++ working-2.5.59-underscore/kernel/params.c   2003-01-21 18:16:05.000000000 +1100
@@ -27,6 +27,22 @@
 #define DEBUGP(fmt, a...)
 #endif

+static inline int dash2underscore(char c)
+{
+       if (c == '-')
+               return '_';
+       return c;
+}
+
+static inline int parameq(const char *input, const char *paramname)
+{
+       unsigned int i;
+       for (i = 0; dash2underscore(input[i]) == paramname[i]; i++)
+               if (input[i] == '\0')
+                       return 1;
+       return 0;
+}
+
 static int parse_one(char *param,
                     char *val,
                     struct kernel_param *params,
@@ -37,7 +53,7 @@ static int parse_one(char *param,

        /* Find parameter */
        for (i = 0; i < num_params; i++) {
-               if (strcmp(param, params[i].name) == 0) {
+               if (parameq(param, params[i].name)) {
                        DEBUGP("They are equal!  Calling %p\n",
                               params[i].set);
                        return params[i].set(val, &params[i]);
@@ -69,8 +85,6 @@ static char *next_arg(char *args, char *
                if (equals == 0) {
                        if (args[i] == '=')
                                equals = i;
-                       else if (args[i] == '-')
-                               args[i] = '_';
                }
                if (args[i] == '"')
                        in_quote = !in_quote;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at   http://www.**-**.com/
Please read the FAQ at   http://www.**-**.com/



 Sun, 17 Jul 2005 09:10:08 GMT   
 
   [ 1 post ] 

Similar Threads

1. Don't bother to post, was, Re: TEST:don't bother to read

2. Can't boot Linux w/o manually passing params to LILO

3. chat: can't get terminal params

4. Make `obsolete params' work correctly if MODULE_SYMBOL_PRE

5. parse error before 'ospeed' error

6. Parsing 'read' command

7. newbie: parsing 'cut -n' output

8. parsing a '#' character (stupid question)

9. php won't parse: (I've tried the usual suspects)

10. GCC 2.11 "Parse error before '('


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software