Fix a few signedness warnings (#1095)

Fix compile warnings in libc-wasi posix.c:
```
posix.c:880:41: warning: comparison of integers of different signs:
 'unsigned long' and 'ssize_t' (aka 'long') [-Wsign-compare]
            if (bufoff + iov[i].buf_len < len) {
posix.c:1359:32: warning: comparison of integers of different signs:
 'off_t' (aka 'long long') and 'unsigned long long' [-Wsign-compare]
    if (ret == 0 && sb.st_size < offset + len)
```
This commit is contained in:
YAMAMOTO Takashi 2022-04-18 17:54:15 +09:00 committed by GitHub
parent 8589ed155d
commit 2366e8c493
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -877,7 +877,7 @@ wasmtime_ssp_fd_pread(
// Copy data back to vectors.
size_t bufoff = 0;
for (size_t i = 0; i < iovcnt; ++i) {
if (bufoff + iov[i].buf_len < len) {
if (bufoff + iov[i].buf_len < (size_t)len) {
bh_memcpy_s(iov[i].buf, iov[i].buf_len, buf + bufoff,
iov[i].buf_len);
bufoff += iov[i].buf_len;
@ -1356,8 +1356,9 @@ wasmtime_ssp_fd_allocate(
// conditions. We may end up shrinking the file right now.
struct stat sb;
int ret = fstat(fd_number(fo), &sb);
if (ret == 0 && sb.st_size < offset + len)
ret = ftruncate(fd_number(fo), offset + len);
off_t newsize = (off_t)(offset + len);
if (ret == 0 && sb.st_size < newsize)
ret = ftruncate(fd_number(fo), newsize);
#endif
fd_object_release(fo);