From e52119329d5117f027f48832e03f0a16ed9f392f Mon Sep 17 00:00:00 2001 From: Yage Hu Date: Tue, 16 Apr 2024 18:46:52 -0700 Subject: [PATCH] Fix posix_fadvise error handling `posix_fadvise()` returns 0 on success and the errno on error. This commit fixes the handling of the return value such that it does not always succeeds. fixes #3322 --- core/shared/platform/common/posix/posix_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/shared/platform/common/posix/posix_file.c b/core/shared/platform/common/posix/posix_file.c index 20f94fba3..e7c8383c3 100644 --- a/core/shared/platform/common/posix/posix_file.c +++ b/core/shared/platform/common/posix/posix_file.c @@ -823,7 +823,7 @@ os_fadvise(os_file_handle handle, __wasi_filesize_t offset, int ret = posix_fadvise(handle, (off_t)offset, (off_t)length, nadvice); - if (ret < 0) + if (ret != 0) return convert_errno(ret); return __WASI_ESUCCESS;