buf.c

Simple byte buffers
git clone git://git.finwo.net/lib/buf.c
Log | Files | Refs | README | LICENSE

commit 476ac4e261203747d3f343ff0cb1c6895ee8e91c
parent cbc2a662b9f4adecd8f0ce80febf139381e6b7de
Author: finwo <finwo@pm.me>
Date:   Sat, 12 Sep 2026 23:33:38 +0200

Fix build warnings

Diffstat:
Msrc/buf.c | 5+----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/buf.c b/src/buf.c @@ -25,14 +25,12 @@ const char *error_messages[] = { "Unknown error", "Missing subject", "Missing source", - "Negative length", }; #define BUF_ERRNO_UNKNOWN -1 #define BUF_ERRNO_OK 0 #define BUF_ERRNO_MISSING_SUBJECT 1 #define BUF_ERRNO_MISSING_SOURCE 2 -#define BUF_ERRNO_NEGATIVE_LENGTH 3 static void *(*_realloc)(void* ptr,size_t size) = realloc; static void (*_free)(void* ptr) = free; @@ -48,7 +46,7 @@ const char *buf_error(int errno) { if (!errno) return NULL; // Known error - if ((errno > 0) && (errno < ARRAY_SIZE(error_messages))) { + if ((errno > 0) && ((size_t)errno < ARRAY_SIZE(error_messages))) { return error_messages[errno]; } @@ -59,7 +57,6 @@ const char *buf_error(int errno) { int buf_append(struct buf *subject, const char *source, const size_t length) { if (!subject) return BUF_ERRNO_MISSING_SUBJECT; if (!source) return BUF_ERRNO_MISSING_SOURCE; - if (length < 0) return BUF_ERRNO_NEGATIVE_LENGTH; // Initial alloc if blank buffer if (!subject->alloc) {