From d39d2ba3ca0bdc47ba81e1ee7723e6181fda3b1b Mon Sep 17 00:00:00 2001 From: Yage Hu Date: Wed, 17 Apr 2024 01:06:25 -0700 Subject: [PATCH] Fix posix_fadvise error handling (#3323) `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 20f94fba34..e7c8383c31 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;