From 5c149d887558bf59bf2af0a2712827c11ad1dc78 Mon Sep 17 00:00:00 2001 From: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com> Date: Tue, 3 Mar 2026 13:43:22 +0100 Subject: [PATCH 1/2] clean(warnings): fix [-Wsign-compare] in zephyr_file buf_len is a long unsigned int, while bytes_* can be negative due to error values. We don't need to check bytes_* for negative value, as it was done during read/write op. Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com> --- core/shared/platform/zephyr/zephyr_file.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/core/shared/platform/zephyr/zephyr_file.c b/core/shared/platform/zephyr/zephyr_file.c index f585002e07..54b357e318 100644 --- a/core/shared/platform/zephyr/zephyr_file.c +++ b/core/shared/platform/zephyr/zephyr_file.c @@ -594,8 +594,9 @@ os_preadv(os_file_handle handle, const struct __wasi_iovec_t *iov, int iovcnt, total_read += bytes_read; - // If we read less than we asked for, stop reading - if (bytes_read < iov[i].buf_len) { + /* If we read less than we asked for, stop reading + bytes_read being a non-negative value was already checked */ + if ((size_t)bytes_read < iov[i].buf_len) { break; } } @@ -630,8 +631,9 @@ os_pwritev(os_file_handle handle, const struct __wasi_ciovec_t *iov, int iovcnt, total_written += bytes_written; - // If we wrote less than we asked for, stop writing - if (bytes_written < iov[i].buf_len) { + /* If we wrote less than we asked for, stop writing + bytes_read being a non-negative value was already checked */ + if ((size_t)bytes_written < iov[i].buf_len) { break; } } @@ -660,8 +662,9 @@ os_readv(os_file_handle handle, const struct __wasi_iovec_t *iov, int iovcnt, total_read += bytes_read; - // If we read less than we asked for, stop reading - if (bytes_read < iov[i].buf_len) { + /* If we read less than we asked for, stop reading + bytes_read being a non-negative value was already checked */ + if ((size_t)bytes_read < iov[i].buf_len) { break; } } @@ -705,8 +708,9 @@ os_writev(os_file_handle handle, const struct __wasi_ciovec_t *iov, int iovcnt, total_written += bytes_written; - // If we wrote less than we asked for, stop writing - if (bytes_written < iov[i].buf_len) { + /* If we wrote less than we asked for, stop writing + bytes_read being a non-negative value was already checked */ + if ((size_t)bytes_written < iov[i].buf_len) { break; } } From e01e6b1ebce2321710756f9412154a189321eac3 Mon Sep 17 00:00:00 2001 From: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com> Date: Tue, 3 Mar 2026 13:49:10 +0100 Subject: [PATCH 2/2] clean(warnings): fix "MIN" redefined warning Some platforms, like Zephyr, already define MIN and definition in WAMR cause `warning: "MIN" redefined` warning. Check if it was defined before, and do not redefine it. Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com> --- core/iwasm/libraries/lib-wasi-threads/tid_allocator.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/iwasm/libraries/lib-wasi-threads/tid_allocator.c b/core/iwasm/libraries/lib-wasi-threads/tid_allocator.c index dc2d4f1bca..d7f6c74548 100644 --- a/core/iwasm/libraries/lib-wasi-threads/tid_allocator.c +++ b/core/iwasm/libraries/lib-wasi-threads/tid_allocator.c @@ -8,7 +8,10 @@ #include "bh_log.h" bh_static_assert(TID_MIN <= TID_MAX); +/* Some platforms, like Zephyr, have already defined MIN at this point */ +#ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif bool tid_allocator_init(TidAllocator *tid_allocator)