diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-11-06 16:10:42 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-11-06 16:10:42 +0100 |
commit | 1d9295b344a885e5a79de38df28740a1db6f6103 (patch) | |
tree | ca427bbf13a04f3480fb398630473bede4ef6463 /common | |
parent | 736a74ba7a1c3983105b92a709c263e206fe3913 (diff) | |
parent | 6face0e8ab8d97dcc7284a8a5d7ae1f4d134798f (diff) | |
download | barebox-1d9295b344a885e5a79de38df28740a1db6f6103.tar.gz barebox-1d9295b344a885e5a79de38df28740a1db6f6103.tar.xz |
Merge branch 'for-next/misc'
Diffstat (limited to 'common')
-rw-r--r-- | common/command.c | 2 | ||||
-rw-r--r-- | common/filetype.c | 4 | ||||
-rw-r--r-- | common/parser.c | 18 |
3 files changed, 13 insertions, 11 deletions
diff --git a/common/command.c b/common/command.c index dc2cb88eaf..03c70834d1 100644 --- a/common/command.c +++ b/common/command.c @@ -83,7 +83,7 @@ int execute_command(int argc, char **argv) #else printf ("Unknown command '%s'\n", argv[0]); #endif - ret = 1; /* give up after bad command */ + ret = COMMAND_ERROR; /* give up after bad command */ } getopt_context_restore(&gc); diff --git a/common/filetype.c b/common/filetype.c index dc2ff3f5f0..9ec8ebf7c2 100644 --- a/common/filetype.c +++ b/common/filetype.c @@ -369,9 +369,10 @@ enum filetype cdev_detect_type(const char *name) struct cdev *cdev; void *buf; - cdev = cdev_by_name(name); + cdev = cdev_open(name, O_RDONLY); if (!cdev) return type; + buf = xzalloc(FILE_TYPE_SAFE_BUFSIZE); ret = cdev_read(cdev, buf, FILE_TYPE_SAFE_BUFSIZE, 0, 0); if (ret < 0) @@ -396,5 +397,6 @@ enum filetype cdev_detect_type(const char *name) err_out: free(buf); + cdev_close(cdev); return type; } diff --git a/common/parser.c b/common/parser.c index ed414d04ea..6136dbf36f 100644 --- a/common/parser.c +++ b/common/parser.c @@ -253,7 +253,8 @@ int run_command(const char *cmd) continue; } - rc = execute_command(argc, argv); + if (execute_command(argc, argv) != COMMAND_SUCCESS) + rc = -1; } return rc; @@ -265,7 +266,6 @@ int run_shell(void) { static char lastcommand[CONFIG_CBSIZE] = { 0, }; int len; - int rc = 1; login(); @@ -275,14 +275,14 @@ int run_shell(void) if (len > 0) strcpy (lastcommand, console_buffer); - if (len == -1) + if (len == -1) { puts ("<INTERRUPT>\n"); - else - rc = run_command(lastcommand); - - if (rc <= 0) { - /* invalid command or not repeatable, forget it */ - lastcommand[0] = 0; + } else { + const int rc = run_command(lastcommand); + if (rc < 0) { + /* invalid command or not repeatable, forget it */ + lastcommand[0] = 0; + } } } return 0; |