From: Dongik Lee Date: Fri, 30 May 2025 04:57:04 +0000 (+0900) Subject: Fix duplicate variable name(local vs global) with -Werror=shadow build option X-Git-Tag: accepted/tizen/unified/20250604.163030^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Faccepted%2Ftizen_unified_x;p=platform%2Fhal%2Fapi%2Fsecurity.git Fix duplicate variable name(local vs global) with -Werror=shadow build option Change-Id: I908bf8db2819da9e458884d947dacb27a0884977 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ed8757..2d2626b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) INCLUDE(FindPkgConfig) PKG_CHECK_MODULES(SECURITY_DEPS REQUIRED hal-api-common) -SET(EXTRA_CFLAGS "-Wall -Wextra -Werror -fvisibility=hidden -fPIC") +SET(EXTRA_CFLAGS "-Wall -Wextra -Werror -Werror=shadow -fvisibility=hidden -fPIC") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SECURITY_DEPS_CFLAGS} ${EXTRA_CFLAGS}") SET( diff --git a/haltest/CMakeLists.txt b/haltest/CMakeLists.txt index 7c465d2..1dcf5af 100644 --- a/haltest/CMakeLists.txt +++ b/haltest/CMakeLists.txt @@ -16,7 +16,7 @@ INCLUDE_DIRECTORIES(SYSTEM ${TEST_DEPS_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}) LINK_DIRECTORIES(${TEST_DEPS_LIBRARY_DIRS}) -SET(EXTRA_CFLAGS "-Wall -Wextra -Werror -fPIC") +SET(EXTRA_CFLAGS "-Wall -Wextra -Werror -Werror=shadow -fPIC") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") diff --git a/haltest/security-keys.cpp b/haltest/security-keys.cpp index c90ac47..07083b1 100644 --- a/haltest/security-keys.cpp +++ b/haltest/security-keys.cpp @@ -81,8 +81,8 @@ hal_security_keys_hash_algorithm_e sha256_hash = HAL_SECURITY_KEYS_HASH_ALGORITH void initialize_key_variables( const hal_security_keys_context_s context, - const std::string& alias, - const std::string& pwd, + const std::string& alias_data, + const std::string& password, hal_security_keys_data_s& iv, hal_security_keys_data_s& key_id, hal_security_keys_data_s& key_pwd, @@ -91,17 +91,17 @@ void initialize_key_variables( int ret; key_id = { - reinterpret_cast(const_cast(alias.c_str())), - alias.size() + reinterpret_cast(const_cast(alias_data.c_str())), + alias_data.size() }; ret = hal_security_keys_create_iv(context, &iv); EXPECT_EQ(ret, 0) << "Failed to create iv (" << ret << ")"; - if(!pwd.empty()) { + if(!password.empty()) { key_pwd = { - reinterpret_cast(const_cast(pwd.c_str())), - pwd.size() + reinterpret_cast(const_cast(password.c_str())), + password.size() }; } else { key_pwd = { NULL, 0 };