From b603c08f5c11a2f84f47877e4686a75efd59777c Mon Sep 17 00:00:00 2001 From: heppen Date: Sat, 22 Jun 2024 10:47:37 +0800 Subject: [PATCH 1/2] build with asan --- .gitignore | 2 +- CMakeLists.txt | 9 +++++++++ build.sh | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7e4e261..10ebe3c 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,4 @@ tags pwrapic/gtest/lib pwrapic/gtest/include/gtest .cache -compile_commands.json \ No newline at end of file +compile_commands.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c762f1..85347ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,15 @@ if(DEFINED RELEASE_MODE) add_definitions(-DRELEASE_MODE=${RELEASE_MODE}) endif() +option(ENABLE_ASAN "Enable Address Sanitizer" OFF) + +if(ENABLE_ASAN) + message(STATUS "AddressSanitizer enabled") + # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined") + set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fsanitize=address") +endif() + add_subdirectory(pwrapic/src) add_subdirectory(pwrapis/src) diff --git a/build.sh b/build.sh index c0a4498..0c6ee9c 100755 --- a/build.sh +++ b/build.sh @@ -7,6 +7,10 @@ mkdir build cd build if [[ "$1" == "release" ]];then cmake -DRELEASE_MODE="true" .. +elif [[ "$1" == "export" ]]; then # export compile database + cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .. +elif [[ "$1" == "asan" ]]; then + cmake -DENABLE_ASAN=ON .. else cmake .. fi -- Gitee From 38f39f6c0ae65417da6378dddac764d54b39d90a Mon Sep 17 00:00:00 2001 From: heppen Date: Tue, 26 Nov 2024 17:19:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?SetSmartGridLevel=E6=89=93=E5=8D=B0=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pwrapic/src/pwrproc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pwrapic/src/pwrproc.c b/pwrapic/src/pwrproc.c index 2e90e6b..0fbce86 100644 --- a/pwrapic/src/pwrproc.c +++ b/pwrapic/src/pwrproc.c @@ -284,9 +284,9 @@ int SetSmartGridLevel(const PWR_PROC_SmartGridProcs *sgProcs) int ret = SendReqAndWaitForRsp(input, output); if (ret != PWR_SUCCESS) { - PwrLog(ERROR, "SetSmartGridState failed. ret:%d", ret); + PwrLog(ERROR, "SetSmartGridLevel failed. ret:%d", ret); } else { - PwrLog(DEBUG, "SetSmartGridState succeed."); + PwrLog(DEBUG, "SetSmartGridLevel succeed."); } return ret; } -- Gitee