summaryrefslogtreecommitdiff
path: root/lib/shell.c
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2018-01-05 01:58:08 +0100
committerRichard Braun <rbraun@sceen.net>2018-01-05 01:58:26 +0100
commit62d27d872769ebcd79a931fa07b1128576e65e65 (patch)
tree0a99e87809c9055dcdcfbd9ed4bec1a72534ced9 /lib/shell.c
parenta6c056ce150bd0339d5325edc18717b2d02a5b8d (diff)
error: remove and use standard errno codes instead
This change also adds strerror to string.h.
Diffstat (limited to 'lib/shell.c')
-rw-r--r--lib/shell.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/shell.c b/lib/shell.c
index 8272b24..3fada36 100644
--- a/lib/shell.c
+++ b/lib/shell.c
@@ -23,6 +23,7 @@
* http://git.sceen.net/rbraun/librbraun.git/
*/
+#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <stdint.h>
@@ -32,7 +33,6 @@
#include <lib/hash.h>
#include <lib/shell.h>
-#include <src/error.h>
#include <src/mutex.h>
#include <src/panic.h>
#include <src/thread.h>
@@ -271,8 +271,8 @@ shell_cmd_match(const struct shell_cmd *cmd, const char *str,
* eligible for completion.
*
* If there is a single match for the given string, return 0. If there
- * are more than one match, return ERROR_AGAIN. If there is no match,
- * return ERROR_INVAL.
+ * are more than one match, return EAGAIN. If there is no match,
+ * return EINVAL.
*
* The global lock must be acquired before calling this function.
*/
@@ -292,7 +292,7 @@ shell_cmd_complete(const char *str, unsigned long *sizep,
cmd = shell_cmd_match(shell_list, str, size);
if (cmd == NULL) {
- return ERROR_INVAL;
+ return EINVAL;
}
*cmdp = cmd;
@@ -337,7 +337,7 @@ shell_cmd_complete(const char *str, unsigned long *sizep,
size--;
*sizep = size;
- return ERROR_AGAIN;
+ return EAGAIN;
}
/*
@@ -383,7 +383,7 @@ shell_cmd_check_char(char c)
return 0;
}
- return ERROR_INVAL;
+ return EINVAL;
}
static int
@@ -401,7 +401,7 @@ shell_cmd_check(const struct shell_cmd *cmd)
}
if (i == 0) {
- return ERROR_INVAL;
+ return EINVAL;
}
return 0;
@@ -459,7 +459,7 @@ shell_cmd_add(struct shell_cmd *cmd)
for (;;) {
if (strcmp(cmd->name, tmp->name) == 0) {
printf("shell: error: %s: shell command name collision", cmd->name);
- return ERROR_EXIST;
+ return EEXIST;
}
if (tmp->ht_next == NULL) {
@@ -532,11 +532,11 @@ shell_line_insert(struct shell_line *line, unsigned long index, char c)
unsigned long remaining_chars;
if (index > line->size) {
- return ERROR_INVAL;
+ return EINVAL;
}
if ((line->size + 1) == sizeof(line->str)) {
- return ERROR_NOMEM;
+ return ENOMEM;
}
remaining_chars = line->size - index;
@@ -557,7 +557,7 @@ shell_line_erase(struct shell_line *line, unsigned long index)
unsigned long remaining_chars;
if (index >= line->size) {
- return ERROR_INVAL;
+ return EINVAL;
}
remaining_chars = line->size - index - 1;
@@ -777,7 +777,7 @@ static int
shell_process_right(void)
{
if (shell_cursor >= shell_line_size(shell_history_get_newest())) {
- return ERROR_AGAIN;
+ return EAGAIN;
}
shell_cursor++;
@@ -880,12 +880,12 @@ shell_process_tabulation(void)
error = shell_cmd_complete(word, &size, &cmd);
- if (error && (error != ERROR_AGAIN)) {
+ if (error && (error != EAGAIN)) {
error = 0;
goto out;
}
- if (error == ERROR_AGAIN) {
+ if (error == EAGAIN) {
unsigned long cursor;
cursor = shell_cursor;
@@ -1069,7 +1069,7 @@ shell_process_args(void)
if (j == ARRAY_SIZE(shell_argv)) {
printf("shell: too many arguments\n");
- return ERROR_INVAL;
+ return EINVAL;
}
shell_argv[j] = NULL;
@@ -1132,7 +1132,7 @@ shell_process_ctrl_char(char c)
case '\r':
putchar('\n');
shell_process_line();
- return ERROR_AGAIN;
+ return EAGAIN;
default:
return 0;
}