]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Upgrade to protozero 1.8.0: https://github.com/mapbox/protozero/releases/tag/v1.8.0 15525/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 6 May 2025 08:20:35 +0000 (10:20 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 6 May 2025 08:30:17 +0000 (10:30 +0200)
ext/protozero/CHANGELOG.md
ext/protozero/LICENSE.md
ext/protozero/include/protozero/basic_pbf_builder.hpp
ext/protozero/include/protozero/basic_pbf_writer.hpp
ext/protozero/include/protozero/buffer_string.hpp
ext/protozero/include/protozero/data_view.hpp
ext/protozero/include/protozero/pbf_message.hpp
ext/protozero/include/protozero/pbf_reader.hpp
ext/protozero/include/protozero/types.hpp
ext/protozero/include/protozero/varint.hpp
ext/protozero/include/protozero/version.hpp

index 35a793c1015c40080a009c97f03e3c238e497e6b..8b28db15afce783c675d7980d55c668a8d1235a6 100644 (file)
@@ -14,6 +14,24 @@ This project adheres to [Semantic Versioning](https://semver.org/).
 ### Fixed
 
 
+## [1.8.0] - 2024-01-13
+
+### Changed
+
+- Switched to C++14 as minimum requirement. Modernised the code accordingly.
+- Only the tests need the Protobuf library when building.
+- Improve compatibility with various STL flavors.
+- Change license formatting to get recognized by license scanning tools.
+- Add lots of `const` in places where we can. Also fix some other issues
+  reported by clang-tidy.
+- Various other code cleanups.
+- Modernize documentation config, CMake config and CI workflows.
+
+### Fixed
+
+- `basic_pbf_builder` constructor can not be noexcept.
+
+
 ## [1.7.1] - 2022-01-10
 
 ### Changed
@@ -399,7 +417,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
 - Make pbf reader and writer code endianess-aware.
 
 
-[unreleased]: https://github.com/osmcode/libosmium/compare/v1.7.1...HEAD
+[unreleased]: https://github.com/osmcode/libosmium/compare/v1.8.0...HEAD
+[1.8.0]: https://github.com/osmcode/libosmium/compare/v1.7.1...v1.8.0
 [1.7.1]: https://github.com/osmcode/libosmium/compare/v1.7.0...v1.7.1
 [1.7.0]: https://github.com/osmcode/libosmium/compare/v1.6.8...v1.7.0
 [1.6.8]: https://github.com/osmcode/libosmium/compare/v1.6.7...v1.6.8
index d0b30117c133cc7d9871355e0c82ac101f793985..5c2ce01d11b1c31a6edbd96d190868e7e7106412 100644 (file)
@@ -1,15 +1,17 @@
-protozero copyright (c) Mapbox.
+Copyright (C) 2022, Mapbox.
+All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are
 met:
 
-    * Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-    * Redistributions in binary form must reproduce the above copyright
-      notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in
+   the documentation and/or other materials provided with the
+   distribution.
 
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
index 0ede726faf441bfeb08addefd796ad33043e81c0..ce7640d43f461f15764aa9a1f52c744f7d428804 100644 (file)
@@ -40,7 +40,7 @@ namespace protozero {
 template <typename TBuffer, typename T>
 class basic_pbf_builder : public basic_pbf_writer<TBuffer> {
 
-    static_assert(std::is_same<pbf_tag_type, typename std::underlying_type<T>::type>::value,
+    static_assert(std::is_same<pbf_tag_type, std::underlying_type_t<T>>::value,
                   "T must be enum with underlying type protozero::pbf_tag_type");
 
 public:
@@ -67,7 +67,7 @@ public:
      * @param tag Tag of the field that will be written
      */
     template <typename P>
-    basic_pbf_builder(basic_pbf_writer<TBuffer>& parent_writer, P tag) noexcept :
+    basic_pbf_builder(basic_pbf_writer<TBuffer>& parent_writer, P tag) :
         basic_pbf_writer<TBuffer>{parent_writer, pbf_tag_type(tag)} {
     }
 
index f167c4d1d521d83d9c9f1d4807f4a09a4f4c64f1..c26ba67cd5f9aa36ed8f3687ab5e3adfa6933888 100644 (file)
@@ -85,7 +85,7 @@ class basic_pbf_writer {
 
     void add_field(pbf_tag_type tag, pbf_wire_type type) {
         protozero_assert(((tag > 0 && tag < 19000) || (tag > 19999 && tag <= ((1U << 29U) - 1))) && "tag out of range");
-        const uint32_t b = (tag << 3U) | uint32_t(type);
+        const uint32_t b = (tag << 3U) | static_cast<uint32_t>(type);
         add_varint(b);
     }
 
@@ -105,7 +105,7 @@ class basic_pbf_writer {
     }
 
     template <typename T, typename It>
-    void add_packed_fixed(pbf_tag_type tag, It first, It last, std::input_iterator_tag /*unused*/) {
+    void add_packed_fixed(pbf_tag_type tag, It first, It last, std::input_iterator_tag /*unused*/) { // NOLINT(performance-unnecessary-value-param)
         if (first == last) {
             return;
         }
@@ -118,7 +118,7 @@ class basic_pbf_writer {
     }
 
     template <typename T, typename It>
-    void add_packed_fixed(pbf_tag_type tag, It first, It last, std::forward_iterator_tag /*unused*/) {
+    void add_packed_fixed(pbf_tag_type tag, It first, It last, std::forward_iterator_tag /*unused*/) { // NOLINT(performance-unnecessary-value-param)
         if (first == last) {
             return;
         }
@@ -133,7 +133,7 @@ class basic_pbf_writer {
     }
 
     template <typename It>
-    void add_packed_varint(pbf_tag_type tag, It first, It last) {
+    void add_packed_varint(pbf_tag_type tag, It first, It last) { // NOLINT(performance-unnecessary-value-param)
         if (first == last) {
             return;
         }
@@ -146,7 +146,7 @@ class basic_pbf_writer {
     }
 
     template <typename It>
-    void add_packed_svarint(pbf_tag_type tag, It first, It last) {
+    void add_packed_svarint(pbf_tag_type tag, It first, It last) { // NOLINT(performance-unnecessary-value-param)
         if (first == last) {
             return;
         }
@@ -162,7 +162,7 @@ class basic_pbf_writer {
     // a length-delimited field. The length has to fit into pbf_length_type,
     // and a varint needs 8 bit for every 7 bit.
     enum : int {
-        reserve_bytes = sizeof(pbf_length_type) * 8 / 7 + 1
+        reserve_bytes = (sizeof(pbf_length_type) * 8 / 7) + 1
     };
 
     // If m_rollpack_pos is set to this special value, it means that when
@@ -181,7 +181,7 @@ class basic_pbf_writer {
             buffer_customization<TBuffer>::append_zeros(m_data, std::size_t(reserve_bytes));
         } else {
             m_rollback_pos = size_is_known;
-            add_length_varint(tag, pbf_length_type(size));
+            add_length_varint(tag, static_cast<pbf_length_type>(size));
             reserve(size);
         }
         m_pos = buffer_customization<TBuffer>::size(m_data);
@@ -391,7 +391,7 @@ public:
         add_field(tag, pbf_wire_type::varint);
         protozero_assert(m_pos == 0 && "you can't add fields to a parent basic_pbf_writer if there is an existing basic_pbf_writer for a submessage");
         protozero_assert(m_data);
-        m_data->push_back(char(value));
+        m_data->push_back(static_cast<char>(value));
     }
 
     /**
@@ -401,7 +401,7 @@ public:
      * @param value Value to be written
      */
     void add_enum(pbf_tag_type tag, int32_t value) {
-        add_tagged_varint(tag, uint64_t(value));
+        add_tagged_varint(tag, static_cast<uint64_t>(value));
     }
 
     /**
@@ -411,7 +411,7 @@ public:
      * @param value Value to be written
      */
     void add_int32(pbf_tag_type tag, int32_t value) {
-        add_tagged_varint(tag, uint64_t(value));
+        add_tagged_varint(tag, static_cast<uint64_t>(value));
     }
 
     /**
@@ -441,7 +441,7 @@ public:
      * @param value Value to be written
      */
     void add_int64(pbf_tag_type tag, int64_t value) {
-        add_tagged_varint(tag, uint64_t(value));
+        add_tagged_varint(tag, static_cast<uint64_t>(value));
     }
 
     /**
@@ -541,7 +541,7 @@ public:
         protozero_assert(m_pos == 0 && "you can't add fields to a parent basic_pbf_writer if there is an existing basic_pbf_writer for a submessage");
         protozero_assert(m_data);
         protozero_assert(size <= std::numeric_limits<pbf_length_type>::max());
-        add_length_varint(tag, pbf_length_type(size));
+        add_length_varint(tag, static_cast<pbf_length_type>(size));
         buffer_customization<TBuffer>::append(m_data, value, size);
     }
 
@@ -602,7 +602,7 @@ public:
         size_t sum_size = 0;
         (void)std::initializer_list<size_t>{sum_size += values.size()...};
         protozero_assert(sum_size <= std::numeric_limits<pbf_length_type>::max());
-        add_length_varint(tag, pbf_length_type(sum_size));
+        add_length_varint(tag, static_cast<pbf_length_type>(sum_size));
         buffer_customization<TBuffer>::reserve_additional(m_data, sum_size);
         (void)std::initializer_list<int>{(buffer_customization<TBuffer>::append(m_data, values.data(), values.size()), 0)...};
     }
@@ -697,7 +697,7 @@ public:
      * @param last Iterator pointing one past the end of data
      */
     template <typename InputIterator>
-    void add_packed_bool(pbf_tag_type tag, InputIterator first, InputIterator last) {
+    void add_packed_bool(pbf_tag_type tag, InputIterator first, InputIterator last) { // NOLINT(performance-unnecessary-value-param)
         add_packed_varint(tag, first, last);
     }
 
@@ -711,7 +711,7 @@ public:
      * @param last Iterator pointing one past the end of data
      */
     template <typename InputIterator>
-    void add_packed_enum(pbf_tag_type tag, InputIterator first, InputIterator last) {
+    void add_packed_enum(pbf_tag_type tag, InputIterator first, InputIterator last) { // NOLINT(performance-unnecessary-value-param)
         add_packed_varint(tag, first, last);
     }
 
@@ -725,7 +725,7 @@ public:
      * @param last Iterator pointing one past the end of data
      */
     template <typename InputIterator>
-    void add_packed_int32(pbf_tag_type tag, InputIterator first, InputIterator last) {
+    void add_packed_int32(pbf_tag_type tag, InputIterator first, InputIterator last) { // NOLINT(performance-unnecessary-value-param)
         add_packed_varint(tag, first, last);
     }
 
@@ -739,7 +739,7 @@ public:
      * @param last Iterator pointing one past the end of data
      */
     template <typename InputIterator>
-    void add_packed_sint32(pbf_tag_type tag, InputIterator first, InputIterator last) {
+    void add_packed_sint32(pbf_tag_type tag, InputIterator first, InputIterator last) { // NOLINT(performance-unnecessary-value-param)
         add_packed_svarint(tag, first, last);
     }
 
@@ -753,7 +753,7 @@ public:
      * @param last Iterator pointing one past the end of data
      */
     template <typename InputIterator>
-    void add_packed_uint32(pbf_tag_type tag, InputIterator first, InputIterator last) {
+    void add_packed_uint32(pbf_tag_type tag, InputIterator first, InputIterator last) { // NOLINT(performance-unnecessary-value-param)
         add_packed_varint(tag, first, last);
     }
 
@@ -767,7 +767,7 @@ public:
      * @param last Iterator pointing one past the end of data
      */
     template <typename InputIterator>
-    void add_packed_int64(pbf_tag_type tag, InputIterator first, InputIterator last) {
+    void add_packed_int64(pbf_tag_type tag, InputIterator first, InputIterator last) { // NOLINT(performance-unnecessary-value-param)
         add_packed_varint(tag, first, last);
     }
 
@@ -781,7 +781,7 @@ public:
      * @param last Iterator pointing one past the end of data
      */
     template <typename InputIterator>
-    void add_packed_sint64(pbf_tag_type tag, InputIterator first, InputIterator last) {
+    void add_packed_sint64(pbf_tag_type tag, InputIterator first, InputIterator last) { // NOLINT(performance-unnecessary-value-param)
         add_packed_svarint(tag, first, last);
     }
 
@@ -795,7 +795,7 @@ public:
      * @param last Iterator pointing one past the end of data
      */
     template <typename InputIterator>
-    void add_packed_uint64(pbf_tag_type tag, InputIterator first, InputIterator last) {
+    void add_packed_uint64(pbf_tag_type tag, InputIterator first, InputIterator last) { // NOLINT(performance-unnecessary-value-param)
         add_packed_varint(tag, first, last);
     }
 
@@ -817,7 +817,7 @@ public:
      * @param last Iterator pointing one past the end of data
      */
     template <typename ValueType, typename InputIterator>
-    void add_packed_fixed(pbf_tag_type tag, InputIterator first, InputIterator last) {
+    void add_packed_fixed(pbf_tag_type tag, InputIterator first, InputIterator last) { // NOLINT(performance-unnecessary-value-param)
         static_assert(std::is_same<ValueType, uint32_t>::value ||
                       std::is_same<ValueType, int32_t>::value ||
                       std::is_same<ValueType, int64_t>::value ||
@@ -838,7 +838,7 @@ public:
      * @param last Iterator pointing one past the end of data
      */
     template <typename InputIterator>
-    void add_packed_fixed32(pbf_tag_type tag, InputIterator first, InputIterator last) {
+    void add_packed_fixed32(pbf_tag_type tag, InputIterator first, InputIterator last) { // NOLINT(performance-unnecessary-value-param)
         add_packed_fixed<uint32_t, InputIterator>(tag, first, last,
             typename std::iterator_traits<InputIterator>::iterator_category{});
     }
@@ -853,7 +853,7 @@ public:
      * @param last Iterator pointing one past the end of data
      */
     template <typename InputIterator>
-    void add_packed_sfixed32(pbf_tag_type tag, InputIterator first, InputIterator last) {
+    void add_packed_sfixed32(pbf_tag_type tag, InputIterator first, InputIterator last) { // NOLINT(performance-unnecessary-value-param)
         add_packed_fixed<int32_t, InputIterator>(tag, first, last,
             typename std::iterator_traits<InputIterator>::iterator_category{});
     }
@@ -868,7 +868,7 @@ public:
      * @param last Iterator pointing one past the end of data
      */
     template <typename InputIterator>
-    void add_packed_fixed64(pbf_tag_type tag, InputIterator first, InputIterator last) {
+    void add_packed_fixed64(pbf_tag_type tag, InputIterator first, InputIterator last) { // NOLINT(performance-unnecessary-value-param)
         add_packed_fixed<uint64_t, InputIterator>(tag, first, last,
             typename std::iterator_traits<InputIterator>::iterator_category{});
     }
@@ -883,7 +883,7 @@ public:
      * @param last Iterator pointing one past the end of data
      */
     template <typename InputIterator>
-    void add_packed_sfixed64(pbf_tag_type tag, InputIterator first, InputIterator last) {
+    void add_packed_sfixed64(pbf_tag_type tag, InputIterator first, InputIterator last) { // NOLINT(performance-unnecessary-value-param)
         add_packed_fixed<int64_t, InputIterator>(tag, first, last,
             typename std::iterator_traits<InputIterator>::iterator_category{});
     }
@@ -898,7 +898,7 @@ public:
      * @param last Iterator pointing one past the end of data
      */
     template <typename InputIterator>
-    void add_packed_float(pbf_tag_type tag, InputIterator first, InputIterator last) {
+    void add_packed_float(pbf_tag_type tag, InputIterator first, InputIterator last) { // NOLINT(performance-unnecessary-value-param)
         add_packed_fixed<float, InputIterator>(tag, first, last,
             typename std::iterator_traits<InputIterator>::iterator_category{});
     }
@@ -913,7 +913,7 @@ public:
      * @param last Iterator pointing one past the end of data
      */
     template <typename InputIterator>
-    void add_packed_double(pbf_tag_type tag, InputIterator first, InputIterator last) {
+    void add_packed_double(pbf_tag_type tag, InputIterator first, InputIterator last) { // NOLINT(performance-unnecessary-value-param)
         add_packed_fixed<double, InputIterator>(tag, first, last,
             typename std::iterator_traits<InputIterator>::iterator_category{});
     }
index 02e8ad25b6e63c888736df398dd62bd1b6ac893d..c620879e45bf0b9869a285ef950a711e7b364e1f 100644 (file)
@@ -57,8 +57,8 @@ struct buffer_customization<std::string> {
         protozero_assert(from <= buffer->size());
         protozero_assert(to <= buffer->size());
         protozero_assert(from <= to);
-        buffer->erase(std::next(buffer->begin(), static_cast<std::string::iterator::difference_type>(from)),
-                      std::next(buffer->begin(), static_cast<std::string::iterator::difference_type>(to)));
+        buffer->erase(buffer->begin() + static_cast<std::string::difference_type>(from),
+                      buffer->begin() + static_cast<std::string::difference_type>(to));
     }
 
     static char* at_pos(std::string* buffer, std::size_t pos) {
index 3ec87af34e4c4c9bb3b5bee4602419a9ad52cc63..815ceb3d243966fd213004b5c9323459525c772f 100644 (file)
@@ -173,7 +173,7 @@ inline void swap(data_view& lhs, data_view& rhs) noexcept {
  * @param lhs First object.
  * @param rhs Second object.
  */
-inline constexpr bool operator==(const data_view lhs, const data_view rhs) noexcept {
+constexpr bool operator==(const data_view lhs, const data_view rhs) noexcept {
     return lhs.size() == rhs.size() &&
            std::equal(lhs.data(), lhs.data() + lhs.size(), rhs.data());
 }
@@ -185,7 +185,7 @@ inline constexpr bool operator==(const data_view lhs, const data_view rhs) noexc
  * @param lhs First object.
  * @param rhs Second object.
  */
-inline constexpr bool operator!=(const data_view lhs, const data_view rhs) noexcept {
+constexpr bool operator!=(const data_view lhs, const data_view rhs) noexcept {
     return !(lhs == rhs);
 }
 
index d7fd8b5d0d01953462800862d2f489a25e584d3b..393078b9bff83c942b68df18297877f8dfae6b61 100644 (file)
@@ -64,7 +64,7 @@ namespace protozero {
 template <typename T>
 class pbf_message : public pbf_reader {
 
-    static_assert(std::is_same<pbf_tag_type, typename std::underlying_type<T>::type>::value,
+    static_assert(std::is_same<pbf_tag_type, std::underlying_type_t<T>>::value,
                   "T must be enum with underlying type protozero::pbf_tag_type");
 
 public:
index 92bfdee5eac6a6079d3dc8acf1d128f402c24007..297683afe6831e38e011ea5447044c4ea8a7771a 100644 (file)
@@ -76,9 +76,9 @@ class pbf_reader {
     template <typename T>
     T get_fixed() {
         T result;
-        const char* data = m_data;
+        const char* tmp_data = m_data;
         skip_bytes(sizeof(T));
-        std::memcpy(&result, data, sizeof(T));
+        std::memcpy(&result, tmp_data, sizeof(T));
 #if PROTOZERO_BYTE_ORDER != PROTOZERO_LITTLE_ENDIAN
         byteswap_inplace(&result);
 #endif
@@ -263,7 +263,7 @@ public:
      * and how it is encoded for this number to have any meaning.
      */
     std::size_t length() const noexcept {
-        return std::size_t(m_end - m_data);
+        return static_cast<std::size_t>(m_end - m_data);
     }
 
     /**
@@ -287,7 +287,7 @@ public:
         }
 
         const auto value = get_varint<uint32_t>();
-        m_tag = pbf_tag_type(value >> 3U);
+        m_tag = static_cast<pbf_tag_type>(value >> 3U);
 
         // tags 0 and 19000 to 19999 are not allowed as per
         // https://developers.google.com/protocol-buffers/docs/proto#assigning-tags
index 3aefddfb51207e70863dd3934f7aa8414bb0be1c..ad9c362ff261b6ff2669ccad222aab99c361233f 100644 (file)
@@ -52,7 +52,7 @@ enum class pbf_wire_type : uint32_t {
  * See pbf_reader.tag_and_type() for an example how to use this.
  */
 template <typename T>
-constexpr inline uint32_t tag_and_type(T tag, pbf_wire_type wire_type) noexcept {
+constexpr uint32_t tag_and_type(T tag, pbf_wire_type wire_type) noexcept {
     return (static_cast<uint32_t>(static_cast<pbf_tag_type>(tag)) << 3U) | static_cast<uint32_t>(wire_type);
 }
 
index b4648a4421e8aa3ff3b66bcb8a2a909665a98b46..5c7fcec75280af876f6debbe93052b7be8dfb8a1 100644 (file)
@@ -26,7 +26,7 @@ namespace protozero {
 /**
  * The maximum length of a 64 bit varint.
  */
-constexpr const int8_t max_varint_length = sizeof(uint64_t) * 8 / 7 + 1;
+constexpr const int8_t max_varint_length = (sizeof(uint64_t) * 8 / 7) + 1;
 
 namespace detail {
 
@@ -40,28 +40,28 @@ namespace detail {
         if (iend - begin >= max_varint_length) {  // fast path
             do {
                 int64_t b = *p++;
-                          val  = ((uint64_t(b) & 0x7fU)       ); if (b >= 0) { break; }
-                b = *p++; val |= ((uint64_t(b) & 0x7fU) <<  7U); if (b >= 0) { break; }
-                b = *p++; val |= ((uint64_t(b) & 0x7fU) << 14U); if (b >= 0) { break; }
-                b = *p++; val |= ((uint64_t(b) & 0x7fU) << 21U); if (b >= 0) { break; }
-                b = *p++; val |= ((uint64_t(b) & 0x7fU) << 28U); if (b >= 0) { break; }
-                b = *p++; val |= ((uint64_t(b) & 0x7fU) << 35U); if (b >= 0) { break; }
-                b = *p++; val |= ((uint64_t(b) & 0x7fU) << 42U); if (b >= 0) { break; }
-                b = *p++; val |= ((uint64_t(b) & 0x7fU) << 49U); if (b >= 0) { break; }
-                b = *p++; val |= ((uint64_t(b) & 0x7fU) << 56U); if (b >= 0) { break; }
-                b = *p++; val |= ((uint64_t(b) & 0x01U) << 63U); if (b >= 0) { break; }
+                          val  = ((static_cast<uint64_t>(b) & 0x7fU)       ); if (b >= 0) { break; }
+                b = *p++; val |= ((static_cast<uint64_t>(b) & 0x7fU) <<  7U); if (b >= 0) { break; }
+                b = *p++; val |= ((static_cast<uint64_t>(b) & 0x7fU) << 14U); if (b >= 0) { break; }
+                b = *p++; val |= ((static_cast<uint64_t>(b) & 0x7fU) << 21U); if (b >= 0) { break; }
+                b = *p++; val |= ((static_cast<uint64_t>(b) & 0x7fU) << 28U); if (b >= 0) { break; }
+                b = *p++; val |= ((static_cast<uint64_t>(b) & 0x7fU) << 35U); if (b >= 0) { break; }
+                b = *p++; val |= ((static_cast<uint64_t>(b) & 0x7fU) << 42U); if (b >= 0) { break; }
+                b = *p++; val |= ((static_cast<uint64_t>(b) & 0x7fU) << 49U); if (b >= 0) { break; }
+                b = *p++; val |= ((static_cast<uint64_t>(b) & 0x7fU) << 56U); if (b >= 0) { break; }
+                b = *p++; val |= ((static_cast<uint64_t>(b) & 0x01U) << 63U); if (b >= 0) { break; }
                 throw varint_too_long_exception{};
             } while (false);
         } else {
             unsigned int shift = 0;
             while (p != iend && *p < 0) {
-                val |= (uint64_t(*p++) & 0x7fU) << shift;
+                val |= (static_cast<uint64_t>(*p++) & 0x7fU) << shift;
                 shift += 7;
             }
             if (p == iend) {
                 throw end_of_buffer_exception{};
             }
-            val |= uint64_t(*p++) << shift;
+            val |= static_cast<uint64_t>(*p++) << shift;
         }
 
         *data = reinterpret_cast<const char*>(p);
@@ -148,11 +148,11 @@ inline int write_varint(T data, uint64_t value) {
     int n = 1;
 
     while (value >= 0x80U) {
-        *data++ = char((value & 0x7fU) | 0x80U);
+        *data++ = static_cast<char>((value & 0x7fU) | 0x80U);
         value >>= 7U;
         ++n;
     }
-    *data = char(value);
+    *data = static_cast<char>(value);
 
     return n;
 }
@@ -163,16 +163,15 @@ inline int write_varint(T data, uint64_t value) {
  * @tparam TBuffer A buffer type.
  * @param buffer Output buffer the varint will be written to.
  * @param value The integer that will be encoded.
- * @returns the number of bytes written
  * @throws Any exception thrown by calling the buffer_push_back() function.
  */
 template <typename TBuffer>
 inline void add_varint_to_buffer(TBuffer* buffer, uint64_t value) {
     while (value >= 0x80U) {
-        buffer_customization<TBuffer>::push_back(buffer, char((value & 0x7fU) | 0x80U));
+        buffer_customization<TBuffer>::push_back(buffer, static_cast<char>((value & 0x7fU) | 0x80U));
         value >>= 7U;
     }
-    buffer_customization<TBuffer>::push_back(buffer, char(value));
+    buffer_customization<TBuffer>::push_back(buffer, static_cast<char>(value));
 }
 
 /**
@@ -186,11 +185,11 @@ inline int add_varint_to_buffer(char* data, uint64_t value) noexcept {
     int n = 1;
 
     while (value >= 0x80U) {
-        *data++ = char((value & 0x7fU) | 0x80U);
+        *data++ = static_cast<char>((value & 0x7fU) | 0x80U);
         value >>= 7U;
         ++n;
     }
-    *data = char(value);
+    *data = static_cast<char>(value);
 
     return n;
 }
@@ -215,28 +214,28 @@ inline int length_of_varint(uint64_t value) noexcept {
 /**
  * ZigZag encodes a 32 bit integer.
  */
-inline constexpr uint32_t encode_zigzag32(int32_t value) noexcept {
+constexpr uint32_t encode_zigzag32(int32_t value) noexcept {
     return (static_cast<uint32_t>(value) << 1U) ^ static_cast<uint32_t>(-static_cast<int32_t>(static_cast<uint32_t>(value) >> 31U));
 }
 
 /**
  * ZigZag encodes a 64 bit integer.
  */
-inline constexpr uint64_t encode_zigzag64(int64_t value) noexcept {
+constexpr uint64_t encode_zigzag64(int64_t value) noexcept {
     return (static_cast<uint64_t>(value) << 1U) ^ static_cast<uint64_t>(-static_cast<int64_t>(static_cast<uint64_t>(value) >> 63U));
 }
 
 /**
  * Decodes a 32 bit ZigZag-encoded integer.
  */
-inline constexpr int32_t decode_zigzag32(uint32_t value) noexcept {
+constexpr int32_t decode_zigzag32(uint32_t value) noexcept {
     return static_cast<int32_t>((value >> 1U) ^ static_cast<uint32_t>(-static_cast<int32_t>(value & 1U)));
 }
 
 /**
  * Decodes a 64 bit ZigZag-encoded integer.
  */
-inline constexpr int64_t decode_zigzag64(uint64_t value) noexcept {
+constexpr int64_t decode_zigzag64(uint64_t value) noexcept {
     return static_cast<int64_t>((value >> 1U) ^ static_cast<uint64_t>(-static_cast<int64_t>(value & 1U)));
 }
 
index fc9b92879c29e1e520f7af0c0bb4eba2e2e48831..18e31cd47256a675bcf89a3308a7c2265f2ba097 100644 (file)
@@ -20,15 +20,15 @@ documentation.
 #define PROTOZERO_VERSION_MAJOR 1
 
 /// The minor version number
-#define PROTOZERO_VERSION_MINOR 7
+#define PROTOZERO_VERSION_MINOR 8
 
 /// The patch number
-#define PROTOZERO_VERSION_PATCH 1
+#define PROTOZERO_VERSION_PATCH 0
 
 /// The complete version number
 #define PROTOZERO_VERSION_CODE (PROTOZERO_VERSION_MAJOR * 10000 + PROTOZERO_VERSION_MINOR * 100 + PROTOZERO_VERSION_PATCH)
 
 /// Version number as string
-#define PROTOZERO_VERSION_STRING "1.7.1"
+#define PROTOZERO_VERSION_STRING "1.8.0"
 
 #endif // PROTOZERO_VERSION_HPP