diff options
-rw-r--r-- | cbuf.c | 12 | ||||
-rw-r--r-- | cbuf.h | 12 | ||||
-rw-r--r-- | error.c | 16 | ||||
-rw-r--r-- | error.h | 34 | ||||
-rw-r--r-- | fmt.c | 20 | ||||
-rw-r--r-- | rdxtree.c | 20 | ||||
-rw-r--r-- | shell.c | 30 | ||||
-rw-r--r-- | test/test_cbuf.c | 2 | ||||
-rw-r--r-- | test/test_rdxtree.c | 12 |
9 files changed, 79 insertions, 79 deletions
@@ -73,7 +73,7 @@ cbuf_push(struct cbuf *cbuf, const void *buf, size_t size, bool erase) free_size = cbuf_capacity(cbuf) - cbuf_size(cbuf); if (size > free_size) { - return ERR_AGAIN; + return ERROR_AGAIN; } } @@ -86,7 +86,7 @@ cbuf_pop(struct cbuf *cbuf, void *buf, size_t *sizep) int error; if (cbuf_size(cbuf) == 0) { - return ERR_AGAIN; + return ERROR_AGAIN; } error = cbuf_read(cbuf, cbuf_start(cbuf), buf, sizep); @@ -104,7 +104,7 @@ cbuf_pushb(struct cbuf *cbuf, uint8_t byte, bool erase) free_size = cbuf_capacity(cbuf) - cbuf_size(cbuf); if (free_size == 0) { - return ERR_AGAIN; + return ERROR_AGAIN; } } @@ -118,7 +118,7 @@ int cbuf_popb(struct cbuf *cbuf, uint8_t *bytep) { if (cbuf_size(cbuf) == 0) { - return ERR_AGAIN; + return ERROR_AGAIN; } *bytep = cbuf->buf[cbuf_index(cbuf, cbuf->start)]; @@ -133,7 +133,7 @@ cbuf_write(struct cbuf *cbuf, size_t index, const void *buf, size_t size) size_t new_end, skip; if (!cbuf_range_valid(cbuf, index, cbuf->end)) { - return ERR_INVAL; + return ERROR_INVAL; } new_end = index + size; @@ -174,7 +174,7 @@ cbuf_read(const struct cbuf *cbuf, size_t index, void *buf, size_t *sizep) /* At least one byte must be available */ if (!cbuf_range_valid(cbuf, index, index + 1)) { - return ERR_INVAL; + return ERROR_INVAL; } size = cbuf->end - index; @@ -98,7 +98,7 @@ void cbuf_init(struct cbuf *cbuf, void *buf, size_t capacity); * Push data to a circular buffer. * * If the function isn't allowed to erase old data and the circular buffer - * doesn't have enough unused bytes for the new data, ERR_AGAIN is returned. + * doesn't have enough unused bytes for the new data, ERROR_AGAIN is returned. */ int cbuf_push(struct cbuf *cbuf, const void *buf, size_t size, bool erase); @@ -108,7 +108,7 @@ int cbuf_push(struct cbuf *cbuf, const void *buf, size_t size, bool erase); * On entry, the sizep argument points to the size of the output buffer. * On exit, it is updated to the number of bytes actually transferred. * - * If the buffer is empty, ERR_AGAIN is returned, and the size of the + * If the buffer is empty, ERROR_AGAIN is returned, and the size of the * output buffer is undefined. */ int cbuf_pop(struct cbuf *cbuf, void *buf, size_t *sizep); @@ -117,21 +117,21 @@ int cbuf_pop(struct cbuf *cbuf, void *buf, size_t *sizep); * Push a byte to a circular buffer. * * If the function isn't allowed to erase old data and the circular buffer - * is full, ERR_AGAIN is returned. + * is full, ERROR_AGAIN is returned. */ int cbuf_pushb(struct cbuf *cbuf, uint8_t byte, bool erase); /* * Pop a byte from a circular buffer. * - * If the buffer is empty, ERR_AGAIN is returned. + * If the buffer is empty, ERROR_AGAIN is returned. */ int cbuf_popb(struct cbuf *cbuf, uint8_t *bytep); /* * Write into a circular buffer at a specific location. * - * If the given index is outside buffer boundaries, ERR_INVAL is returned. + * If the given index is outside buffer boundaries, ERROR_INVAL is returned. * The given [index, size) range may extend beyond the end of the circular * buffer. */ @@ -143,7 +143,7 @@ int cbuf_write(struct cbuf *cbuf, size_t index, const void *buf, size_t size); * On entry, the sizep argument points to the size of the output buffer. * On exit, it is updated to the number of bytes actually transferred. * - * If the given index is outside buffer boundaries, ERR_INVAL is returned. + * If the given index is outside buffer boundaries, ERROR_INVAL is returned. * * The circular buffer isn't changed by this operation. */ @@ -74,22 +74,22 @@ error_from_errno(int errno_code) { switch (errno_code) { case 0: - return ERR_SUCCESS; + return ERROR_SUCCESS; case EINVAL: - return ERR_INVAL; + return ERROR_INVAL; case ENOMEM: - return ERR_NOMEM; + return ERROR_NOMEM; case EAGAIN: - return ERR_NORES; + return ERROR_NORES; case EPERM: - return ERR_PERM; + return ERROR_PERM; case EBUSY: - return ERR_BUSY; + return ERROR_BUSY; case ETIMEDOUT: - return ERR_TIMEDOUT; + return ERROR_TIMEDOUT; default: fprintf(stderr, "unable to translate errno code (%d)\n", errno_code); - return ERR_UNKNOWN; + return ERROR_UNKNOWN; } } @@ -37,7 +37,7 @@ /* * List of errors this library can return. * - * ERR_SUCCESS is guaranteed to be 0, allowing code such as : + * ERROR_SUCCESS is guaranteed to be 0, allowing code such as : * * error = do_smth(); * @@ -46,21 +46,21 @@ * } */ enum { - ERR_SUCCESS, - ERR_UNKNOWN, - ERR_INVAL, - ERR_NOMEM, - ERR_FORMAT, - ERR_NORES, - ERR_PERM, - ERR_BUSY, - ERR_MEMLIM, - ERR_TIMEDOUT, - ERR_WOULDBLOCK, - ERR_LOOKUP, - ERR_MEM_CACHE, - ERR_AGAIN, - ERR_EXIST, + ERROR_SUCCESS, + ERROR_UNKNOWN, + ERROR_INVAL, + ERROR_NOMEM, + ERROR_FORMAT, + ERROR_NORES, + ERROR_PERM, + ERROR_BUSY, + ERROR_MEMLIM, + ERROR_TIMEDOUT, + ERROR_WOULDBLOCK, + ERROR_LOOKUP, + ERROR_MEM_CACHE, + ERROR_AGAIN, + ERROR_EXIST, }; /* @@ -77,7 +77,7 @@ const char * error_str(unsigned int error); * * This function accepts a subset of the standard error codes in errno.h. * When called, and if the errno value is handled, it will return the - * corresponding ERR_xxx code. Otherwise ERR_UNKNOWN is returned. + * corresponding ERROR_xxx code. Otherwise ERROR_UNKNOWN is returned. */ unsigned int error_from_errno(int errno_code); @@ -408,12 +408,12 @@ fmt_sprintf_state_consume(struct fmt_sprintf_state *state) c = fmt_consume(&state->format); if (c == '\0') { - return ERR_NORES; + return ERROR_NORES; } if (c != '%') { fmt_sprintf_state_produce_raw_char(state, c); - return ERR_AGAIN; + return ERROR_AGAIN; } fmt_sprintf_state_consume_flags(state); @@ -792,7 +792,7 @@ fmt_vsnprintf(char *str, size_t size, const char *format, va_list ap) for (;;) { error = fmt_sprintf_state_consume(&state); - if (error == ERR_AGAIN) { + if (error == ERROR_AGAIN) { continue; } else if (error) { break; @@ -1073,7 +1073,7 @@ fmt_sscanf_state_discard_char(struct fmt_sscanf_state *state, char c) state->nr_convs = EOF; } - return ERR_FORMAT; + return ERROR_FORMAT; } return 0; @@ -1090,7 +1090,7 @@ fmt_sscanf_state_consume(struct fmt_sscanf_state *state) c = fmt_consume(&state->format); if (c == '\0') { - return ERR_NORES; + return ERROR_NORES; } if (c != '%') { @@ -1100,7 +1100,7 @@ fmt_sscanf_state_consume(struct fmt_sscanf_state *state) return error; } - return ERR_AGAIN; + return ERROR_AGAIN; } fmt_sscanf_state_consume_flags(state); @@ -1192,7 +1192,7 @@ fmt_sscanf_state_produce_int(struct fmt_sscanf_state *state) if (i == 0) { if (c == '\0') { fmt_sscanf_state_report_error(state); - return ERR_FORMAT; + return ERROR_FORMAT; } buf[0] = '0'; @@ -1386,7 +1386,7 @@ fmt_sscanf_state_produce_str(struct fmt_sscanf_state *state) if (state->str == orig) { fmt_sscanf_state_report_error(state); - return ERR_FORMAT; + return ERROR_FORMAT; } if (dest != NULL) { @@ -1421,7 +1421,7 @@ fmt_sscanf_state_produce(struct fmt_sscanf_state *state) return fmt_sscanf_state_discard_char(state, '%'); default: fmt_sscanf_state_report_error(state); - return ERR_FORMAT; + return ERROR_FORMAT; } } @@ -1449,7 +1449,7 @@ fmt_vsscanf(const char *str, const char *format, va_list ap) for (;;) { error = fmt_sscanf_state_consume(&state); - if (error == ERR_AGAIN) { + if (error == ERROR_AGAIN) { continue; } else if (error) { break; @@ -146,7 +146,7 @@ rdxtree_node_create(struct rdxtree_node **nodep, unsigned short height) rdxtree_nr_node_creations++; if (rdxtree_nr_node_creations == rdxtree_fail_node_creation_threshold) { - return ERR_NOMEM; + return ERROR_NOMEM; } } #endif /* RDXTREE_ENABLE_NODE_CREATION_FAILURES */ @@ -154,7 +154,7 @@ rdxtree_node_create(struct rdxtree_node **nodep, unsigned short height) node = malloc(sizeof(*node)); if (node == NULL) { - return ERR_NOMEM; + return ERROR_NOMEM; } rdxtree_assert_alignment(node); @@ -352,7 +352,7 @@ rdxtree_grow(struct rdxtree *tree, rdxtree_key_t key) if (tree->root == NULL) { tree->height = new_height; - return ERR_SUCCESS; + return ERROR_SUCCESS; } root = rdxtree_entry_addr(tree->root); @@ -384,7 +384,7 @@ rdxtree_grow(struct rdxtree *tree, rdxtree_key_t key) root = node; } while (new_height > tree->height); - return ERR_SUCCESS; + return ERROR_SUCCESS; } static void @@ -455,7 +455,7 @@ rdxtree_insert_common(struct rdxtree *tree, rdxtree_key_t key, if (unlikely(height == 0)) { if (tree->root != NULL) { - return ERR_BUSY; + return ERROR_BUSY; } llsync_assign_ptr(tree->root, ptr); @@ -464,7 +464,7 @@ rdxtree_insert_common(struct rdxtree *tree, rdxtree_key_t key, *slotp = &tree->root; } - return ERR_SUCCESS; + return ERROR_SUCCESS; } node = rdxtree_entry_addr(tree->root); @@ -501,7 +501,7 @@ rdxtree_insert_common(struct rdxtree *tree, rdxtree_key_t key, } while (height > 0); if (unlikely(node != NULL)) { - return ERR_BUSY; + return ERROR_BUSY; } rdxtree_node_insert(prev, index, ptr); @@ -514,7 +514,7 @@ rdxtree_insert_common(struct rdxtree *tree, rdxtree_key_t key, *slotp = &prev->entries[index]; } - return ERR_SUCCESS; + return ERROR_SUCCESS; } int @@ -542,7 +542,7 @@ rdxtree_insert_alloc_common(struct rdxtree *tree, void *ptr, *slotp = &tree->root; } - return ERR_SUCCESS; + return ERROR_SUCCESS; } goto grow; @@ -598,7 +598,7 @@ grow: out: *keyp = key; - return ERR_SUCCESS; + return ERROR_SUCCESS; } static void @@ -267,8 +267,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 ERR_AGAIN. If there is no match, - * return ERR_INVAL. + * are more than one match, return ERROR_AGAIN. If there is no match, + * return ERROR_INVAL. * * The global lock must be acquired before calling this function. */ @@ -288,7 +288,7 @@ shell_cmd_complete(const char *str, unsigned long *sizep, cmd = shell_cmd_match(shell_list, str, size); if (cmd == NULL) { - return ERR_INVAL; + return ERROR_INVAL; } *cmdp = cmd; @@ -333,7 +333,7 @@ shell_cmd_complete(const char *str, unsigned long *sizep, size--; *sizep = size; - return ERR_AGAIN; + return ERROR_AGAIN; } /* @@ -379,7 +379,7 @@ shell_cmd_check_char(char c) return 0; } - return ERR_INVAL; + return ERROR_INVAL; } static int @@ -397,7 +397,7 @@ shell_cmd_check(const struct shell_cmd *cmd) } if (i == 0) { - return ERR_INVAL; + return ERROR_INVAL; } return 0; @@ -456,7 +456,7 @@ shell_cmd_add(struct shell_cmd *cmd) if (strcmp(cmd->name, tmp->name) == 0) { fprintf(stderr, "shell: %s: shell command name collision", cmd->name); - return ERR_EXIST; + return ERROR_EXIST; } if (tmp->ht_next == NULL) { @@ -529,11 +529,11 @@ shell_line_insert(struct shell_line *line, unsigned long index, char c) unsigned long remaining_chars; if (index > line->size) { - return ERR_INVAL; + return ERROR_INVAL; } if ((line->size + 1) == sizeof(line->str)) { - return ERR_NOMEM; + return ERROR_NOMEM; } remaining_chars = line->size - index; @@ -554,7 +554,7 @@ shell_line_erase(struct shell_line *line, unsigned long index) unsigned long remaining_chars; if (index >= line->size) { - return ERR_INVAL; + return ERROR_INVAL; } remaining_chars = line->size - index - 1; @@ -774,7 +774,7 @@ static int shell_process_right(void) { if (shell_cursor >= shell_line_size(shell_history_get_newest())) { - return ERR_AGAIN; + return ERROR_AGAIN; } shell_cursor++; @@ -877,12 +877,12 @@ shell_process_tabulation(void) error = shell_cmd_complete(word, &size, &cmd); - if (error && (error != ERR_AGAIN)) { + if (error && (error != ERROR_AGAIN)) { error = 0; goto out; } - if (error == ERR_AGAIN) { + if (error == ERROR_AGAIN) { unsigned long cursor; cursor = shell_cursor; @@ -1066,7 +1066,7 @@ shell_process_args(void) if (j == ARRAY_SIZE(shell_argv)) { printf("shell: too many arguments\n"); - return ERR_INVAL; + return ERROR_INVAL; } shell_argv[j] = NULL; @@ -1129,7 +1129,7 @@ shell_process_ctrl_char(char c) case '\r': putchar('\n'); shell_process_line(); - return ERR_AGAIN; + return ERROR_AGAIN; default: return 0; } diff --git a/test/test_cbuf.c b/test/test_cbuf.c index 15e4d62..b982319 100644 --- a/test/test_cbuf.c +++ b/test/test_cbuf.c @@ -80,7 +80,7 @@ test_read_0(void) size = 0; error = cbuf_read(&cbuf, index, buf, &size); - check(error == ERR_INVAL); + check(error == ERROR_INVAL); check(size == 0); test_push(&cbuf, "a"); diff --git a/test/test_rdxtree.c b/test/test_rdxtree.c index b95d11f..57b1336 100644 --- a/test/test_rdxtree.c +++ b/test/test_rdxtree.c @@ -694,7 +694,7 @@ test_21(void) error = rdxtree_insert(&tree, 0, obj); check(!error); error = rdxtree_insert(&tree, 0, obj); - check(error == ERR_BUSY); + check(error == ERROR_BUSY); destroy_tree(&tree); } @@ -712,7 +712,7 @@ test_22(void) error = rdxtree_insert(&tree, 123, obj); check(!error); error = rdxtree_insert(&tree, 123, obj); - check(error == ERR_BUSY); + check(error == ERROR_BUSY); destroy_tree(&tree); } @@ -922,7 +922,7 @@ test_33(void) rdxtree_init(&tree, 0); obj = obj_create(1); error = rdxtree_insert(&tree, obj->id, obj); - check(error == ERR_NOMEM); + check(error == ERROR_NOMEM); obj_destroy(obj); print_tree(&tree); } @@ -942,7 +942,7 @@ test_34(void) rdxtree_init(&tree, 0); obj = obj_create(64); error = rdxtree_insert(&tree, obj->id, obj); - check(error == ERR_NOMEM); + check(error == ERROR_NOMEM); obj_destroy(obj); print_tree(&tree); } @@ -965,7 +965,7 @@ test_35(void) check(!error); obj = obj_create(64); error = rdxtree_insert(&tree, obj->id, obj); - check(error == ERR_NOMEM); + check(error == ERROR_NOMEM); obj_destroy(obj); print_tree(&tree); destroy_tree(&tree); @@ -989,7 +989,7 @@ test_36(void) check(!error); obj = obj_create(64); error = rdxtree_insert(&tree, obj->id, obj); - check(error == ERR_NOMEM); + check(error == ERROR_NOMEM); obj_destroy(obj); print_tree(&tree); destroy_tree(&tree); |