summaryrefslogtreecommitdiffstats
path: root/common/hush.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2012-02-14 19:59:25 +0000
committerWolfgang Denk <wd@denx.de>2012-03-06 21:09:41 +0100
commit9d12d5d41d5653ba2f943886f45b8c2eb0f63450 (patch)
tree03ea18e10cb7c8f06bf82525c8aacad91938ad93 /common/hush.c
parent7344f9128dfa797a9b9d51b38832f77a1eaeac2d (diff)
downloadblackbird-obmc-uboot-9d12d5d41d5653ba2f943886f45b8c2eb0f63450.tar.gz
blackbird-obmc-uboot-9d12d5d41d5653ba2f943886f45b8c2eb0f63450.zip
Add cmd_process() to process commands in one place
We currently have the same code in hush.c and main.c. This brings the code into one place. As an added feature, if the command function returns CMD_RET_USAGE then cmd_process() will print a usage message for the command before returning the standard failure code of 1. ARM code size increases about 32 bytes with this clean-up. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/hush.c')
-rw-r--r--common/hush.c52
1 files changed, 12 insertions, 40 deletions
diff --git a/common/hush.c b/common/hush.c
index 3aa9d50113..672ab9e157 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -1538,7 +1538,6 @@ static int run_pipe_real(struct pipe *pi)
int nextin;
int flag = do_repeat ? CMD_FLAG_REPEAT : 0;
struct child_prog *child;
- cmd_tbl_t *cmdtp;
char *p;
# if __GNUC__
/* Avoid longjmp clobbering */
@@ -1652,47 +1651,20 @@ static int run_pipe_real(struct pipe *pi)
return rcode;
}
#else
- /* check ";", because ,example , argv consist from
- * "help;flinfo" must not execute
- */
- if (strchr(child->argv[i], ';')) {
- printf ("Unknown command '%s' - try 'help' or use 'run' command\n",
- child->argv[i]);
- return -1;
- }
- /* Look up command in command table */
-
-
- if ((cmdtp = find_cmd(child->argv[i])) == NULL) {
- printf ("Unknown command '%s' - try 'help'\n", child->argv[i]);
- return -1; /* give up after bad command */
- } else {
- int rcode;
-#if defined(CONFIG_CMD_BOOTD)
- /* avoid "bootd" recursion */
- if (cmdtp->cmd == do_bootd) {
- if (flag & CMD_FLAG_BOOTD) {
- printf ("'bootd' recursion detected\n");
- return -1;
- }
- else
- flag |= CMD_FLAG_BOOTD;
- }
-#endif
- /* found - check max args */
- if ((child->argc - i) > cmdtp->maxargs)
- return cmd_usage(cmdtp);
-#endif
- /* OK - call function to do the command */
- rcode = cmd_call(cmdtp, flag, child->argc,
- child->argv);
- if (!cmdtp->repeatable)
- flag_repeat = 0;
- return rcode;
- }
+ /* check ";", because ,example , argv consist from
+ * "help;flinfo" must not execute
+ */
+ if (strchr(child->argv[i], ';')) {
+ printf("Unknown command '%s' - try 'help' or use "
+ "'run' command\n", child->argv[i]);
+ return -1;
}
-#ifndef __U_BOOT__
+ /* Process the command */
+ return cmd_process(flag, child->argc, child->argv,
+ &flag_repeat);
+#endif
}
+#ifndef __U_BOOT__
for (i = 0; i < pi->num_progs; i++) {
child = & (pi->progs[i]);
OpenPOWER on IntegriCloud