summaryrefslogtreecommitdiff
path: root/lib/cbuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cbuf.c')
-rw-r--r--lib/cbuf.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/cbuf.c b/lib/cbuf.c
index e405964..ecff57a 100644
--- a/lib/cbuf.c
+++ b/lib/cbuf.c
@@ -24,6 +24,7 @@
*/
#include <assert.h>
+#include <errno.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
@@ -31,8 +32,6 @@
#include <lib/cbuf.h>
#include <lib/macros.h>
-#include <src/error.h>
-
/* Negative close to 0 so that an overflow occurs early */
#define CBUF_INIT_INDEX ((size_t)-500)
@@ -71,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;
}
}
@@ -84,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);
@@ -102,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;
}
}
@@ -118,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;
@@ -134,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;
@@ -175,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;