diff options
author | ypostolov <ypostolov@luxoft.com> | 2020-01-09 20:01:14 +0200 |
---|---|---|
committer | yurii <ypostolov> | 2020-03-26 15:02:49 +0200 |
commit | dd85d888fec494b6b07d5d19c93b3c8257919807 (patch) | |
tree | 075a3636157861b5af3562723d81c749887567ab | |
parent | e8050e0a2957cab5592f774435458cbf597c28dc (diff) | |
download | sdl_core-dd85d888fec494b6b07d5d19c93b3c8257919807.tar.gz |
fix cppcheck issues in component config_profile
4 files changed, 9 insertions, 5 deletions
diff --git a/src/components/config_profile/src/ini_file.cc b/src/components/config_profile/src/ini_file.cc index 024c75de3e..9fa0540613 100644 --- a/src/components/config_profile/src/ini_file.cc +++ b/src/components/config_profile/src/ini_file.cc @@ -152,6 +152,7 @@ char* ini_read_value(const char* fname, return NULL; } +// cppcheck-suppress unusedFunction char ini_write_value(const char* fname, const char* chapter, const char* item, @@ -186,11 +187,9 @@ char ini_write_value(const char* fname, #if USE_MKSTEMP { const char* temp_str = "./"; - int32_t fd = -1; if (temp_str) { snprintf(temp_fname, PATH_MAX, "%s/ini.XXXXXX", temp_str); - - fd = mkstemp(temp_fname); + int32_t fd = mkstemp(temp_fname); if (-1 == fd) { fclose(rd_fp); return FALSE; @@ -289,7 +288,6 @@ char ini_write_value(const char* fname, Ini_search_id ini_parse_line(const char* line, const char* tag, char* value) { const char* line_ptr; - char* temp_ptr; char temp_str[INI_LINE_LEN] = ""; *temp_str = '\0'; @@ -332,7 +330,7 @@ Ini_search_id ini_parse_line(const char* line, const char* tag, char* value) { return INI_NOTHING; snprintf(temp_str, INI_LINE_LEN, "%s", line_ptr); - temp_ptr = strrchr(temp_str, ']'); + char* temp_ptr = strrchr(temp_str, ']'); if (NULL == temp_ptr) { return INI_NOTHING; } else { diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index 3037b66fdd..587536689a 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -1717,6 +1717,7 @@ void Profile::UpdateValues() { std::string help_prompt_value; if (ReadValue(&help_prompt_value, kGlobalPropertiesSection, kHelpPromptKey)) { char* str = NULL; + // cppcheck-suppress redundantAssignment str = strtok(const_cast<char*>(help_prompt_value.c_str()), ","); while (str != NULL) { // Default prompt should have delimiter included for each item @@ -1737,6 +1738,7 @@ void Profile::UpdateValues() { if (ReadValue( &timeout_prompt_value, kGlobalPropertiesSection, kTimeoutPromptKey)) { char* str = NULL; + // cppcheck-suppress redundantAssignment str = strtok(const_cast<char*>(timeout_prompt_value.c_str()), ","); while (str != NULL) { // Default prompt should have delimiter included for each item @@ -1762,6 +1764,7 @@ void Profile::UpdateValues() { std::string vr_help_command_value; if (ReadValue(&vr_help_command_value, kVrCommandsSection, kHelpCommandKey)) { char* str = NULL; + // cppcheck-suppress redundantAssignment str = strtok(const_cast<char*>(vr_help_command_value.c_str()), ","); while (str != NULL) { const std::string vr_item = str; @@ -1845,6 +1848,7 @@ void Profile::UpdateValues() { kMainSection, kSupportedDiagModesKey)) { char* str = NULL; + // cppcheck-suppress redundantAssignment str = strtok(const_cast<char*>(supported_diag_modes_value.c_str()), ","); while (str != NULL) { errno = 0; diff --git a/src/components/config_profile/test/ini_file_test.cc b/src/components/config_profile/test/ini_file_test.cc index ca4f2fc849..d96476676e 100644 --- a/src/components/config_profile/test/ini_file_test.cc +++ b/src/components/config_profile/test/ini_file_test.cc @@ -40,6 +40,7 @@ namespace profile_test { using namespace ::profile; +// cppcheck-suppress syntaxError TEST(IniFileTest, WriteItemReadItem) { // Write line in chapter const char* fname = "./test_ini_file.ini"; diff --git a/src/components/config_profile/test/profile_test.cc b/src/components/config_profile/test/profile_test.cc index 6dc0434440..0d08871ac1 100644 --- a/src/components/config_profile/test/profile_test.cc +++ b/src/components/config_profile/test/profile_test.cc @@ -49,6 +49,7 @@ class ProfileTest : public ::testing::Test { profile::Profile profile_; }; +// cppcheck-suppress syntaxError TEST_F(ProfileTest, UpdateConfigWithDefaultFile) { // Default value uint32_t thread_min_stack_size = threads::Thread::kMinStackSize; |