diff options
author | Andrey Oleynik <AOleynik@luxoft.com> | 2015-02-09 12:57:15 +0200 |
---|---|---|
committer | Aleksandr Galiuzov <AGaliuzov@luxoft.com> | 2015-02-23 13:58:19 +0200 |
commit | 205d74658dec66a440e90435b4d4b2178686fa7c (patch) | |
tree | 4baa9ed1d1d18967bb8948c6495d0db1e412996b /src | |
parent | 5ecd7e9a91fed31c0cd14f7c7614a891ac4647a9 (diff) | |
download | sdl_core-205d74658dec66a440e90435b4d4b2178686fa7c.tar.gz |
APPLINK-11231. Fixed setting 0 values for parameters from SDL configuration file.
Diffstat (limited to 'src')
-rw-r--r-- | src/components/config_profile/include/config_profile/profile.h | 16 | ||||
-rw-r--r-- | src/components/config_profile/src/profile.cc | 47 |
2 files changed, 28 insertions, 35 deletions
diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h index 4a71656bae..9cf1367b82 100644 --- a/src/components/config_profile/include/config_profile/profile.h +++ b/src/components/config_profile/include/config_profile/profile.h @@ -573,14 +573,6 @@ class Profile : public utils::Singleton<Profile> { const char* const pKey) const; /** - * @brief Write to log content of container - * @param array Source array - * @param log Log string - */ - void LogContainer(const std::vector<std::string>& container, - std::string* log); - - /** * @brief Checks, if path is relative * @param path Path * @return true, if is relative, otherwise - false @@ -593,6 +585,14 @@ class Profile : public utils::Singleton<Profile> { */ void MakeAbsolutePath(std::string& path); + /** + * @brief Converts input string to number + * @param input Input string + * @param output Output number + * @return true, if successfully converted, otherwise - false + */ + bool StringToNumber(const std::string& input, uint64_t* output) const; + private: bool launch_hmi_; std::string app_config_folder_; diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index c4a6133de2..ec3c1f837c 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -215,7 +215,7 @@ const size_t kDefaultFrequencyCount = 1000; const size_t kDefaultFrequencyTime = 1000; const uint16_t kDefaultAttemptsToOpenPolicyDB = 5; const uint16_t kDefaultOpenAttemptTimeoutMsKey = 500; -const uint32_t kDefaultAppIconsFolderMaxSize = 104857600; +const uint32_t kDefaultAppIconsFolderMaxSize = 1048576; const uint32_t kDefaultAppIconsAmountToRemove = 1; } // namespace @@ -1462,14 +1462,13 @@ bool Profile::ReadUIntValue(uint16_t* value, uint16_t default_value, *value = default_value; return false; } else { - errno = 0; - uint16_t user_value = strtoul(string_value.c_str(), NULL, 10); - if (!user_value || errno == ERANGE) { + uint64_t user_value; + if (!StringToNumber(string_value, &user_value)) { *value = default_value; return false; } - *value = user_value; + *value = static_cast<uint16_t>(user_value); return true; } } @@ -1482,14 +1481,13 @@ bool Profile::ReadUIntValue(uint32_t* value, uint32_t default_value, *value = default_value; return false; } else { - errno = 0; - uint32_t user_value = strtoul(string_value.c_str(), NULL, 10); - if (!user_value || errno == ERANGE) { + uint64_t user_value; + if (!StringToNumber(string_value, &user_value)) { *value = default_value; return false; } - *value = user_value; + *value = static_cast<uint32_t>(user_value); return true; } } @@ -1502,9 +1500,8 @@ bool Profile::ReadUIntValue(uint64_t* value, uint64_t default_value, *value = default_value; return false; } else { - errno = 0; - uint64_t user_value = strtoull(string_value.c_str(), NULL, 10); - if (!user_value || errno == ERANGE) { + uint64_t user_value; + if (!StringToNumber(string_value, &user_value)) { *value = default_value; return false; } @@ -1514,22 +1511,18 @@ bool Profile::ReadUIntValue(uint64_t* value, uint64_t default_value, } } -void Profile::LogContainer(const std::vector<std::string>& container, - std::string* log) { - if (container.empty()) { - return; - } - if (NULL == log) { - return; - } - std::vector<std::string>::const_iterator it = container.begin(); - std::vector<std::string>::const_iterator it_end = container.end(); - for (; it != it_end-1; ++it) { - log->append(*it); - log->append(" ; "); +bool Profile::StringToNumber(const std::string& input, uint64_t* output) const { + const char* input_value = input.c_str(); + char* endptr; + const int base = 10; + uint64_t user_value = strtoull(input_value, &endptr, base); + bool is_real_zero_value = + (!user_value && endptr != input_value && *endptr == '\0'); + if (!is_real_zero_value && (!user_value || errno == ERANGE)) { + return false; } - - log->append(container.back()); + *output = user_value; + return true; } bool Profile::IsRelativePath(const std::string& path) { |