kdb: Use KDB_REPEAT_* values as flags
authorAnton Vorontsov <anton.vorontsov@linaro.org>
Thu, 6 Nov 2014 14:36:43 +0000 (14:36 +0000)
committerJason Wessel <jason.wessel@windriver.com>
Tue, 11 Nov 2014 15:31:51 +0000 (09:31 -0600)
The actual values of KDB_REPEAT_* enum values and overall logic stayed
the same, but we now treat the values as flags.

This makes it possible to add other flags and combine them, plus makes
the code a lot simpler and shorter. But functionality-wise, there should
be no changes.

Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
include/linux/kdb.h
kernel/debug/kdb/kdb_main.c

index 32d2f407981d65caa48a31b669cea7c0b47521a5..90aed7c31f0d730b4d3df4a4ab205c12fe6c002b 100644 (file)
@@ -15,8 +15,8 @@
 
 typedef enum {
        KDB_REPEAT_NONE = 0,    /* Do not repeat this command */
-       KDB_REPEAT_NO_ARGS,     /* Repeat the command without arguments */
-       KDB_REPEAT_WITH_ARGS,   /* Repeat the command including its arguments */
+       KDB_REPEAT_NO_ARGS      = 0x1, /* Repeat the command w/o arguments */
+       KDB_REPEAT_WITH_ARGS    = 0x2, /* Repeat the command w/ its arguments */
 } kdb_cmdflags_t;
 
 typedef int (*kdb_func_t)(int, const char **);
index 070f1ff358d26c7b56a4c7059ac1b347d056a16b..cbacae24a55a899a618468f1d2b3e84001347aed 100644 (file)
@@ -1008,20 +1008,13 @@ int kdb_parse(const char *cmdstr)
                if (result && ignore_errors && result > KDB_CMD_GO)
                        result = 0;
                KDB_STATE_CLEAR(CMD);
-               switch (tp->cmd_flags) {
-               case KDB_REPEAT_NONE:
-                       argc = 0;
-                       if (argv[0])
-                               *(argv[0]) = '\0';
-                       break;
-               case KDB_REPEAT_NO_ARGS:
-                       argc = 1;
-                       if (argv[1])
-                               *(argv[1]) = '\0';
-                       break;
-               case KDB_REPEAT_WITH_ARGS:
-                       break;
-               }
+
+               if (tp->cmd_flags & KDB_REPEAT_WITH_ARGS)
+                       return result;
+
+               argc = tp->cmd_flags & KDB_REPEAT_NO_ARGS ? 1 : 0;
+               if (argv[argc])
+                       *(argv[argc]) = '\0';
                return result;
        }