Skip to content

Commit 5c149d8

Browse files
committed
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>
1 parent 595dcd5 commit 5c149d8

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

core/shared/platform/zephyr/zephyr_file.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,9 @@ os_preadv(os_file_handle handle, const struct __wasi_iovec_t *iov, int iovcnt,
594594

595595
total_read += bytes_read;
596596

597-
// If we read less than we asked for, stop reading
598-
if (bytes_read < iov[i].buf_len) {
597+
/* If we read less than we asked for, stop reading
598+
bytes_read being a non-negative value was already checked */
599+
if ((size_t)bytes_read < iov[i].buf_len) {
599600
break;
600601
}
601602
}
@@ -630,8 +631,9 @@ os_pwritev(os_file_handle handle, const struct __wasi_ciovec_t *iov, int iovcnt,
630631

631632
total_written += bytes_written;
632633

633-
// If we wrote less than we asked for, stop writing
634-
if (bytes_written < iov[i].buf_len) {
634+
/* If we wrote less than we asked for, stop writing
635+
bytes_read being a non-negative value was already checked */
636+
if ((size_t)bytes_written < iov[i].buf_len) {
635637
break;
636638
}
637639
}
@@ -660,8 +662,9 @@ os_readv(os_file_handle handle, const struct __wasi_iovec_t *iov, int iovcnt,
660662

661663
total_read += bytes_read;
662664

663-
// If we read less than we asked for, stop reading
664-
if (bytes_read < iov[i].buf_len) {
665+
/* If we read less than we asked for, stop reading
666+
bytes_read being a non-negative value was already checked */
667+
if ((size_t)bytes_read < iov[i].buf_len) {
665668
break;
666669
}
667670
}
@@ -705,8 +708,9 @@ os_writev(os_file_handle handle, const struct __wasi_ciovec_t *iov, int iovcnt,
705708

706709
total_written += bytes_written;
707710

708-
// If we wrote less than we asked for, stop writing
709-
if (bytes_written < iov[i].buf_len) {
711+
/* If we wrote less than we asked for, stop writing
712+
bytes_read being a non-negative value was already checked */
713+
if ((size_t)bytes_written < iov[i].buf_len) {
710714
break;
711715
}
712716
}

0 commit comments

Comments
 (0)