From 12d8a56cda8015d50d6c1fd9133bb87be8f5dfb3 Mon Sep 17 00:00:00 2001 From: buzhenwang Date: Wed, 10 Sep 2025 16:12:35 +0800 Subject: [PATCH] code rectification Signed-off-by: buzhenwang --- interfaces/ets/ani/hilog/ets/@ohos.hilog.ets | 2 +- interfaces/ets/ani/hilog/include/hilog_ani_base.h | 4 ++-- interfaces/ets/ani/hilog/src/ani_util.cpp | 7 +++---- .../kits/napi/src/hilog/include/context/hilog_napi_base.h | 2 +- interfaces/js/kits/napi/src/hilog/src/hilog_napi_base.cpp | 6 +++--- interfaces/native/kits/include/hilog/log.h | 6 +++--- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/interfaces/ets/ani/hilog/ets/@ohos.hilog.ets b/interfaces/ets/ani/hilog/ets/@ohos.hilog.ets index 15cb6a7..affe282 100644 --- a/interfaces/ets/ani/hilog/ets/@ohos.hilog.ets +++ b/interfaces/ets/ani/hilog/ets/@ohos.hilog.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -type RecordData = undefined | null | Object | Record | Array; +import { RecordData } from '@ohos.base'; export default namespace hilog { loadLibrary("hilog_ani"); diff --git a/interfaces/ets/ani/hilog/include/hilog_ani_base.h b/interfaces/ets/ani/hilog/include/hilog_ani_base.h index 6a9795d..be04a7c 100644 --- a/interfaces/ets/ani/hilog/include/hilog_ani_base.h +++ b/interfaces/ets/ani/hilog/include/hilog_ani_base.h @@ -26,10 +26,10 @@ using AniParam = struct { std::string val; }; -typedef struct LogContentPosition { +struct LogContentPosition { uint32_t pos = 0; uint32_t count = 0; -} LogContentPosition; +}; class HilogAniBase { public: diff --git a/interfaces/ets/ani/hilog/src/ani_util.cpp b/interfaces/ets/ani/hilog/src/ani_util.cpp index 1388336..c16401c 100644 --- a/interfaces/ets/ani/hilog/src/ani_util.cpp +++ b/interfaces/ets/ani/hilog/src/ani_util.cpp @@ -54,9 +54,9 @@ bool AniUtil::IsRefUndefined(ani_env *env, ani_ref ref) bool AniUtil::IsRefNull(ani_env *env, ani_ref ref) { - ani_boolean isUull = ANI_FALSE; - env->Reference_IsNull(ref, &isUull); - return isUull; + ani_boolean isNull = ANI_FALSE; + env->Reference_IsNull(ref, &isNull); + return isNull; } AniArgsType AniUtil::AniArgGetType(ani_env *env, ani_object element) @@ -104,7 +104,6 @@ std::string AniUtil::AniStringToStdString(ani_env *env, ani_string aniStr) char* utf8Buffer = buffer.data(); ani_size bytesWritten = 0; env->String_GetUTF8(aniStr, utf8Buffer, strSize + 1, &bytesWritten); - utf8Buffer[bytesWritten] = '\0'; return std::string(utf8Buffer); } diff --git a/interfaces/js/kits/napi/src/hilog/include/context/hilog_napi_base.h b/interfaces/js/kits/napi/src/hilog/include/context/hilog_napi_base.h index 5e59f3c..e6b3a9c 100644 --- a/interfaces/js/kits/napi/src/hilog/include/context/hilog_napi_base.h +++ b/interfaces/js/kits/napi/src/hilog/include/context/hilog_napi_base.h @@ -44,7 +44,7 @@ public: static napi_value IsLoggable(napi_env env, napi_callback_info info); static napi_value SetMinLogLevel(napi_env env, napi_callback_info info); private: - static napi_value parseNapiValue(napi_env env, napi_callback_info info, + static napi_value ParseNapiValue(napi_env env, napi_callback_info info, napi_value element, std::vector& params); }; } // namespace HiviewDFX diff --git a/interfaces/js/kits/napi/src/hilog/src/hilog_napi_base.cpp b/interfaces/js/kits/napi/src/hilog/src/hilog_napi_base.cpp index 7bbfab2..f8e9e01 100644 --- a/interfaces/js/kits/napi/src/hilog/src/hilog_napi_base.cpp +++ b/interfaces/js/kits/napi/src/hilog/src/hilog_napi_base.cpp @@ -210,7 +210,7 @@ napi_value HilogNapiBase::SysLogFatal(napi_env env, napi_callback_info info) return HilogImpl(env, info, LOG_FATAL, false); } -napi_value HilogNapiBase::parseNapiValue(napi_env env, napi_callback_info info, +napi_value HilogNapiBase::ParseNapiValue(napi_env env, napi_callback_info info, napi_value element, vector& params) { bool succ = false; @@ -282,7 +282,7 @@ napi_value HilogNapiBase::HilogImpl(napi_env env, napi_callback_info info, int l if (!res) { for (size_t i = MIN_NUMBER; i < funcArg.GetArgc(); i++) { napi_value argsVal = funcArg[i]; - (void)parseNapiValue(env, info, argsVal, params); + (void)ParseNapiValue(env, info, argsVal, params); } } else { if (funcArg.GetArgc() != MIN_NUMBER + 1) { @@ -302,7 +302,7 @@ napi_value HilogNapiBase::HilogImpl(napi_env env, napi_callback_info info, int l if (eleStatus != napi_ok) { return nullptr; } - (void)parseNapiValue(env, info, element, params); + (void)ParseNapiValue(env, info, element, params); } } ParseLogContent(fmtString, params, logContent); diff --git a/interfaces/native/kits/include/hilog/log.h b/interfaces/native/kits/include/hilog/log.h index 5771964..fe48b03 100644 --- a/interfaces/native/kits/include/hilog/log.h +++ b/interfaces/native/kits/include/hilog/log.h @@ -165,7 +165,7 @@ int OH_LOG_Print(LogType type, LogLevel level, unsigned int domain, const char * * @param message Indicates the log string. * @return Returns 0 or a larger value if the operation is successful; returns a value smaller * than 0 otherwise. - * @since 16 + * @since 18 */ int OH_LOG_PrintMsg(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *message); @@ -185,7 +185,7 @@ int OH_LOG_PrintMsg(LogType type, LogLevel level, unsigned int domain, const cha * @param messageLen Indicates the length of message. * @return Returns 0 or a larger value if the operation is successful; returns a value smaller * than 0 otherwise. - * @since 16 + * @since 18 */ int OH_LOG_PrintMsgByLen(LogType type, LogLevel level, unsigned int domain, const char *tag, size_t tagLen, const char *message, size_t messageLen); @@ -209,7 +209,7 @@ int OH_LOG_PrintMsgByLen(LogType type, LogLevel level, unsigned int domain, cons * in the format string. * @return Returns 0 or a larger value if the operation is successful; returns a value smaller * than 0 otherwise. - * @since 16 + * @since 18 */ int OH_LOG_VPrint(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, va_list ap) __attribute__((__format__(os_log, 5, 0))); -- Gitee