From 3f2bd025b460e5ac12a034abf4084dee24f25c6e Mon Sep 17 00:00:00 2001 From: Fancy code <258828110.@qq.com> Date: Mon, 17 Jun 2024 11:39:24 +0800 Subject: [PATCH 1/4] Improve:SharedData include cleaner. --- utils/SharedData/src/ISharedData.cpp | 4 ++++ utils/SharedData/src/SharedData.cpp | 3 +++ utils/SharedData/src/SharedDataCode.c | 2 ++ utils/SharedData/src/SharedDataImpl.cpp | 4 +++- utils/SharedData/src/SharedMemory.cpp | 3 +++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/utils/SharedData/src/ISharedData.cpp b/utils/SharedData/src/ISharedData.cpp index d5c18d3..0534b34 100644 --- a/utils/SharedData/src/ISharedData.cpp +++ b/utils/SharedData/src/ISharedData.cpp @@ -14,7 +14,11 @@ */ #include "ISharedData.h" #include "ILog.h" +#include "SharedData.h" #include "SharedDataImpl.h" // TODO: 互相包含,需要修改 +#include "StatusCode.h" +#include +#include #include void ISharedData::MakeSharedMemory(const unsigned int readableSize, const unsigned int writableSize) { diff --git a/utils/SharedData/src/SharedData.cpp b/utils/SharedData/src/SharedData.cpp index 211f204..cc3d235 100644 --- a/utils/SharedData/src/SharedData.cpp +++ b/utils/SharedData/src/SharedData.cpp @@ -15,6 +15,9 @@ #include "SharedData.h" #include "ILog.h" #include "ISharedData.h" +#include "StatusCode.h" +#include +#include static bool ObjectCheck(void *object) { if (nullptr == object) { diff --git a/utils/SharedData/src/SharedDataCode.c b/utils/SharedData/src/SharedDataCode.c index ea96da8..47b5be2 100644 --- a/utils/SharedData/src/SharedDataCode.c +++ b/utils/SharedData/src/SharedDataCode.c @@ -14,6 +14,8 @@ */ #include "SharedDataCode.h" #include "ILog.h" +#include "SharedData.h" +#include "StatusCode.h" #include static const char *StatusCodeString[SHARED_DATA_CODE_END - STATUS_CODE_END + 1] = { "SHARED_DATA_CODE_INIT_FAILED", "SHARED_DATA_CODE_WRONG_PEER_PARAMETERS", "SHARED_DATA_CODE_END"}; diff --git a/utils/SharedData/src/SharedDataImpl.cpp b/utils/SharedData/src/SharedDataImpl.cpp index a3dbdab..91227fb 100644 --- a/utils/SharedData/src/SharedDataImpl.cpp +++ b/utils/SharedData/src/SharedDataImpl.cpp @@ -14,9 +14,11 @@ */ #include "SharedDataImpl.h" #include "ILog.h" +#include "SharedData.h" #include "SharedDataCode.h" +#include "SharedMemory.h" +#include "StatusCode.h" #include -static const char *SHARED_DATA_NAME = "shared_data"; constexpr short THERE_TWO_USER_DATA_HEADER = 2; SharedDataImpl::SharedDataImpl(const SHARER_NAME &sharerName, const char *path, const int &projectId) : SharedMemory(path, projectId), mSharerName(sharerName) diff --git a/utils/SharedData/src/SharedMemory.cpp b/utils/SharedData/src/SharedMemory.cpp index 0f18784..d2295f5 100644 --- a/utils/SharedData/src/SharedMemory.cpp +++ b/utils/SharedData/src/SharedMemory.cpp @@ -15,13 +15,16 @@ #include "SharedMemory.h" #include "ILog.h" #include "LinuxApi.h" +#include "SharedData.h" #include "SharedDataCode.h" +#include "StatusCode.h" #include #include #include #include #include #include +#include #include constexpr int SHMGET_FAILED = -1; SharedMemory::SharedMemory(const char *path, const int &projectId) : mPath(path), mProjectId(projectId) From 509142a0fada78a9db4642198bbd0fc0bf3f389e Mon Sep 17 00:00:00 2001 From: Fancy code <258828110.@qq.com> Date: Mon, 17 Jun 2024 12:20:52 +0800 Subject: [PATCH 2/4] Improve:ConfigBase include cleaner. --- utils/ConfigBase/src/ConfigBase.cpp | 3 +++ utils/ConfigBase/src/ConfigBaseCode.c | 2 ++ utils/ConfigBase/src/ConfigBaseImpl.cpp | 9 ++++++++- utils/ConfigBase/src/IConfigBase.cpp | 3 +++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/utils/ConfigBase/src/ConfigBase.cpp b/utils/ConfigBase/src/ConfigBase.cpp index 4c1e54a..e9a1636 100644 --- a/utils/ConfigBase/src/ConfigBase.cpp +++ b/utils/ConfigBase/src/ConfigBase.cpp @@ -15,6 +15,9 @@ #include "ConfigBase.h" #include "IConfigBase.h" #include "ILog.h" +#include "StatusCode.h" +#include +#include static bool ObjectCheck(void *object) { if (nullptr == object) { diff --git a/utils/ConfigBase/src/ConfigBaseCode.c b/utils/ConfigBase/src/ConfigBaseCode.c index c6dac5a..3eca51a 100644 --- a/utils/ConfigBase/src/ConfigBaseCode.c +++ b/utils/ConfigBase/src/ConfigBaseCode.c @@ -13,7 +13,9 @@ * limitations under the License. */ #include "ConfigBaseCode.h" +#include "ConfigBase.h" #include "ILog.h" +#include "StatusCode.h" #include static const char *ConfigCodeString[CONFIG_CODE_END - STATUS_CODE_END + 1] = {"CONFIG_CODE_PARAM_NOT_EXIST", "CONFIG_CODE_END"}; diff --git a/utils/ConfigBase/src/ConfigBaseImpl.cpp b/utils/ConfigBase/src/ConfigBaseImpl.cpp index 4fe9e29..09fdffd 100644 --- a/utils/ConfigBase/src/ConfigBaseImpl.cpp +++ b/utils/ConfigBase/src/ConfigBaseImpl.cpp @@ -13,10 +13,16 @@ * limitations under the License. */ #include "ConfigBaseImpl.h" +#include "ConfigBase.h" #include "ConfigBaseCode.h" #include "ILog.h" +#include "StatusCode.h" +#include #include #include +#include +#include +#include #include constexpr int INVALID_RESULT = -1; @@ -38,7 +44,8 @@ bool ConfigBaseImpl::OpenConfigFile(void) if (FIEL_EXIST == access(mFileName.c_str(), F_OK)) { if (!config_read_file(&mCfg, mFileName.c_str())) { LogError("Read file failed[%s].\n", mFileName.c_str()); - fprintf(stderr, "%s:%d - %s\n", config_error_file(&mCfg), config_error_line(&mCfg), config_error_text(&mCfg)); + fprintf( + stderr, "%s:%d - %s\n", config_error_file(&mCfg), config_error_line(&mCfg), config_error_text(&mCfg)); return false; } } diff --git a/utils/ConfigBase/src/IConfigBase.cpp b/utils/ConfigBase/src/IConfigBase.cpp index 55086fb..de94df7 100644 --- a/utils/ConfigBase/src/IConfigBase.cpp +++ b/utils/ConfigBase/src/IConfigBase.cpp @@ -15,7 +15,10 @@ #include "IConfigBase.h" #include "ConfigBaseImpl.h" #include "ILog.h" +#include "StatusCode.h" #include +#include +#include bool IConfigBase::OpenConfigFile(void) { return false; From 833b69a823813589a35531997407596056147879 Mon Sep 17 00:00:00 2001 From: Fancy code <258828110.@qq.com> Date: Mon, 17 Jun 2024 12:24:59 +0800 Subject: [PATCH 3/4] Improve:KeyControl include cleaner. --- utils/KeyControl/src/KeyControl.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/KeyControl/src/KeyControl.cpp b/utils/KeyControl/src/KeyControl.cpp index 01ab7e0..7573194 100644 --- a/utils/KeyControl/src/KeyControl.cpp +++ b/utils/KeyControl/src/KeyControl.cpp @@ -14,6 +14,8 @@ */ #include "KeyControl.h" #include "ILog.h" +#include +#include constexpr long int KEY_PRESSING = 0; constexpr unsigned int NOT_A_HOLD_KEY_ACTION = 0; KeyControl::KeyControl() @@ -30,14 +32,17 @@ bool KeyControl::IsKeyPressing(void) } const std::string VKeyControl::GetKeyName(void) { + LogWarning("STATUS_CODE_VIRTUAL_FUNCTION\n"); return "undefine"; } unsigned int VKeyControl::GetStatusCheckPeriodMs(void) { + LogWarning("STATUS_CODE_VIRTUAL_FUNCTION\n"); return 0; } void VKeyControl::KeyEventTrigger(const std::string &keyName, const KeyEvent &event, const unsigned int &timeMs) { + LogWarning("STATUS_CODE_VIRTUAL_FUNCTION\n"); } void KeyControl::Init(void) { From 67d5e2014f9dd02f06614b7a1557263b9c01bda1 Mon Sep 17 00:00:00 2001 From: Fancy code <258828110.@qq.com> Date: Mon, 17 Jun 2024 12:32:12 +0800 Subject: [PATCH 4/4] Improve:LedControl and Log include cleaner. --- build/global_config.cmake | 4 ++-- utils/LedControl/src/LedControl.cpp | 3 +++ utils/Log/src/Log.cpp | 26 +++++++++++--------------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/build/global_config.cmake b/build/global_config.cmake index 7af1883..2cb9a11 100755 --- a/build/global_config.cmake +++ b/build/global_config.cmake @@ -27,7 +27,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,\ @@ -55,7 +55,7 @@ set(CLANG_FORMAT_FILE "LLVM ${CMAKE_SOURCE_DIR_IPCSDK}/tools/clang-format/.clang if(${LINUX_TEST} MATCHES "true") set(CLANG_TIDY_SUPPORT "true") set(CLANG_FORMAT_SUPPORT "true") - set(COMPILE_IMPROVE_SUPPORT "false") # 开启后每次编译可能会很慢 + set(COMPILE_IMPROVE_SUPPORT "true") # 开启后每次编译可能会很慢 set(LLVM_PATH "$ENV{HOME}/llvm-project") endif() # ------------ build clang-tools end ------------ # diff --git a/utils/LedControl/src/LedControl.cpp b/utils/LedControl/src/LedControl.cpp index 3191ae7..d4e8fa4 100644 --- a/utils/LedControl/src/LedControl.cpp +++ b/utils/LedControl/src/LedControl.cpp @@ -14,7 +14,10 @@ */ #include "LedControl.h" #include "ILog.h" +#include "StatusCode.h" #include +#include +#include StatusCode VSingleControl::GetLedState(LedState &state) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); diff --git a/utils/Log/src/Log.cpp b/utils/Log/src/Log.cpp index 0bc7938..40ac077 100644 --- a/utils/Log/src/Log.cpp +++ b/utils/Log/src/Log.cpp @@ -3,9 +3,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -13,21 +13,21 @@ * limitations under the License. */ #include "Log.h" +#include "ILog.h" #include "ILogCpp.h" #include #include -#include -#include +#include #include static void LogFree(ILog *object) { printf("log instance free.\n"); - if (object) - { + if (object) { free(object); } } -static int LogPrintf(ILog *object, const char *function, const int line, const enum LogType type, const char *format, ...) +static int LogPrintf(ILog *object, const char *function, const int line, const enum LogType type, const char *format, + ...) { // TODO: // LogTypeToString(type); @@ -40,8 +40,7 @@ static int LogPrintf(ILog *object, const char *function, const int line, const e va_start(vargs, format); int len = vsnprintf(buff + headLen, SEND_TRACE_BUFF_SIZE - headLen, format, vargs); va_end(vargs); - switch (type) - { + switch (type) { case LOG_TYPE_INFORMATION: ILogCpp::GetInstance()->InFo(buff); break; @@ -75,16 +74,13 @@ static void LogImplInit(Log *log) } void NewLog(Log **log) { - if (!log) - { + if (!log) { printf("STATUS_CODE_INVALID_PARAMENTER\n"); return; } - if (!(*log)) - { + if (!(*log)) { *log = (Log *)malloc(sizeof(Log)); - if (*log) - { + if (*log) { printf("NewLog succeed.\n"); NewILog((ILog **)log); LogImplInit(*log);