summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2018-01-04 21:43:37 +0100
committerRichard Braun <rbraun@sceen.net>2018-01-04 21:43:37 +0100
commite7321910ca4d956b572a050d302a25df37ce06ab (patch)
treea3428d4746741325218dd385f36f84b494058d91
parentfe5415c54b05853dbbe230fca0aea3623c3be1e2 (diff)
error: remove and use errno.h directly
-rw-r--r--Makefile.am2
-rw-r--r--cbuf.c14
-rw-r--r--cbuf.h12
-rw-r--r--error.c100
-rw-r--r--error.h82
-rw-r--r--fmt.c22
-rw-r--r--rdxtree.c22
-rw-r--r--shell.c32
-rw-r--r--shell.h26
-rw-r--r--test/test_cbuf.c4
-rw-r--r--test/test_rdxtree.c14
-rw-r--r--test/test_shell.c1
12 files changed, 76 insertions, 255 deletions
diff --git a/Makefile.am b/Makefile.am
index 5d4d441..8586419 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -25,8 +25,6 @@ librbraun_la_SOURCES = \
cbuf.h \
check.h \
cpu.h \
- error.c \
- error.h \
fmt.c \
fmt.h \
hash.h \
diff --git a/cbuf.c b/cbuf.c
index d79cd6d..1570ac8 100644
--- a/cbuf.c
+++ b/cbuf.c
@@ -24,12 +24,12 @@
*/
#include <assert.h>
+#include <errno.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include "cbuf.h"
-#include "error.h"
#include "macros.h"
/* Negative close to 0 so that an overflow occurs early */
@@ -70,7 +70,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 ERROR_AGAIN;
+ return EAGAIN;
}
}
@@ -83,7 +83,7 @@ cbuf_pop(struct cbuf *cbuf, void *buf, size_t *sizep)
__unused int error;
if (cbuf_size(cbuf) == 0) {
- return ERROR_AGAIN;
+ return EAGAIN;
}
error = cbuf_read(cbuf, cbuf_start(cbuf), buf, sizep);
@@ -101,7 +101,7 @@ cbuf_pushb(struct cbuf *cbuf, uint8_t byte, bool erase)
free_size = cbuf_capacity(cbuf) - cbuf_size(cbuf);
if (free_size == 0) {
- return ERROR_AGAIN;
+ return EAGAIN;
}
}
@@ -117,7 +117,7 @@ cbuf_popb(struct cbuf *cbuf, void *bytep)
uint8_t *ptr;
if (cbuf_size(cbuf) == 0) {
- return ERROR_AGAIN;
+ return EAGAIN;
}
ptr = bytep;
@@ -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 ERROR_INVAL;
+ return EINVAL;
}
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 ERROR_INVAL;
+ return EINVAL;
}
size = cbuf->end - index;
diff --git a/cbuf.h b/cbuf.h
index eb2ec83..8b46cd4 100644
--- a/cbuf.h
+++ b/cbuf.h
@@ -96,7 +96,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, ERROR_AGAIN is returned.
+ * doesn't have enough unused bytes for the new data, EAGAIN is returned.
*/
int cbuf_push(struct cbuf *cbuf, const void *buf, size_t size, bool erase);
@@ -106,7 +106,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, ERROR_AGAIN is returned, and the size of the
+ * If the buffer is empty, EAGAIN is returned, and the size of the
* output buffer is undefined.
*/
int cbuf_pop(struct cbuf *cbuf, void *buf, size_t *sizep);
@@ -115,21 +115,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, ERROR_AGAIN is returned.
+ * is full, EAGAIN 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, ERROR_AGAIN is returned.
+ * If the buffer is empty, EAGAIN is returned.
*/
int cbuf_popb(struct cbuf *cbuf, void *bytep);
/*
* Write into a circular buffer at a specific location.
*
- * If the given index is outside buffer boundaries, ERROR_INVAL is returned.
+ * If the given index is outside buffer boundaries, EINVAL is returned.
* The given [index, size) range may extend beyond the end of the circular
* buffer.
*/
@@ -141,7 +141,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, ERROR_INVAL is returned.
+ * If the given index is outside buffer boundaries, EINVAL is returned.
*
* The circular buffer isn't changed by this operation.
*/
diff --git a/error.c b/error.c
deleted file mode 100644
index 5861bfc..0000000
--- a/error.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2009-2018 Richard Braun.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Upstream site with license notes :
- * http://git.sceen.net/rbraun/librbraun.git/
- */
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "error.h"
-#include "macros.h"
-
-/*
- * Error message table.
- *
- * This table must be consistent with the enum defined in error.h.
- */
-static const char *errormsg_table[] = {
- "success",
- "unknown error",
- "invalid argument",
- "not enough space",
- "invalid format",
- "not enough resources",
- "operation not permitted",
- "resource busy",
- "operation timed out",
- "resource temporarily unavailable",
- "entry exist",
-};
-
-#define ERRORMSG_TABLE_SIZE ARRAY_SIZE(errormsg_table)
-
-const char *
-error_str(unsigned int error)
-{
- if (error >= ERRORMSG_TABLE_SIZE) {
- return "invalid error code";
- }
-
- return errormsg_table[error];
-}
-
-unsigned int
-error_from_errno(int errno_code)
-{
- switch (errno_code) {
- case 0:
- return ERROR_SUCCESS;
- case EINVAL:
- return ERROR_INVAL;
- case ENOMEM:
- return ERROR_NOMEM;
- case EAGAIN:
- return ERROR_NORES;
- case EPERM:
- return ERROR_PERM;
- case EBUSY:
- return ERROR_BUSY;
- case ETIMEDOUT:
- return ERROR_TIMEDOUT;
- default:
- fprintf(stderr, "unable to translate errno code (%d)\n", errno_code);
- return ERROR_UNKNOWN;
- }
-}
-
-void
-error_check(int error, const char *prefix)
-{
- if (!error) {
- return;
- }
-
- fprintf(stderr, "%s%s%s\n",
- (prefix == NULL) ? "" : prefix,
- (prefix == NULL) ? "" : ": ",
- error_str(error));
- abort();
-}
diff --git a/error.h b/error.h
deleted file mode 100644
index eb43b52..0000000
--- a/error.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2009-2018 Richard Braun.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Upstream site with license notes :
- * http://git.sceen.net/rbraun/librbraun.git/
- */
-
-#ifndef _ERROR_H
-#define _ERROR_H
-
-#include <stdnoreturn.h>
-
-#include "macros.h"
-
-/*
- * List of errors this library can return.
- *
- * ERROR_SUCCESS is guaranteed to be 0, allowing code such as :
- *
- * error = do_smth();
- *
- * if (error) {
- * ...;
- * }
- */
-enum {
- ERROR_SUCCESS,
- ERROR_UNKNOWN,
- ERROR_INVAL,
- ERROR_NOMEM,
- ERROR_FORMAT,
- ERROR_NORES,
- ERROR_PERM,
- ERROR_BUSY,
- ERROR_TIMEDOUT,
- ERROR_AGAIN,
- ERROR_EXIST,
-};
-
-/*
- * Return the message matching the given error.
- *
- * The returned address points to a statically allocated, read only,
- * null-terminated string literal. The caller must not attempt to use it
- * for anything else than error reporting.
- */
-const char * error_str(unsigned int error);
-
-/*
- * Map standard error codes to error values.
- *
- * 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 ERROR_xxx code. Otherwise ERROR_UNKNOWN is returned.
- */
-unsigned int error_from_errno(int errno_code);
-
-/*
- * If error denotes an actual error (i.e. is not 0), abort, using the given
- * string as a prefix for the error message. A NULL prefix is allowed.
- */
-void error_check(int error, const char *prefix);
-
-#endif /* _ERROR_H */
diff --git a/fmt.c b/fmt.c
index 10c34f6..5b5db78 100644
--- a/fmt.c
+++ b/fmt.c
@@ -24,6 +24,7 @@
*/
#include <assert.h>
+#include <errno.h>
#include <limits.h>
#include <stdbool.h>
#include <stdarg.h>
@@ -32,7 +33,6 @@
#include <stdio.h>
#include <string.h>
-#include "error.h"
#include "fmt.h"
#include "macros.h"
@@ -404,12 +404,12 @@ fmt_sprintf_state_consume(struct fmt_sprintf_state *state)
c = fmt_consume(&state->format);
if (c == '\0') {
- return ERROR_NORES;
+ return ENOENT;
}
if (c != '%') {
fmt_sprintf_state_produce_raw_char(state, c);
- return ERROR_AGAIN;
+ return EAGAIN;
}
fmt_sprintf_state_consume_flags(state);
@@ -788,7 +788,7 @@ fmt_vsnprintf(char *str, size_t size, const char *format, va_list ap)
for (;;) {
error = fmt_sprintf_state_consume(&state);
- if (error == ERROR_AGAIN) {
+ if (error == EAGAIN) {
continue;
} else if (error) {
break;
@@ -1069,7 +1069,7 @@ fmt_sscanf_state_discard_char(struct fmt_sscanf_state *state, char c)
state->nr_convs = EOF;
}
- return ERROR_FORMAT;
+ return EINVAL;
}
return 0;
@@ -1086,7 +1086,7 @@ fmt_sscanf_state_consume(struct fmt_sscanf_state *state)
c = fmt_consume(&state->format);
if (c == '\0') {
- return ERROR_NORES;
+ return ENOENT;
}
if (c != '%') {
@@ -1096,7 +1096,7 @@ fmt_sscanf_state_consume(struct fmt_sscanf_state *state)
return error;
}
- return ERROR_AGAIN;
+ return EAGAIN;
}
fmt_sscanf_state_consume_flags(state);
@@ -1188,7 +1188,7 @@ fmt_sscanf_state_produce_int(struct fmt_sscanf_state *state)
if (i == 0) {
if (c == '\0') {
fmt_sscanf_state_report_error(state);
- return ERROR_FORMAT;
+ return EINVAL;
}
buf[0] = '0';
@@ -1382,7 +1382,7 @@ fmt_sscanf_state_produce_str(struct fmt_sscanf_state *state)
if (state->str == orig) {
fmt_sscanf_state_report_error(state);
- return ERROR_FORMAT;
+ return EINVAL;
}
if (dest != NULL) {
@@ -1417,7 +1417,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 ERROR_FORMAT;
+ return EINVAL;
}
}
@@ -1445,7 +1445,7 @@ fmt_vsscanf(const char *str, const char *format, va_list ap)
for (;;) {
error = fmt_sscanf_state_consume(&state);
- if (error == ERROR_AGAIN) {
+ if (error == EAGAIN) {
continue;
} else if (error) {
break;
diff --git a/rdxtree.c b/rdxtree.c
index 0f26545..3df6ccb 100644
--- a/rdxtree.c
+++ b/rdxtree.c
@@ -26,13 +26,13 @@
#include <stdbool.h>
#include <assert.h>
+#include <errno.h>
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
-#include "error.h"
#include "macros.h"
#include "rdxtree.h"
#include "rdxtree_i.h"
@@ -142,7 +142,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 ERROR_NOMEM;
+ return ENOMEM;
}
}
#endif /* RDXTREE_ENABLE_NODE_CREATION_FAILURES */
@@ -150,7 +150,7 @@ rdxtree_node_create(struct rdxtree_node **nodep, unsigned short height)
node = malloc(sizeof(*node));
if (node == NULL) {
- return ERROR_NOMEM;
+ return ENOMEM;
}
rdxtree_assert_alignment(node);
@@ -348,7 +348,7 @@ rdxtree_grow(struct rdxtree *tree, rdxtree_key_t key)
if (tree->root == NULL) {
tree->height = new_height;
- return ERROR_SUCCESS;
+ return 0;
}
root = rdxtree_entry_addr(tree->root);
@@ -380,7 +380,7 @@ rdxtree_grow(struct rdxtree *tree, rdxtree_key_t key)
root = node;
} while (new_height > tree->height);
- return ERROR_SUCCESS;
+ return 0;
}
static void
@@ -451,7 +451,7 @@ rdxtree_insert_common(struct rdxtree *tree, rdxtree_key_t key,
if (unlikely(height == 0)) {
if (tree->root != NULL) {
- return ERROR_BUSY;
+ return EBUSY;
}
llsync_store_ptr(tree->root, ptr);
@@ -460,7 +460,7 @@ rdxtree_insert_common(struct rdxtree *tree, rdxtree_key_t key,
*slotp = &tree->root;
}
- return ERROR_SUCCESS;
+ return 0;
}
node = rdxtree_entry_addr(tree->root);
@@ -497,7 +497,7 @@ rdxtree_insert_common(struct rdxtree *tree, rdxtree_key_t key,
} while (height > 0);
if (unlikely(node != NULL)) {
- return ERROR_BUSY;
+ return EBUSY;
}
rdxtree_node_insert(prev, index, ptr);
@@ -510,7 +510,7 @@ rdxtree_insert_common(struct rdxtree *tree, rdxtree_key_t key,
*slotp = &prev->entries[index];
}
- return ERROR_SUCCESS;
+ return 0;
}
int
@@ -538,7 +538,7 @@ rdxtree_insert_alloc_common(struct rdxtree *tree, void *ptr,
*slotp = &tree->root;
}
- return ERROR_SUCCESS;
+ return 0;
}
goto grow;
@@ -594,7 +594,7 @@ grow:
out:
*keyp = key;
- return ERROR_SUCCESS;
+ return 0;
}
static void
diff --git a/shell.c b/shell.c
index 2f319e2..f98baab 100644
--- a/shell.c
+++ b/shell.c
@@ -23,6 +23,7 @@
* http://git.sceen.net/rbraun/librbraun.git/
*/
+#include <errno.h>
#include <pthread.h>
#include <stddef.h>
#include <stdio.h>
@@ -30,7 +31,6 @@
#include <string.h>
#include "macros.h"
-#include "error.h"
#include "hash.h"
#include "shell.h"
@@ -265,8 +265,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.
*/
@@ -286,7 +286,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;
@@ -331,7 +331,7 @@ shell_cmd_complete(const char *str, unsigned long *sizep,
size--;
*sizep = size;
- return ERROR_AGAIN;
+ return EAGAIN;
}
/*
@@ -377,7 +377,7 @@ shell_cmd_check_char(char c)
return 0;
}
- return ERROR_INVAL;
+ return EINVAL;
}
static int
@@ -395,7 +395,7 @@ shell_cmd_check(const struct shell_cmd *cmd)
}
if (i == 0) {
- return ERROR_INVAL;
+ return EINVAL;
}
return 0;
@@ -454,7 +454,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 ERROR_EXIST;
+ return EEXIST;
}
if (tmp->ht_next == NULL) {
@@ -527,11 +527,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;
@@ -552,7 +552,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;
@@ -772,7 +772,7 @@ static int
shell_process_right(void)
{
if (shell_cursor >= shell_line_size(shell_history_get_newest())) {
- return ERROR_AGAIN;
+ return EAGAIN;
}
shell_cursor++;
@@ -875,12 +875,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;
@@ -1064,7 +1064,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;
@@ -1127,7 +1127,7 @@ shell_process_ctrl_char(char c)
case '\r':
putchar('\n');
shell_process_line();
- return ERROR_AGAIN;
+ return EAGAIN;
default:
return 0;
}
diff --git a/shell.h b/shell.h
index f509880..54a3b7a 100644
--- a/shell.h
+++ b/shell.h
@@ -30,19 +30,25 @@
#define _SHELL_H
#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
-#include <error.h>
#include <macros.h>
-#define SHELL_REGISTER_CMDS(cmds) \
-MACRO_BEGIN \
- size_t ___i; \
- int ___error; \
- \
- for (___i = 0; ___i < ARRAY_SIZE(cmds); ___i++) { \
- ___error = shell_cmd_register(&(cmds)[___i]); \
- error_check(___error, __func__); \
- } \
+#define SHELL_REGISTER_CMDS(cmds) \
+MACRO_BEGIN \
+ size_t ___i; \
+ int ___error; \
+ \
+ for (___i = 0; ___i < ARRAY_SIZE(cmds); ___i++) { \
+ ___error = shell_cmd_register(&(cmds)[___i]); \
+ \
+ if (___error) { \
+ fprintf(stderr, "%s: %s\n", __func__, strerror(___error)); \
+ abort(); \
+ } \
+ } \
MACRO_END
typedef void (*shell_fn_t)(int argc, char *argv[]);
diff --git a/test/test_cbuf.c b/test/test_cbuf.c
index 7f00080..629157d 100644
--- a/test/test_cbuf.c
+++ b/test/test_cbuf.c
@@ -20,13 +20,13 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../cbuf.h"
#include "../check.h"
-#include "../error.h"
#include "../macros.h"
#define TEST_BUF_SIZE 1024
@@ -77,7 +77,7 @@ test_read_0(void)
size = 0;
error = cbuf_read(&cbuf, index, buf, &size);
- check(error == ERROR_INVAL);
+ check(error == EINVAL);
check(size == 0);
test_push(&cbuf, "a");
diff --git a/test/test_rdxtree.c b/test/test_rdxtree.c
index 7a3ed2c..dec72c3 100644
--- a/test/test_rdxtree.c
+++ b/test/test_rdxtree.c
@@ -20,13 +20,13 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#define RDXTREE_ENABLE_NODE_CREATION_FAILURES
#include "../check.h"
-#include "../error.h"
#include "../macros.h"
#include "../rdxtree.c"
@@ -691,7 +691,7 @@ test_21(void)
error = rdxtree_insert(&tree, 0, obj);
check(!error);
error = rdxtree_insert(&tree, 0, obj);
- check(error == ERROR_BUSY);
+ check(error == EBUSY);
destroy_tree(&tree);
}
@@ -709,7 +709,7 @@ test_22(void)
error = rdxtree_insert(&tree, 123, obj);
check(!error);
error = rdxtree_insert(&tree, 123, obj);
- check(error == ERROR_BUSY);
+ check(error == EBUSY);
destroy_tree(&tree);
}
@@ -919,7 +919,7 @@ test_33(void)
rdxtree_init(&tree, 0);
obj = obj_create(1);
error = rdxtree_insert(&tree, obj->id, obj);
- check(error == ERROR_NOMEM);
+ check(error == ENOMEM);
obj_destroy(obj);
print_tree(&tree);
}
@@ -939,7 +939,7 @@ test_34(void)
rdxtree_init(&tree, 0);
obj = obj_create(64);
error = rdxtree_insert(&tree, obj->id, obj);
- check(error == ERROR_NOMEM);
+ check(error == ENOMEM);
obj_destroy(obj);
print_tree(&tree);
}
@@ -962,7 +962,7 @@ test_35(void)
check(!error);
obj = obj_create(64);
error = rdxtree_insert(&tree, obj->id, obj);
- check(error == ERROR_NOMEM);
+ check(error == ENOMEM);
obj_destroy(obj);
print_tree(&tree);
destroy_tree(&tree);
@@ -986,7 +986,7 @@ test_36(void)
check(!error);
obj = obj_create(64);
error = rdxtree_insert(&tree, obj->id, obj);
- check(error == ERROR_NOMEM);
+ check(error == ENOMEM);
obj_destroy(obj);
print_tree(&tree);
destroy_tree(&tree);
diff --git a/test/test_shell.c b/test/test_shell.c
index 3e44ba3..6ace094 100644
--- a/test/test_shell.c
+++ b/test/test_shell.c
@@ -26,7 +26,6 @@
#include <termios.h>
#include <unistd.h>
-#include "../error.h"
#include "../macros.h"
#include "../shell.h"