From f9308fb3f44537343c00714f68b22d6c600aa9bc Mon Sep 17 00:00:00 2001 From: gwx1278443 Date: Thu, 22 Feb 2024 10:51:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B8=85=E6=A5=9A=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: gwx1278443 --- .../kits/js/src/common/napi/n_async/n_async_context.h | 6 +++--- .../js/src/common/napi/n_async/n_async_work_callback.h | 2 +- .../kits/js/src/common/napi/n_async/n_async_work_promise.h | 2 +- interfaces/kits/js/src/common/napi/n_val.cpp | 7 ++++--- .../kits/js/src/mod_fileio/properties/prop_n_exporter.h | 2 +- interfaces/kits/js/src/mod_fs/properties/utimes.cpp | 2 +- utils/filemgmt_libn/src/n_async/n_async_work_callback.cpp | 4 ++-- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/interfaces/kits/js/src/common/napi/n_async/n_async_context.h b/interfaces/kits/js/src/common/napi/n_async/n_async_context.h index 87339bbdd..7ffd2ff94 100644 --- a/interfaces/kits/js/src/common/napi/n_async/n_async_context.h +++ b/interfaces/kits/js/src/common/napi/n_async/n_async_context.h @@ -43,14 +43,14 @@ class NAsyncContextPromise : public NAsyncContext { public: napi_deferred deferred_ = nullptr; explicit NAsyncContextPromise(NVal thisPtr) : NAsyncContext(thisPtr) {} - ~NAsyncContextPromise() = default; + ~NAsyncContextPromise() override = default; }; class NAsyncContextCallback : public NAsyncContext { public: NRef cb_; NAsyncContextCallback(NVal thisPtr, NVal cb) : NAsyncContext(thisPtr), cb_(cb) {} - ~NAsyncContextCallback() = default; + ~NAsyncContextCallback() override = default; }; class NAsyncContextLegacy : public NAsyncContext { @@ -61,7 +61,7 @@ public: NAsyncContextLegacy(NVal thisPtr, NVal cbSucc, NVal cbFail, NVal cbFinal) : NAsyncContext(thisPtr), cbSucc_(cbSucc), cbFail_(cbFail), cbFinal_(cbFinal) {} - ~NAsyncContextLegacy() = default; + ~NAsyncContextLegacy() override = default; }; } // namespace DistributedFS } // namespace OHOS diff --git a/interfaces/kits/js/src/common/napi/n_async/n_async_work_callback.h b/interfaces/kits/js/src/common/napi/n_async/n_async_work_callback.h index 9bc6d5f3d..bd30ccd27 100644 --- a/interfaces/kits/js/src/common/napi/n_async/n_async_work_callback.h +++ b/interfaces/kits/js/src/common/napi/n_async/n_async_work_callback.h @@ -23,7 +23,7 @@ namespace DistributedFS { class NAsyncWorkCallback : public NAsyncWorkFactory { public: NAsyncWorkCallback(napi_env env, NVal thisPtr, NVal cb); - ~NAsyncWorkCallback() = default; + ~NAsyncWorkCallback() override = default; NVal Schedule(std::string procedureName, NContextCBExec cbExec, NContextCBComplete cbComplete) final; diff --git a/interfaces/kits/js/src/common/napi/n_async/n_async_work_promise.h b/interfaces/kits/js/src/common/napi/n_async/n_async_work_promise.h index 8a049de65..af3bf79cf 100644 --- a/interfaces/kits/js/src/common/napi/n_async/n_async_work_promise.h +++ b/interfaces/kits/js/src/common/napi/n_async/n_async_work_promise.h @@ -23,7 +23,7 @@ namespace DistributedFS { class NAsyncWorkPromise : public NAsyncWorkFactory { public: NAsyncWorkPromise(napi_env env, NVal thisPtr); - ~NAsyncWorkPromise() = default; + ~NAsyncWorkPromise() override = default; NVal Schedule(std::string procedureName, NContextCBExec cbExec, NContextCBComplete cbComplete) final; diff --git a/interfaces/kits/js/src/common/napi/n_val.cpp b/interfaces/kits/js/src/common/napi/n_val.cpp index 5e068e708..5c1ed6486 100644 --- a/interfaces/kits/js/src/common/napi/n_val.cpp +++ b/interfaces/kits/js/src/common/napi/n_val.cpp @@ -200,11 +200,11 @@ tuple NVal::ToTypedArray() const { napi_typedarray_type type; napi_value in_array_buffer = nullptr; - size_t byte_offset; + size_t byteOffset; size_t length; void *data = nullptr; napi_status status = - napi_get_typedarray_info(env_, val_, &type, &length, (void **)&data, &in_array_buffer, &byte_offset); + napi_get_typedarray_info(env_, val_, &type, &length, (void **)&data, &in_array_buffer, &byteOffset); return make_tuple(status == napi_ok, data, length); } @@ -212,8 +212,9 @@ bool NVal::HasProp(string propName) const { bool res = false; - if (!env_ || !val_ || !TypeIs(napi_object)) + if (!env_ || !val_ || !TypeIs(napi_object)) { return false; + } napi_status status = napi_has_named_property(env_, val_, propName.c_str(), &res); return (status == napi_ok) && res; } diff --git a/interfaces/kits/js/src/mod_fileio/properties/prop_n_exporter.h b/interfaces/kits/js/src/mod_fileio/properties/prop_n_exporter.h index 6fa7be33d..30d194461 100644 --- a/interfaces/kits/js/src/mod_fileio/properties/prop_n_exporter.h +++ b/interfaces/kits/js/src/mod_fileio/properties/prop_n_exporter.h @@ -57,7 +57,7 @@ public: std::string GetClassName() override; PropNExporter(napi_env env, napi_value exports); - ~PropNExporter() = default; + ~PropNExporter() override = default; }; } // namespace ModuleFileIO } // namespace DistributedFS diff --git a/interfaces/kits/js/src/mod_fs/properties/utimes.cpp b/interfaces/kits/js/src/mod_fs/properties/utimes.cpp index b73e1ab70..04277c964 100644 --- a/interfaces/kits/js/src/mod_fs/properties/utimes.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/utimes.cpp @@ -42,7 +42,7 @@ napi_value Utimes::Sync(napi_env env, napi_callback_info info) return nullptr; } - auto [succGetMtime, mtime] = NVal(env, funcArg[NARG_POS::SECOND]).ToDouble();; + auto [succGetMtime, mtime] = NVal(env, funcArg[NARG_POS::SECOND]).ToDouble(); if (!succGetMtime || mtime < 0) { HILOGE("Invalid mtime from JS second argument"); NError(EINVAL).ThrowErr(env); diff --git a/utils/filemgmt_libn/src/n_async/n_async_work_callback.cpp b/utils/filemgmt_libn/src/n_async/n_async_work_callback.cpp index 3df058b85..84e5ab885 100644 --- a/utils/filemgmt_libn/src/n_async/n_async_work_callback.cpp +++ b/utils/filemgmt_libn/src/n_async/n_async_work_callback.cpp @@ -45,7 +45,7 @@ NAsyncWorkCallback::~NAsyncWorkCallback() return; } - unique_ptr work(new (std::nothrow) uv_work_t); + std::unique_ptr work = std::make_unique(); if (work == nullptr) { HILOGE("Failed to new uv_work_t"); return; @@ -195,7 +195,7 @@ void NAsyncWorkCallback::ThreadSafeSchedule(NContextCBComplete cbComplete) return; } - unique_ptr work(new (std::nothrow) uv_work_t); + std::unique_ptr work = std::make_unique(); if (!work) { HILOGE("Failed to new uv_work_t"); return; -- Gitee From 87aee67ab23510c24d417e055fbeb7c6a066f4c6 Mon Sep 17 00:00:00 2001 From: shuaiguo Date: Mon, 26 Feb 2024 12:24:48 +0000 Subject: [PATCH 2/2] update interfaces/kits/js/src/mod_fileio/properties/prop_n_exporter.h. Signed-off-by: shuaiguo --- interfaces/kits/js/src/mod_fileio/properties/prop_n_exporter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/js/src/mod_fileio/properties/prop_n_exporter.h b/interfaces/kits/js/src/mod_fileio/properties/prop_n_exporter.h index 30d194461..6fa7be33d 100644 --- a/interfaces/kits/js/src/mod_fileio/properties/prop_n_exporter.h +++ b/interfaces/kits/js/src/mod_fileio/properties/prop_n_exporter.h @@ -57,7 +57,7 @@ public: std::string GetClassName() override; PropNExporter(napi_env env, napi_value exports); - ~PropNExporter() override = default; + ~PropNExporter() = default; }; } // namespace ModuleFileIO } // namespace DistributedFS -- Gitee