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] 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);