From eef5cadab0b58b58379b0cd8edfc627de211739a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 28 May 2020 23:27:36 +0200 Subject: [PATCH 1/4] Fix deprecated enum usage --- src/algorithms/PVT/libs/rtcm.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/algorithms/PVT/libs/rtcm.h b/src/algorithms/PVT/libs/rtcm.h index 2ee30e196..6c57e57b8 100644 --- a/src/algorithms/PVT/libs/rtcm.h +++ b/src/algorithms/PVT/libs/rtcm.h @@ -502,14 +502,8 @@ private: class Rtcm_Message { public: - enum - { - header_length = 6 - }; - enum - { - max_body_length = 1029 - }; + static const std::size_t header_length = 6; + static const std::size_t max_body_length = 1029; Rtcm_Message() : body_length_(0) From 8c2d1d6ad1705af0f9a94010333483bc200c5954 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 29 May 2020 01:23:24 +0200 Subject: [PATCH 2/4] Initialize buffer --- src/algorithms/PVT/libs/rtcm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/PVT/libs/rtcm.h b/src/algorithms/PVT/libs/rtcm.h index 6c57e57b8..dfbd42009 100644 --- a/src/algorithms/PVT/libs/rtcm.h +++ b/src/algorithms/PVT/libs/rtcm.h @@ -582,7 +582,7 @@ private: } private: - char data_[header_length + max_body_length]; + char data_[header_length + max_body_length] = ""; std::size_t body_length_; }; From 0897811d16bbbeb7b9b4ce2bf46217c62c24c7b0 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 29 May 2020 09:46:30 +0200 Subject: [PATCH 3/4] Fix for GCC 4.9 --- src/algorithms/PVT/libs/rtcm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/PVT/libs/rtcm.h b/src/algorithms/PVT/libs/rtcm.h index dfbd42009..49b681b3e 100644 --- a/src/algorithms/PVT/libs/rtcm.h +++ b/src/algorithms/PVT/libs/rtcm.h @@ -506,8 +506,8 @@ private: static const std::size_t max_body_length = 1029; Rtcm_Message() - : body_length_(0) { + body_length_ = 0; } const char* data() const From 2f3f63309bcffeaf44900d1e0945a8290e2350b3 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 30 May 2020 09:40:20 +0200 Subject: [PATCH 4/4] Fix for GCC 4.9 using std::array instead of char array --- src/algorithms/PVT/libs/rtcm.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/algorithms/PVT/libs/rtcm.h b/src/algorithms/PVT/libs/rtcm.h index 49b681b3e..d90fd90b4 100644 --- a/src/algorithms/PVT/libs/rtcm.h +++ b/src/algorithms/PVT/libs/rtcm.h @@ -34,6 +34,7 @@ #include #include #include // for min +#include #include #include // for size_t #include @@ -506,18 +507,18 @@ private: static const std::size_t max_body_length = 1029; Rtcm_Message() + : body_length_(0) { - body_length_ = 0; } const char* data() const { - return data_; + return data_.data(); } char* data() { - return data_; + return data_.data(); } inline std::size_t length() const @@ -527,12 +528,12 @@ private: const char* body() const { - return data_ + header_length; + return data_.data() + header_length; } char* body() { - return data_ + header_length; + return data_.data() + header_length; } std::size_t body_length() const @@ -552,14 +553,14 @@ private: inline bool decode_header() { char header[header_length + 1] = ""; - std::strncat(header, data_, header_length); + std::strncat(header, data_.data(), header_length); if (header[0] != 'G' || header[1] != 'S') { return false; } char header2_[header_length - 1] = ""; - std::strncat(header2_, data_ + 2, header_length - 2); + std::strncat(header2_, data_.data() + 2, header_length - 2); body_length_ = std::atoi(header2_); if (body_length_ == 0) { @@ -578,11 +579,11 @@ private: { char header[header_length + 1] = ""; std::snprintf(header, header_length + 1, "GS%4d", std::max(std::min(static_cast(body_length_), static_cast(max_body_length)), 0)); - std::memcpy(data_, header, header_length); + std::memcpy(data_.data(), header, header_length); } private: - char data_[header_length + max_body_length] = ""; + std::array data_{}; std::size_t body_length_; };