From fba0f9234e83ecf0b2c0b2bd5ea249903434d0ba Mon Sep 17 00:00:00 2001 From: s_c_c Date: Tue, 12 Mar 2024 16:27:08 +0800 Subject: [PATCH] Fix compile errors for embedded (cherry picked from commit 4ecfed4395e4c910ac739f7939db092e0b444ff7) --- ...feat-for-embedded-comment-out-os_log.patch | 27 +++++++++++ ...-feat-for-embedded-fix-unused-errors.patch | 48 +++++++++++++++++++ hilog.spec | 7 ++- 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 0005-feat-for-embedded-comment-out-os_log.patch create mode 100644 0006-feat-for-embedded-fix-unused-errors.patch diff --git a/0005-feat-for-embedded-comment-out-os_log.patch b/0005-feat-for-embedded-comment-out-os_log.patch new file mode 100644 index 0000000..206fb18 --- /dev/null +++ b/0005-feat-for-embedded-comment-out-os_log.patch @@ -0,0 +1,27 @@ +From 002900776aae7d7bdf1025d118ce59ca2cf316b0 Mon Sep 17 00:00:00 2001 +From: s_c_c +Date: Tue, 12 Mar 2024 16:07:04 +0800 +Subject: [PATCH 1/2] feat for embedded comment out os_log + +--- + interfaces/native/innerkits/include/hilog_base/log_base.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/interfaces/native/innerkits/include/hilog_base/log_base.h b/interfaces/native/innerkits/include/hilog_base/log_base.h +index 7e06e64..9fbc992 100644 +--- a/interfaces/native/innerkits/include/hilog_base/log_base.h ++++ b/interfaces/native/innerkits/include/hilog_base/log_base.h +@@ -56,8 +56,8 @@ typedef enum { + LOG_LEVEL_MAX, + } LogLevel; + +-int HiLogBasePrint(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) +- __attribute__((__format__(os_log, 5, 6))); ++int HiLogBasePrint(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...); ++ // __attribute__((__format__(os_log, 5, 6))); + + #define HILOG_BASE_DEBUG(type, ...) ((void)HiLogBasePrint((type), LOG_DEBUG, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) + +-- +2.20.1 (Apple Git-117) + diff --git a/0006-feat-for-embedded-fix-unused-errors.patch b/0006-feat-for-embedded-fix-unused-errors.patch new file mode 100644 index 0000000..c682d4a --- /dev/null +++ b/0006-feat-for-embedded-fix-unused-errors.patch @@ -0,0 +1,48 @@ +From 874b94e548e6a66264d5fa5b35c272a5b64aab35 Mon Sep 17 00:00:00 2001 +From: s_c_c +Date: Tue, 12 Mar 2024 16:11:06 +0800 +Subject: [PATCH 2/2] feat for embedded fix unused errors + +--- + frameworks/libhilog/hilog.cpp | 3 +-- + frameworks/libhilog/utils/log_utils.cpp | 3 ++- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/frameworks/libhilog/hilog.cpp b/frameworks/libhilog/hilog.cpp +index 8da82c5..b42f601 100644 +--- a/frameworks/libhilog/hilog.cpp ++++ b/frameworks/libhilog/hilog.cpp +@@ -76,7 +76,6 @@ int HiLogPrintArgs(const LogType type, const LogLevel level, const unsigned int + char buf[MAX_LOG_LEN] = {0}; + char *logBuf = buf; + int traceBufLen = 0; +- int ret; + bool priv = false; + + #ifdef __clang__ +@@ -88,7 +87,7 @@ int HiLogPrintArgs(const LogType type, const LogLevel level, const unsigned int + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wformat-nonliteral" + #endif +- ret = vsnprintfp_s(logBuf, MAX_LOG_LEN - traceBufLen, MAX_LOG_LEN - traceBufLen - 1, priv, fmt, ap); ++ (void)vsnprintfp_s(logBuf, MAX_LOG_LEN - traceBufLen, MAX_LOG_LEN - traceBufLen - 1, priv, fmt, ap); + #ifdef __clang__ + #pragma clang diagnostic pop + #elif __GNUC__ +diff --git a/frameworks/libhilog/utils/log_utils.cpp b/frameworks/libhilog/utils/log_utils.cpp +index af130c4..0ff618f 100644 +--- a/frameworks/libhilog/utils/log_utils.cpp ++++ b/frameworks/libhilog/utils/log_utils.cpp +@@ -494,7 +494,8 @@ void PrintErrorno(int err) + constexpr int bufSize = 256; + char buf[bufSize] = { 0 }; + #ifndef __WINDOWS__ +- (void)strerror_r(err, buf, bufSize); ++ char *ret = strerror_r(err, buf, bufSize); ++ (void)ret; + #else + (void)strerror_s(buf, bufSize, err); + #endif +-- +2.20.1 (Apple Git-117) + diff --git a/hilog.spec b/hilog.spec index 5d70774..09d9bbc 100644 --- a/hilog.spec +++ b/hilog.spec @@ -5,7 +5,7 @@ Name: hilog Version: 1.0.0 -Release: 2 +Release: 3 Summary: OpenEuler supports hilog for distributed softbus capability License: Apache License 2.0 Url: https://gitee.com/openharmony/hiviewdfx_hilog @@ -14,6 +14,8 @@ Patch0000: 0001-init-and-adapt-to-openeuler.patch Patch0001: 0002-fix-build-gn-files-config.patch Patch0002: 0003-feat-set-priv-false.patch Patch0003: 0004-close-private-print-in-hilog.cpp-file.patch +Patch0005: 0005-feat-for-embedded-comment-out-os_log.patch +Patch0006: 0006-feat-for-embedded-fix-unused-errors.patch BuildRequires: distributed-build, libboundscheck,libatomic Requires: libboundscheck, libatomic @@ -82,6 +84,9 @@ install -m 554 %{hilog_dir}/hilog/interfaces/native/innerkits/include/hilog_base %changelog +* Tue Mar 12 2024 s_c_c - 1.0.0-3 +- Fix compile errors for embedded. + * Mon Jul 31 2023 Peng He - 1.0.0-2 - Close private print in hilog.cpp file. -- Gitee