From 3c52037560a28744696578c00d9631052bd86882 Mon Sep 17 00:00:00 2001 From: xiaojiazhu <258828110.@qq.com> Date: Fri, 8 Sep 2023 16:53:44 -0700 Subject: [PATCH] Fix clang-tidy warnings. --- build/global_config.cmake | 2 +- hal/CMakeLists.txt | 10 +++++++--- hal/abstract/IHalCpp.cpp | 2 +- hal/src/Hal.c | 6 +++--- hal/src/HalCpp.cpp | 2 +- hal/src/HalMakePtr.cpp | 2 +- test/utils/Log/src/ILogTest.cpp | 4 +--- utils/CMakeLists.txt | 2 +- utils/Log/abstract/ILog.cpp | 4 ++-- utils/Log/include/ILog.h | 9 ++++----- utils/Log/include/ILogCpp.h | 2 +- utils/Log/src/LogEasylogging.cpp | 2 +- utils/Log/src/LogEasylogging.h | 2 +- utils/StatusCode/src/StatusCode.c | 2 +- 14 files changed, 26 insertions(+), 25 deletions(-) diff --git a/build/global_config.cmake b/build/global_config.cmake index 82facb6f..ebe12d3d 100755 --- a/build/global_config.cmake +++ b/build/global_config.cmake @@ -23,7 +23,7 @@ llvm-twine-local,\ misc-confusable-identifiers,\ misc-definitions-in-headers,\ misc-header-include-cycle,\ -misc-include-cleaner,\ +-misc-include-cleaner,\ misc-misleading-bidirectional,\ misc-misleading-identifier,\ misc-misplaced-const,\ diff --git a/hal/CMakeLists.txt b/hal/CMakeLists.txt index f256d7e3..0a96fec5 100644 --- a/hal/CMakeLists.txt +++ b/hal/CMakeLists.txt @@ -32,11 +32,15 @@ target_link_libraries(${IMPL_TARGET} ${ABSTRACT_TARGET}) if ("${CLANG_TIDY_SUPPORT}" MATCHES "true") add_custom_target( hal_code_check - COMMAND ${CMAKE_SOURCE_DIR_IPCSDK}/tools/clang-tidy/clang-tidy + # COMMAND ${CMAKE_SOURCE_DIR_IPCSDK}/tools/clang-tidy/clang-tidy + COMMAND ${CLANG_TIDY_EXE} -checks='${CLANG_TIDY_CHECKS}' - -header-filter=.* - -system-headers + # -header-filter=.* + # -system-headers + --header-filter=.* + --system-headers=false ${ABSTRACT_SRC_FILES} + ${IMPL_SRC_FILES} ${CLANG_TIDY_CONFIG} -p ${CMAKE_SOURCE_DIR_IPCSDK}/cmake-shell-linux # -- -I /usr/include/linux/ -X c++ diff --git a/hal/abstract/IHalCpp.cpp b/hal/abstract/IHalCpp.cpp index 2bdc0840..a18cfd4b 100644 --- a/hal/abstract/IHalCpp.cpp +++ b/hal/abstract/IHalCpp.cpp @@ -1,5 +1,5 @@ #include "IHalCpp.h" -#include "Log.h" +#include "ILog.h" // #include #include std::shared_ptr &IHalCpp::GetInstance(std::shared_ptr *impl) diff --git a/hal/src/Hal.c b/hal/src/Hal.c index 85c1c325..c175032f 100644 --- a/hal/src/Hal.c +++ b/hal/src/Hal.c @@ -1,5 +1,5 @@ #include "Hal.h" -#include "Log.h" +#include "ILog.h" #include #include static void HalFree(IHal *object) @@ -35,9 +35,9 @@ StatusCode NewHal(Hal **hal) LogError("NewHal failed.\n"); return CreateStatusCode(STATUS_CODE_NOT_OK); } - else + // else { HalImplInit(*hal); + return CreateStatusCode(STATUS_CODE_OK); } - return CreateStatusCode(STATUS_CODE_OK); } \ No newline at end of file diff --git a/hal/src/HalCpp.cpp b/hal/src/HalCpp.cpp index 23a6af02..33e4aeb8 100644 --- a/hal/src/HalCpp.cpp +++ b/hal/src/HalCpp.cpp @@ -1,5 +1,5 @@ #include "HalCpp.h" -#include "Log.h" +#include "ILog.h" StatusCode HalCpp::Init(void) { LogInfo("HalCpp::Init\n"); diff --git a/hal/src/HalMakePtr.cpp b/hal/src/HalMakePtr.cpp index 12ca0f3e..104dd733 100644 --- a/hal/src/HalMakePtr.cpp +++ b/hal/src/HalMakePtr.cpp @@ -1,7 +1,7 @@ #include "HalMakePtr.h" -#include "Log.h" #include "Hal.h" #include "HalCpp.h" +#include "ILog.h" StatusCode create_hal_module(void) { IHal *hal = NULL; diff --git a/test/utils/Log/src/ILogTest.cpp b/test/utils/Log/src/ILogTest.cpp index 19f0afd6..bb741e9b 100644 --- a/test/utils/Log/src/ILogTest.cpp +++ b/test/utils/Log/src/ILogTest.cpp @@ -3,16 +3,14 @@ #include namespace ILogTest { - // ../out/test/bin/ILogTest --gtest_filter=LogCTest.Demo + // ../out/test/bin/LogTest --gtest_filter=ILogTest.Demo TEST(ILogTest, Demo) { CreateLogModule(); ILogInit(LOG_INSTANCE_TYPE_END); - LogInfo("hello world."); LogError("create ... failed."); LogDebug("a = %d b = %s", 124, "apple"); - IHalUnInit(); DestroyLogModule(); } diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 1b7ece1b..aff8ddcb 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -1,5 +1,5 @@ # cmake_minimum_required(VERSION 2.8.0) -add_subdirectory(ReturnCode) +# add_subdirectory(ReturnCode) add_subdirectory(StatusCode) add_subdirectory(Log) diff --git a/utils/Log/abstract/ILog.cpp b/utils/Log/abstract/ILog.cpp index c4446cd5..0f2d0e5c 100644 --- a/utils/Log/abstract/ILog.cpp +++ b/utils/Log/abstract/ILog.cpp @@ -1,7 +1,7 @@ #include "ILog.h" #include "ILogCpp.h" #include -static void ILogInitCallBack(ILog *object, const LogInstance log) +static void ILogInitCallBack(ILog *object, const int log) { return ILogCpp::GetInstance()->Init(log); } @@ -36,7 +36,7 @@ void NewILog(ILog **object) memcpy(*object, &default_log, sizeof(ILog)); return; } -void ResetHalImpl(ILog *impl) +void ResetLogImpl(ILog *impl) { log_instance->free(log_instance); log_instance = impl; diff --git a/utils/Log/include/ILog.h b/utils/Log/include/ILog.h index dacfbd10..c146baec 100644 --- a/utils/Log/include/ILog.h +++ b/utils/Log/include/ILog.h @@ -24,7 +24,6 @@ extern "C" { LOG_SERIAL_PRINT = 0, // for serial print. LOG_EASYLOGGING, // for easylogging++. - LOG_CAPTURE_LOG, // capture log to other who need it LOG_INSTANCE_TYPE_END }; #define LogVerbose(...) GetLogIntance()->printf(GetLogIntance(), __FUNCTION__, __LINE__, LOG_TYPE_VERBOSE, __VA_ARGS__) @@ -36,19 +35,19 @@ extern "C" typedef struct i_log ILog; typedef struct i_log { - void (*init)(ILog *, const LogInstance); + void (*init)(ILog *, const int); void (*free)(ILog *); int (*printf)(ILog *, const char *, const int, const int, const char *, ...); void (*un_init)(ILog *); } ILog; ILog *GetLogIntance(void); void NewILog(ILog **object); - void ResetHalImpl(ILog *impl); - static inline void ILogInit(const LogInstance log) + void ResetLogImpl(ILog *impl); + static inline void ILogInit(const int log) { return GetLogIntance()->init(GetLogIntance(), log); } - static inline void IHalUnInit(void) + static inline void ILolUnInit(void) { return GetLogIntance()->un_init(GetLogIntance()); } diff --git a/utils/Log/include/ILogCpp.h b/utils/Log/include/ILogCpp.h index 4e8f438f..e8b1c1fa 100644 --- a/utils/Log/include/ILogCpp.h +++ b/utils/Log/include/ILogCpp.h @@ -8,7 +8,7 @@ public: ILogCpp() = default; virtual ~ILogCpp() = default; static std::shared_ptr &GetInstance(std::shared_ptr *impl = nullptr); - virtual void Init(const LogInstance &log) {} + virtual void Init(const int &log) {} virtual void UnInit(void) {} }; #endif \ No newline at end of file diff --git a/utils/Log/src/LogEasylogging.cpp b/utils/Log/src/LogEasylogging.cpp index c86c9921..4d6831ca 100644 --- a/utils/Log/src/LogEasylogging.cpp +++ b/utils/Log/src/LogEasylogging.cpp @@ -21,7 +21,7 @@ LogEasylogging::LogEasylogging(const LogSetting *setting) mMaxSize = setting->maxSize; } } -void LogEasylogging::Init(const LogInstance &log) +void LogEasylogging::Init(const int &log) { #if 0 el::Configurations conf("/home/xiaojiazhu/project/OS/OSThings/test/out/bin/default-logger.conf"); diff --git a/utils/Log/src/LogEasylogging.h b/utils/Log/src/LogEasylogging.h index 808d39ff..c5826092 100644 --- a/utils/Log/src/LogEasylogging.h +++ b/utils/Log/src/LogEasylogging.h @@ -6,7 +6,7 @@ class LogEasylogging : public ILogCpp public: LogEasylogging(const LogSetting *setting); virtual ~LogEasylogging() = default; - void Init(const LogInstance &log) override; + void Init(const int &log) override; void UnInit(void) override; // bool IsWorking(); // override; // int Log(const char *buff); // override; diff --git a/utils/StatusCode/src/StatusCode.c b/utils/StatusCode/src/StatusCode.c index 4c6c572d..60ac928e 100644 --- a/utils/StatusCode/src/StatusCode.c +++ b/utils/StatusCode/src/StatusCode.c @@ -1,5 +1,5 @@ #include "StatusCode.h" -#include "Log.h" +#include "ILog.h" #include #include static const char *StatusCodeString[STATUS_CODE_END + 1] = {