From 066b2bb674c59ebab2bc04387069f7a2f0173862 Mon Sep 17 00:00:00 2001 From: zhuhongtao66 Date: Tue, 28 Mar 2023 16:14:13 +0800 Subject: [PATCH] Should return ENOMEM as error Signed-off-by: zhuhongtao66 --- interfaces/kits/js/src/mod_fs/properties/fdatasync.cpp | 2 +- interfaces/kits/js/src/mod_fs/properties/fsync.cpp | 2 +- interfaces/kits/js/src/mod_fs/properties/mkdtemp.cpp | 2 +- interfaces/kits/js/src/mod_fs/properties/open.cpp | 2 +- interfaces/kits/js/src/mod_fs/properties/read_text.cpp | 4 ++-- interfaces/kits/js/src/mod_fs/properties/symlink.cpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/interfaces/kits/js/src/mod_fs/properties/fdatasync.cpp b/interfaces/kits/js/src/mod_fs/properties/fdatasync.cpp index 54dae67b9..6c683170c 100644 --- a/interfaces/kits/js/src/mod_fs/properties/fdatasync.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/fdatasync.cpp @@ -82,7 +82,7 @@ napi_value Fdatasync::Async(napi_env env, napi_callback_info info) new uv_fs_t, CommonFunc::fs_req_cleanup }; if (!fdatasync_req) { HILOGE("Failed to request heap memory."); - return NError(ERRNO_NOERR); + return NError(ENOMEM); } int ret = uv_fs_fdatasync(nullptr, fdatasync_req.get(), fd, nullptr); if (ret < 0) { diff --git a/interfaces/kits/js/src/mod_fs/properties/fsync.cpp b/interfaces/kits/js/src/mod_fs/properties/fsync.cpp index 6fcb230fd..b252665c7 100644 --- a/interfaces/kits/js/src/mod_fs/properties/fsync.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/fsync.cpp @@ -79,7 +79,7 @@ napi_value Fsync::Async(napi_env env, napi_callback_info info) new uv_fs_t, CommonFunc::fs_req_cleanup }; if (!fsync_req) { HILOGE("Failed to request heap memory."); - return NError(ERRNO_NOERR); + return NError(ENOMEM); } int ret = uv_fs_fsync(nullptr, fsync_req.get(), fd, nullptr); if (ret < 0) { diff --git a/interfaces/kits/js/src/mod_fs/properties/mkdtemp.cpp b/interfaces/kits/js/src/mod_fs/properties/mkdtemp.cpp index 2beb0445e..532e78180 100755 --- a/interfaces/kits/js/src/mod_fs/properties/mkdtemp.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/mkdtemp.cpp @@ -80,7 +80,7 @@ napi_value Mkdtemp::Async(napi_env env, napi_callback_info info) new uv_fs_t, CommonFunc::fs_req_cleanup }; if (!mkdtemp_req) { HILOGE("Failed to request heap memory."); - return NError(ERRNO_NOERR); + return NError(ENOMEM); } int ret = uv_fs_mkdtemp(nullptr, mkdtemp_req.get(), path.c_str(), nullptr); if (ret < 0) { diff --git a/interfaces/kits/js/src/mod_fs/properties/open.cpp b/interfaces/kits/js/src/mod_fs/properties/open.cpp index 1bb4350f0..32acfaa90 100644 --- a/interfaces/kits/js/src/mod_fs/properties/open.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/open.cpp @@ -244,7 +244,7 @@ napi_value Open::Async(napi_env env, napi_callback_info info) new uv_fs_t, CommonFunc::fs_req_cleanup }; if (!open_req) { HILOGE("Failed to request heap memory."); - return NError(ERRNO_NOERR); + return NError(ENOMEM); } int ret = uv_fs_open(nullptr, open_req.get(), pathStr.c_str(), mode, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, nullptr); diff --git a/interfaces/kits/js/src/mod_fs/properties/read_text.cpp b/interfaces/kits/js/src/mod_fs/properties/read_text.cpp index b577ec89e..b7c120119 100755 --- a/interfaces/kits/js/src/mod_fs/properties/read_text.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/read_text.cpp @@ -83,7 +83,7 @@ static NError ReadTextAsync(const std::string &path, std::shared_ptrlen = uv_fs_read(nullptr, read_req.get(), sfd.GetFD(), &readbuf, 1, offset, nullptr); if (arg->len < 0) { diff --git a/interfaces/kits/js/src/mod_fs/properties/symlink.cpp b/interfaces/kits/js/src/mod_fs/properties/symlink.cpp index 0c21cc9a6..62881ee16 100755 --- a/interfaces/kits/js/src/mod_fs/properties/symlink.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/symlink.cpp @@ -98,7 +98,7 @@ napi_value Symlink::Async(napi_env env, napi_callback_info info) new uv_fs_t, CommonFunc::fs_req_cleanup }; if (!symlink_req) { HILOGE("Failed to request heap memory."); - return NError(ERRNO_NOERR); + return NError(ENOMEM); } int ret = uv_fs_symlink(nullptr, symlink_req.get(), oldPath.c_str(), newPath.c_str(), 0, nullptr); if (ret < 0) { -- Gitee