提交 04bb171e 编写于 作者: A Anton Vorontsov 提交者: Jason Wessel

kdb: Use KDB_REPEAT_* values as flags

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: NAnton Vorontsov <anton.vorontsov@linaro.org>
Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
Signed-off-by: NDaniel Thompson <daniel.thompson@linaro.org>
Cc: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: NJason Wessel <jason.wessel@windriver.com>
上级 42c884c1
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
typedef enum { typedef enum {
KDB_REPEAT_NONE = 0, /* Do not repeat this command */ KDB_REPEAT_NONE = 0, /* Do not repeat this command */
KDB_REPEAT_NO_ARGS, /* Repeat the command without arguments */ KDB_REPEAT_NO_ARGS = 0x1, /* Repeat the command w/o arguments */
KDB_REPEAT_WITH_ARGS, /* Repeat the command including its arguments */ KDB_REPEAT_WITH_ARGS = 0x2, /* Repeat the command w/ its arguments */
} kdb_cmdflags_t; } kdb_cmdflags_t;
typedef int (*kdb_func_t)(int, const char **); typedef int (*kdb_func_t)(int, const char **);
......
...@@ -1008,20 +1008,13 @@ int kdb_parse(const char *cmdstr) ...@@ -1008,20 +1008,13 @@ int kdb_parse(const char *cmdstr)
if (result && ignore_errors && result > KDB_CMD_GO) if (result && ignore_errors && result > KDB_CMD_GO)
result = 0; result = 0;
KDB_STATE_CLEAR(CMD); KDB_STATE_CLEAR(CMD);
switch (tp->cmd_flags) {
case KDB_REPEAT_NONE: if (tp->cmd_flags & KDB_REPEAT_WITH_ARGS)
argc = 0; return result;
if (argv[0])
*(argv[0]) = '\0'; argc = tp->cmd_flags & KDB_REPEAT_NO_ARGS ? 1 : 0;
break; if (argv[argc])
case KDB_REPEAT_NO_ARGS: *(argv[argc]) = '\0';
argc = 1;
if (argv[1])
*(argv[1]) = '\0';
break;
case KDB_REPEAT_WITH_ARGS:
break;
}
return result; return result;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册