From 4a8662ac566d17ccc48d4b920d70e644fda416f2 Mon Sep 17 00:00:00 2001 From: wangyinghao Date: Fri, 30 May 2025 18:00:27 +0800 Subject: [PATCH] Remove direct dependency on hilog Signed-off-by: wangyinghao Change-Id: I4f7f952bb61046f856d8c87539328b8a135082f7 --- .../inner_api/jit_code_sign/include/jit_code_signer.h | 8 ++------ .../inner_api/jit_code_sign/src/jit_code_signer.cpp | 8 +++----- utils/include/log.h | 6 ------ 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/interfaces/inner_api/jit_code_sign/include/jit_code_signer.h b/interfaces/inner_api/jit_code_sign/include/jit_code_signer.h index ae87718..b98843b 100644 --- a/interfaces/inner_api/jit_code_sign/include/jit_code_signer.h +++ b/interfaces/inner_api/jit_code_sign/include/jit_code_signer.h @@ -18,9 +18,6 @@ #include #include -#ifndef JIT_FORT_DISABLE -#include "hilog/log.h" -#endif #include "pac_sign_ctx.h" namespace OHOS { @@ -44,9 +41,9 @@ static inline int GetIndexFromOffset(int offset) #ifndef JIT_FORT_DISABLE struct DeferredLog { DeferredLog() = delete; - DeferredLog(char *message, LogLevel level) noexcept : message(message), level(level) {} + DeferredLog(char *message) noexcept : message(message) {} DeferredLog(const DeferredLog &other) = delete; - DeferredLog(DeferredLog &&other) noexcept : message(other.message), level(other.level) + DeferredLog(DeferredLog &&other) noexcept : message(other.message) { other.message = nullptr; } @@ -56,7 +53,6 @@ struct DeferredLog { message = nullptr; } char *message; - LogLevel level; }; #endif diff --git a/interfaces/inner_api/jit_code_sign/src/jit_code_signer.cpp b/interfaces/inner_api/jit_code_sign/src/jit_code_signer.cpp index 05558c0..d114618 100644 --- a/interfaces/inner_api/jit_code_sign/src/jit_code_signer.cpp +++ b/interfaces/inner_api/jit_code_sign/src/jit_code_signer.cpp @@ -132,7 +132,7 @@ int32_t JitCodeSigner::PatchData(Byte *buffer, const Byte *const data, uint32_t void JitCodeSigner::FlushLog() { for (auto &log: deferredLogs) { - LOG_LEVELED(log.level, "%{public}s", log.message); + LOG_ERROR("%{public}s", log.message); } deferredLogs.clear(); // There's at most 1 log, for now. No need to shrink. @@ -179,14 +179,13 @@ int32_t JitCodeSigner::CheckDataCopy(Instr *jitMemory, Byte *tmpBuffer, int size int ret = sprintf_s(buffer, MAX_DEFERRED_LOG_LENGTH, "[%s]: Range invalid, size = %d, table size = %zu", __func__, size, signTable_.size()); - if (ret == -1) { free(buffer); buffer = nullptr; return CS_ERR_LOG_TOO_LONG; } - deferredLogs.emplace_back(DeferredLog{buffer, LOG_ERROR}); + deferredLogs.emplace_back(DeferredLog{buffer}); #endif return CS_ERR_JIT_SIGN_SIZE; } @@ -253,13 +252,12 @@ int32_t JitCodeSigner::ValidateCodeCopy(Instr *jitMemory, "[%s]: validate insn(%x) without context failed at index = " \ "%x, signature(%x) != wanted(%x)", __func__, insn, index * INSTRUCTION_SIZE, signature, signTable_[index]); - if (ret == -1) { free(buffer); buffer = nullptr; return CS_ERR_LOG_TOO_LONG; } - deferredLogs.emplace_back(DeferredLog{buffer, LOG_ERROR}); + deferredLogs.emplace_back(DeferredLog{buffer}); #endif #ifndef JIT_CODE_SIGN_PERMISSIVE return CS_ERR_VALIDATE_CODE; diff --git a/utils/include/log.h b/utils/include/log.h index e36f667..5bae85a 100644 --- a/utils/include/log.h +++ b/utils/include/log.h @@ -35,12 +35,6 @@ #define LOG_ERROR(fmt, ...) HILOG_ERROR(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) #define LOG_FATAL(fmt, ...) HILOG_FATAL(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -/* Deferred logs have variable level, and their caller must be recorded - when the log is generated, not when this macro is invoked. - * LOG_LEVEL is used as the enum name. -*/ -#define LOG_LEVELED(level, ...) HILOG_IMPL(LOG_CORE, level, LOG_DOMAIN, LOG_TAG, ##__VA_ARGS__) - #else // LOG_RUST namespace OHOS { namespace Security { -- Gitee