Skip to content

Commit c3a78cd

Browse files
fix sign-compare warnings (#4876)
1 parent c3dda4a commit c3a78cd

File tree

1 file changed

+6
-2
lines changed
  • core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src

1 file changed

+6
-2
lines changed

core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,9 @@ fd_table_attach(struct fd_table *ft, __wasi_fd_t fd, struct fd_object *fo,
430430
__wasi_rights_t rights_base, __wasi_rights_t rights_inheriting)
431431
REQUIRES_EXCLUSIVE(ft->lock) CONSUMES(fo->refcount)
432432
{
433-
bh_assert(ft->size > (size_t)fd && "File descriptor table too small");
433+
bh_assert(ft->size <= INT_MAX
434+
&& "Unsigned value is out of signed int range");
435+
bh_assert((int32_t)ft->size > fd && "File descriptor table too small");
434436
struct fd_entry *fe = &ft->entries[fd];
435437
bh_assert(fe->object == NULL
436438
&& "Attempted to overwrite an existing descriptor");
@@ -446,7 +448,9 @@ static void
446448
fd_table_detach(struct fd_table *ft, __wasi_fd_t fd, struct fd_object **fo)
447449
REQUIRES_EXCLUSIVE(ft->lock) PRODUCES((*fo)->refcount)
448450
{
449-
bh_assert(ft->size > fd && "File descriptor table too small");
451+
bh_assert(ft->size <= INT_MAX
452+
&& "Unsigned value is out of signed int range");
453+
bh_assert((int32_t)ft->size > fd && "File descriptor table too small");
450454
struct fd_entry *fe = &ft->entries[fd];
451455
*fo = fe->object;
452456
bh_assert(*fo != NULL && "Attempted to detach nonexistent descriptor");

0 commit comments

Comments
 (0)