summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaroslav Mamykin (GitHub) <ymamykin@luxoft.com>2019-10-04 23:29:25 +0300
committerYarik <ymamykin@gmail.com>2019-11-15 15:16:38 +0200
commit24630d4ed456ee5621db4a97f24c7c15f484db80 (patch)
tree7fb8a959e1b0a242eb0c16d2326dc89b5f1c66a6
parent09ffe8620fc06691ec1cce2fb2bad0cdf5745c76 (diff)
downloadsdl_core-24630d4ed456ee5621db4a97f24c7c15f484db80.tar.gz
Add parsing of syncMsgVersion without specified patch version
-rw-r--r--src/components/include/utils/semantic_version.h22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/components/include/utils/semantic_version.h b/src/components/include/utils/semantic_version.h
index 5b2f2a1cdf..78b6f15d1a 100644
--- a/src/components/include/utils/semantic_version.h
+++ b/src/components/include/utils/semantic_version.h
@@ -51,17 +51,19 @@ struct SemanticVersion {
SemanticVersion(const std::string& versionString)
: major_version_(0), minor_version_(0), patch_version_(0) {
- unsigned int major_int, minor_int, patch_int;
+
int readElements = sscanf(
- versionString.c_str(), "%u.%u.%u", &major_int, &minor_int, &patch_int);
+ versionString.c_str(), "%hu.%hu.%hu", &major_version_, &minor_version_, &patch_version_);
+
if (readElements != 3) {
- // LOG4CXX_WARN(logger_,
- // "Error while parsing version string: " << versionString);
- } else {
- major_version_ = static_cast<uint8_t>(major_int);
- minor_version_ = static_cast<uint8_t>(minor_int);
- patch_version_ = static_cast<uint8_t>(patch_int);
- }
+ if (readElements != 2) {
+ major_version_ = 0;
+ minor_version_ = 0;
+ patch_version_ = 0;
+ // LOG4CXX_WARN(logger_,
+ // "Error while parsing version string: " << versionString);
+ }
+ }
}
static inline int16_t cmp(const SemanticVersion& version1,
@@ -122,4 +124,4 @@ extern const SemanticVersion base_rpc_version;
extern const SemanticVersion rpc_version_5;
} // namespace utils
-#endif // SRC_COMPONENTS_INCLUDE_UTILS_CALLABLE_H \ No newline at end of file
+#endif // SRC_COMPONENTS_INCLUDE_UTILS_CALLABLE_H