summaryrefslogtreecommitdiff
path: root/kern/cbuf.c
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-06-17 18:39:07 +0200
committerRichard Braun <rbraun@sceen.net>2017-06-17 18:39:07 +0200
commitbf32d26490a6fd688194f67856563f0a5a843668 (patch)
tree82d1415c14972db783f3067429bea38b92583789 /kern/cbuf.c
parent363d01aa8443bcccab267ff9a1830dcbf67eaba1 (diff)
kern/cbuf: use size_t instead of unsigned long
Diffstat (limited to 'kern/cbuf.c')
-rw-r--r--kern/cbuf.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/kern/cbuf.c b/kern/cbuf.c
index 5c636e56..ef5c7e33 100644
--- a/kern/cbuf.c
+++ b/kern/cbuf.c
@@ -16,16 +16,17 @@
*/
#include <assert.h>
+#include <stddef.h>
#include <kern/cbuf.h>
#include <kern/error.h>
#include <kern/macros.h>
/* Negative close to 0 so that an overflow occurs early */
-#define CBUF_INIT_INDEX ((unsigned long)-500)
+#define CBUF_INIT_INDEX ((size_t)-500)
void
-cbuf_init(struct cbuf *cbuf, char *buf, unsigned long capacity)
+cbuf_init(struct cbuf *cbuf, char *buf, size_t capacity)
{
assert(ISP2(capacity));
@@ -35,8 +36,8 @@ cbuf_init(struct cbuf *cbuf, char *buf, unsigned long capacity)
cbuf->end = cbuf->start;
}
-static unsigned long
-cbuf_index(const struct cbuf *cbuf, unsigned long abs_index)
+static size_t
+cbuf_index(const struct cbuf *cbuf, size_t abs_index)
{
return abs_index & (cbuf->capacity - 1);
}
@@ -66,7 +67,7 @@ cbuf_pop(struct cbuf *cbuf, char *bytep)
}
int
-cbuf_read(const struct cbuf *cbuf, unsigned long index, char *bytep)
+cbuf_read(const struct cbuf *cbuf, size_t index, char *bytep)
{
/* Mind integer overflows */
if ((cbuf->end - index - 1) >= cbuf_size(cbuf)) {