Fix clang-tidy warnings.
This commit is contained in:
parent
076a6da052
commit
3c52037560
|
@ -23,7 +23,7 @@ llvm-twine-local,\
|
||||||
misc-confusable-identifiers,\
|
misc-confusable-identifiers,\
|
||||||
misc-definitions-in-headers,\
|
misc-definitions-in-headers,\
|
||||||
misc-header-include-cycle,\
|
misc-header-include-cycle,\
|
||||||
misc-include-cleaner,\
|
-misc-include-cleaner,\
|
||||||
misc-misleading-bidirectional,\
|
misc-misleading-bidirectional,\
|
||||||
misc-misleading-identifier,\
|
misc-misleading-identifier,\
|
||||||
misc-misplaced-const,\
|
misc-misplaced-const,\
|
||||||
|
|
|
@ -32,11 +32,15 @@ target_link_libraries(${IMPL_TARGET} ${ABSTRACT_TARGET})
|
||||||
if ("${CLANG_TIDY_SUPPORT}" MATCHES "true")
|
if ("${CLANG_TIDY_SUPPORT}" MATCHES "true")
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
hal_code_check
|
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}'
|
-checks='${CLANG_TIDY_CHECKS}'
|
||||||
-header-filter=.*
|
# -header-filter=.*
|
||||||
-system-headers
|
# -system-headers
|
||||||
|
--header-filter=.*
|
||||||
|
--system-headers=false
|
||||||
${ABSTRACT_SRC_FILES}
|
${ABSTRACT_SRC_FILES}
|
||||||
|
${IMPL_SRC_FILES}
|
||||||
${CLANG_TIDY_CONFIG}
|
${CLANG_TIDY_CONFIG}
|
||||||
-p ${CMAKE_SOURCE_DIR_IPCSDK}/cmake-shell-linux
|
-p ${CMAKE_SOURCE_DIR_IPCSDK}/cmake-shell-linux
|
||||||
# -- -I /usr/include/linux/ -X c++
|
# -- -I /usr/include/linux/ -X c++
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "IHalCpp.h"
|
#include "IHalCpp.h"
|
||||||
#include "Log.h"
|
#include "ILog.h"
|
||||||
// #include <thread>
|
// #include <thread>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
std::shared_ptr<IHalCpp> &IHalCpp::GetInstance(std::shared_ptr<IHalCpp> *impl)
|
std::shared_ptr<IHalCpp> &IHalCpp::GetInstance(std::shared_ptr<IHalCpp> *impl)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "Hal.h"
|
#include "Hal.h"
|
||||||
#include "Log.h"
|
#include "ILog.h"
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
static void HalFree(IHal *object)
|
static void HalFree(IHal *object)
|
||||||
|
@ -35,9 +35,9 @@ StatusCode NewHal(Hal **hal)
|
||||||
LogError("NewHal failed.\n");
|
LogError("NewHal failed.\n");
|
||||||
return CreateStatusCode(STATUS_CODE_NOT_OK);
|
return CreateStatusCode(STATUS_CODE_NOT_OK);
|
||||||
}
|
}
|
||||||
else
|
// else
|
||||||
{
|
{
|
||||||
HalImplInit(*hal);
|
HalImplInit(*hal);
|
||||||
}
|
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
#include "HalCpp.h"
|
#include "HalCpp.h"
|
||||||
#include "Log.h"
|
#include "ILog.h"
|
||||||
StatusCode HalCpp::Init(void)
|
StatusCode HalCpp::Init(void)
|
||||||
{
|
{
|
||||||
LogInfo("HalCpp::Init\n");
|
LogInfo("HalCpp::Init\n");
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "HalMakePtr.h"
|
#include "HalMakePtr.h"
|
||||||
#include "Log.h"
|
|
||||||
#include "Hal.h"
|
#include "Hal.h"
|
||||||
#include "HalCpp.h"
|
#include "HalCpp.h"
|
||||||
|
#include "ILog.h"
|
||||||
StatusCode create_hal_module(void)
|
StatusCode create_hal_module(void)
|
||||||
{
|
{
|
||||||
IHal *hal = NULL;
|
IHal *hal = NULL;
|
||||||
|
|
|
@ -3,16 +3,14 @@
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
namespace ILogTest
|
namespace ILogTest
|
||||||
{
|
{
|
||||||
// ../out/test/bin/ILogTest --gtest_filter=LogCTest.Demo
|
// ../out/test/bin/LogTest --gtest_filter=ILogTest.Demo
|
||||||
TEST(ILogTest, Demo)
|
TEST(ILogTest, Demo)
|
||||||
{
|
{
|
||||||
CreateLogModule();
|
CreateLogModule();
|
||||||
ILogInit(LOG_INSTANCE_TYPE_END);
|
ILogInit(LOG_INSTANCE_TYPE_END);
|
||||||
|
|
||||||
LogInfo("hello world.");
|
LogInfo("hello world.");
|
||||||
LogError("create ... failed.");
|
LogError("create ... failed.");
|
||||||
LogDebug("a = %d b = %s", 124, "apple");
|
LogDebug("a = %d b = %s", 124, "apple");
|
||||||
|
|
||||||
IHalUnInit();
|
IHalUnInit();
|
||||||
DestroyLogModule();
|
DestroyLogModule();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
# cmake_minimum_required(VERSION 2.8.0)
|
# cmake_minimum_required(VERSION 2.8.0)
|
||||||
add_subdirectory(ReturnCode)
|
# add_subdirectory(ReturnCode)
|
||||||
add_subdirectory(StatusCode)
|
add_subdirectory(StatusCode)
|
||||||
add_subdirectory(Log)
|
add_subdirectory(Log)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
#include "ILogCpp.h"
|
#include "ILogCpp.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
static void ILogInitCallBack(ILog *object, const LogInstance log)
|
static void ILogInitCallBack(ILog *object, const int log)
|
||||||
{
|
{
|
||||||
return ILogCpp::GetInstance()->Init(log);
|
return ILogCpp::GetInstance()->Init(log);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ void NewILog(ILog **object)
|
||||||
memcpy(*object, &default_log, sizeof(ILog));
|
memcpy(*object, &default_log, sizeof(ILog));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
void ResetHalImpl(ILog *impl)
|
void ResetLogImpl(ILog *impl)
|
||||||
{
|
{
|
||||||
log_instance->free(log_instance);
|
log_instance->free(log_instance);
|
||||||
log_instance = impl;
|
log_instance = impl;
|
||||||
|
|
|
@ -24,7 +24,6 @@ extern "C"
|
||||||
{
|
{
|
||||||
LOG_SERIAL_PRINT = 0, // for serial print.
|
LOG_SERIAL_PRINT = 0, // for serial print.
|
||||||
LOG_EASYLOGGING, // for easylogging++.
|
LOG_EASYLOGGING, // for easylogging++.
|
||||||
LOG_CAPTURE_LOG, // capture log to other who need it
|
|
||||||
LOG_INSTANCE_TYPE_END
|
LOG_INSTANCE_TYPE_END
|
||||||
};
|
};
|
||||||
#define LogVerbose(...) GetLogIntance()->printf(GetLogIntance(), __FUNCTION__, __LINE__, LOG_TYPE_VERBOSE, __VA_ARGS__)
|
#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 ILog;
|
||||||
typedef struct i_log
|
typedef struct i_log
|
||||||
{
|
{
|
||||||
void (*init)(ILog *, const LogInstance);
|
void (*init)(ILog *, const int);
|
||||||
void (*free)(ILog *);
|
void (*free)(ILog *);
|
||||||
int (*printf)(ILog *, const char *, const int, const int, const char *, ...);
|
int (*printf)(ILog *, const char *, const int, const int, const char *, ...);
|
||||||
void (*un_init)(ILog *);
|
void (*un_init)(ILog *);
|
||||||
} ILog;
|
} ILog;
|
||||||
ILog *GetLogIntance(void);
|
ILog *GetLogIntance(void);
|
||||||
void NewILog(ILog **object);
|
void NewILog(ILog **object);
|
||||||
void ResetHalImpl(ILog *impl);
|
void ResetLogImpl(ILog *impl);
|
||||||
static inline void ILogInit(const LogInstance log)
|
static inline void ILogInit(const int log)
|
||||||
{
|
{
|
||||||
return GetLogIntance()->init(GetLogIntance(), log);
|
return GetLogIntance()->init(GetLogIntance(), log);
|
||||||
}
|
}
|
||||||
static inline void IHalUnInit(void)
|
static inline void ILolUnInit(void)
|
||||||
{
|
{
|
||||||
return GetLogIntance()->un_init(GetLogIntance());
|
return GetLogIntance()->un_init(GetLogIntance());
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ public:
|
||||||
ILogCpp() = default;
|
ILogCpp() = default;
|
||||||
virtual ~ILogCpp() = default;
|
virtual ~ILogCpp() = default;
|
||||||
static std::shared_ptr<ILogCpp> &GetInstance(std::shared_ptr<ILogCpp> *impl = nullptr);
|
static std::shared_ptr<ILogCpp> &GetInstance(std::shared_ptr<ILogCpp> *impl = nullptr);
|
||||||
virtual void Init(const LogInstance &log) {}
|
virtual void Init(const int &log) {}
|
||||||
virtual void UnInit(void) {}
|
virtual void UnInit(void) {}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
|
@ -21,7 +21,7 @@ LogEasylogging::LogEasylogging(const LogSetting *setting)
|
||||||
mMaxSize = setting->maxSize;
|
mMaxSize = setting->maxSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void LogEasylogging::Init(const LogInstance &log)
|
void LogEasylogging::Init(const int &log)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
el::Configurations conf("/home/xiaojiazhu/project/OS/OSThings/test/out/bin/default-logger.conf");
|
el::Configurations conf("/home/xiaojiazhu/project/OS/OSThings/test/out/bin/default-logger.conf");
|
||||||
|
|
|
@ -6,7 +6,7 @@ class LogEasylogging : public ILogCpp
|
||||||
public:
|
public:
|
||||||
LogEasylogging(const LogSetting *setting);
|
LogEasylogging(const LogSetting *setting);
|
||||||
virtual ~LogEasylogging() = default;
|
virtual ~LogEasylogging() = default;
|
||||||
void Init(const LogInstance &log) override;
|
void Init(const int &log) override;
|
||||||
void UnInit(void) override;
|
void UnInit(void) override;
|
||||||
// bool IsWorking(); // override;
|
// bool IsWorking(); // override;
|
||||||
// int Log(const char *buff); // override;
|
// int Log(const char *buff); // override;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "StatusCode.h"
|
#include "StatusCode.h"
|
||||||
#include "Log.h"
|
#include "ILog.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
static const char *StatusCodeString[STATUS_CODE_END + 1] = {
|
static const char *StatusCodeString[STATUS_CODE_END + 1] = {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user