Skip to content

Commit ccbe25c

Browse files
committed
update protozero to v1.6.8
1 parent ed692a4 commit ccbe25c

File tree

9 files changed

+57
-50
lines changed

9 files changed

+57
-50
lines changed

contrib/protozero/README.contrib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Source: https://github.com/mapbox/protozero
2-
Revision: v1.6.7
2+
Revision: v1.6.8

contrib/protozero/include/protozero/byteswap.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,25 @@ inline uint32_t byteswap_impl(uint32_t value) noexcept {
2727
#ifdef PROTOZERO_USE_BUILTIN_BSWAP
2828
return __builtin_bswap32(value);
2929
#else
30-
return ((value & 0xff000000) >> 24) |
31-
((value & 0x00ff0000) >> 8) |
32-
((value & 0x0000ff00) << 8) |
33-
((value & 0x000000ff) << 24);
30+
return ((value & 0xff000000U) >> 24U) |
31+
((value & 0x00ff0000U) >> 8U) |
32+
((value & 0x0000ff00U) << 8U) |
33+
((value & 0x000000ffU) << 24U);
3434
#endif
3535
}
3636

3737
inline uint64_t byteswap_impl(uint64_t value) noexcept {
3838
#ifdef PROTOZERO_USE_BUILTIN_BSWAP
3939
return __builtin_bswap64(value);
4040
#else
41-
return ((value & 0xff00000000000000ULL) >> 56) |
42-
((value & 0x00ff000000000000ULL) >> 40) |
43-
((value & 0x0000ff0000000000ULL) >> 24) |
44-
((value & 0x000000ff00000000ULL) >> 8) |
45-
((value & 0x00000000ff000000ULL) << 8) |
46-
((value & 0x0000000000ff0000ULL) << 24) |
47-
((value & 0x000000000000ff00ULL) << 40) |
48-
((value & 0x00000000000000ffULL) << 56);
41+
return ((value & 0xff00000000000000ULL) >> 56U) |
42+
((value & 0x00ff000000000000ULL) >> 40U) |
43+
((value & 0x0000ff0000000000ULL) >> 24U) |
44+
((value & 0x000000ff00000000ULL) >> 8U) |
45+
((value & 0x00000000ff000000ULL) << 8U) |
46+
((value & 0x0000000000ff0000ULL) << 24U) |
47+
((value & 0x000000000000ff00ULL) << 40U) |
48+
((value & 0x00000000000000ffULL) << 56U);
4949
#endif
5050
}
5151

contrib/protozero/include/protozero/data_view.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ class data_view {
141141
*
142142
* @pre Must not be default constructed data_view.
143143
*/
144-
int compare(data_view other) const {
145-
protozero_assert(m_data && other.m_data);
144+
int compare(data_view other) const noexcept {
145+
assert(m_data && other.m_data);
146146
const int cmp = std::memcmp(data(), other.data(),
147147
std::min(size(), other.size()));
148148
if (cmp == 0) {

contrib/protozero/include/protozero/iterators.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,10 @@ class const_varint_iterator {
291291
protected:
292292

293293
/// Pointer to current iterator position
294-
const char* m_data = nullptr;
294+
const char* m_data = nullptr; // NOLINT(misc-non-private-member-variables-in-classes, cppcoreguidelines-non-private-member-variables-in-classes,-warnings-as-errors)
295295

296296
/// Pointer to end iterator position
297-
const char* m_end = nullptr;
297+
const char* m_end = nullptr; // NOLINT(misc-non-private-member-variables-in-classes, cppcoreguidelines-non-private-member-variables-in-classes,-warnings-as-errors)
298298

299299
public:
300300

@@ -316,7 +316,7 @@ class const_varint_iterator {
316316
// significant bit not set. We can use this to quickly figure out
317317
// how many varints there are without actually decoding the varints.
318318
return std::count_if(begin.m_data, end.m_data, [](char c) noexcept {
319-
return (static_cast<unsigned char>(c) & 0x80u) == 0;
319+
return (static_cast<unsigned char>(c) & 0x80U) == 0;
320320
});
321321
}
322322

contrib/protozero/include/protozero/pbf_reader.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,15 @@ class pbf_reader {
287287
}
288288

289289
const auto value = get_varint<uint32_t>();
290-
m_tag = pbf_tag_type(value >> 3u);
290+
m_tag = pbf_tag_type(value >> 3U);
291291

292292
// tags 0 and 19000 to 19999 are not allowed as per
293293
// https://developers.google.com/protocol-buffers/docs/proto#assigning-tags
294294
if (m_tag == 0 || (m_tag >= 19000 && m_tag <= 19999)) {
295295
throw invalid_tag_exception{};
296296
}
297297

298-
m_wire_type = pbf_wire_type(value & 0x07u);
298+
m_wire_type = pbf_wire_type(value & 0x07U);
299299
switch (m_wire_type) {
300300
case pbf_wire_type::varint:
301301
case pbf_wire_type::fixed64:

contrib/protozero/include/protozero/pbf_writer.hpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ class pbf_writer {
7878
}
7979

8080
void add_field(pbf_tag_type tag, pbf_wire_type type) {
81-
protozero_assert(((tag > 0 && tag < 19000) || (tag > 19999 && tag <= ((1u << 29u) - 1))) && "tag out of range");
82-
const uint32_t b = (tag << 3u) | uint32_t(type);
81+
protozero_assert(((tag > 0 && tag < 19000) || (tag > 19999 && tag <= ((1U << 29U) - 1))) && "tag out of range");
82+
const uint32_t b = (tag << 3U) | uint32_t(type);
8383
add_varint(b);
8484
}
8585

@@ -289,9 +289,16 @@ class pbf_writer {
289289
return *this;
290290
}
291291

292-
~pbf_writer() {
293-
if (m_parent_writer != nullptr) {
294-
m_parent_writer->close_submessage();
292+
~pbf_writer() noexcept {
293+
try {
294+
if (m_parent_writer != nullptr) {
295+
m_parent_writer->close_submessage();
296+
}
297+
} catch (...) {
298+
// This try/catch is used to make the destructor formally noexcept.
299+
// close_submessage() is not noexcept, but will not throw the way
300+
// it is called here, so we are good. But to be paranoid, call...
301+
std::terminate();
295302
}
296303
}
297304

@@ -928,7 +935,7 @@ namespace detail {
928935

929936
protected:
930937

931-
pbf_writer m_writer{};
938+
pbf_writer m_writer{}; // NOLINT(misc-non-private-member-variables-in-classes, cppcoreguidelines-non-private-member-variables-in-classes,-warnings-as-errors)
932939

933940
public:
934941

contrib/protozero/include/protozero/types.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ enum class pbf_wire_type : uint32_t {
5353
*/
5454
template <typename T>
5555
constexpr inline uint32_t tag_and_type(T tag, pbf_wire_type wire_type) noexcept {
56-
return (static_cast<uint32_t>(static_cast<pbf_tag_type>(tag)) << 3u) | static_cast<uint32_t>(wire_type);
56+
return (static_cast<uint32_t>(static_cast<pbf_tag_type>(tag)) << 3U) | static_cast<uint32_t>(wire_type);
5757
}
5858

5959
/**

contrib/protozero/include/protozero/varint.hpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,22 @@ namespace detail {
3939
if (iend - begin >= max_varint_length) { // fast path
4040
do {
4141
int64_t b;
42-
b = *p++; val = ((uint64_t(b) & 0x7fu) ); if (b >= 0) { break; }
43-
b = *p++; val |= ((uint64_t(b) & 0x7fu) << 7u); if (b >= 0) { break; }
44-
b = *p++; val |= ((uint64_t(b) & 0x7fu) << 14u); if (b >= 0) { break; }
45-
b = *p++; val |= ((uint64_t(b) & 0x7fu) << 21u); if (b >= 0) { break; }
46-
b = *p++; val |= ((uint64_t(b) & 0x7fu) << 28u); if (b >= 0) { break; }
47-
b = *p++; val |= ((uint64_t(b) & 0x7fu) << 35u); if (b >= 0) { break; }
48-
b = *p++; val |= ((uint64_t(b) & 0x7fu) << 42u); if (b >= 0) { break; }
49-
b = *p++; val |= ((uint64_t(b) & 0x7fu) << 49u); if (b >= 0) { break; }
50-
b = *p++; val |= ((uint64_t(b) & 0x7fu) << 56u); if (b >= 0) { break; }
51-
b = *p++; val |= ((uint64_t(b) & 0x01u) << 63u); if (b >= 0) { break; }
42+
b = *p++; val = ((uint64_t(b) & 0x7fU) ); if (b >= 0) { break; }
43+
b = *p++; val |= ((uint64_t(b) & 0x7fU) << 7U); if (b >= 0) { break; }
44+
b = *p++; val |= ((uint64_t(b) & 0x7fU) << 14U); if (b >= 0) { break; }
45+
b = *p++; val |= ((uint64_t(b) & 0x7fU) << 21U); if (b >= 0) { break; }
46+
b = *p++; val |= ((uint64_t(b) & 0x7fU) << 28U); if (b >= 0) { break; }
47+
b = *p++; val |= ((uint64_t(b) & 0x7fU) << 35U); if (b >= 0) { break; }
48+
b = *p++; val |= ((uint64_t(b) & 0x7fU) << 42U); if (b >= 0) { break; }
49+
b = *p++; val |= ((uint64_t(b) & 0x7fU) << 49U); if (b >= 0) { break; }
50+
b = *p++; val |= ((uint64_t(b) & 0x7fU) << 56U); if (b >= 0) { break; }
51+
b = *p++; val |= ((uint64_t(b) & 0x01U) << 63U); if (b >= 0) { break; }
5252
throw varint_too_long_exception{};
5353
} while (false);
5454
} else {
5555
unsigned int shift = 0;
5656
while (p != iend && *p < 0) {
57-
val |= (uint64_t(*p++) & 0x7fu) << shift;
57+
val |= (uint64_t(*p++) & 0x7fU) << shift;
5858
shift += 7;
5959
}
6060
if (p == iend) {
@@ -88,7 +88,7 @@ namespace detail {
8888
*/
8989
inline uint64_t decode_varint(const char** data, const char* end) {
9090
// If this is a one-byte varint, decode it here.
91-
if (end != *data && ((static_cast<uint64_t>(**data) & 0x80u) == 0)) {
91+
if (end != *data && ((static_cast<uint64_t>(**data) & 0x80U) == 0)) {
9292
const auto val = static_cast<uint64_t>(**data);
9393
++(*data);
9494
return val;
@@ -145,9 +145,9 @@ template <typename T>
145145
inline int write_varint(T data, uint64_t value) {
146146
int n = 1;
147147

148-
while (value >= 0x80u) {
149-
*data++ = char((value & 0x7fu) | 0x80u);
150-
value >>= 7u;
148+
while (value >= 0x80U) {
149+
*data++ = char((value & 0x7fU) | 0x80U);
150+
value >>= 7U;
151151
++n;
152152
}
153153
*data++ = char(value);
@@ -164,8 +164,8 @@ inline int write_varint(T data, uint64_t value) {
164164
inline int length_of_varint(uint64_t value) noexcept {
165165
int n = 1;
166166

167-
while (value >= 0x80u) {
168-
value >>= 7u;
167+
while (value >= 0x80U) {
168+
value >>= 7U;
169169
++n;
170170
}
171171

@@ -176,28 +176,28 @@ inline int length_of_varint(uint64_t value) noexcept {
176176
* ZigZag encodes a 32 bit integer.
177177
*/
178178
inline constexpr uint32_t encode_zigzag32(int32_t value) noexcept {
179-
return (static_cast<uint32_t>(value) << 1u) ^ static_cast<uint32_t>(-static_cast<int32_t>(static_cast<uint32_t>(value) >> 31u));
179+
return (static_cast<uint32_t>(value) << 1U) ^ static_cast<uint32_t>(-static_cast<int32_t>(static_cast<uint32_t>(value) >> 31U));
180180
}
181181

182182
/**
183183
* ZigZag encodes a 64 bit integer.
184184
*/
185185
inline constexpr uint64_t encode_zigzag64(int64_t value) noexcept {
186-
return (static_cast<uint64_t>(value) << 1u) ^ static_cast<uint64_t>(-static_cast<int64_t>(static_cast<uint64_t>(value) >> 63u));
186+
return (static_cast<uint64_t>(value) << 1U) ^ static_cast<uint64_t>(-static_cast<int64_t>(static_cast<uint64_t>(value) >> 63U));
187187
}
188188

189189
/**
190190
* Decodes a 32 bit ZigZag-encoded integer.
191191
*/
192192
inline constexpr int32_t decode_zigzag32(uint32_t value) noexcept {
193-
return static_cast<int32_t>((value >> 1u) ^ static_cast<uint32_t>(-static_cast<int32_t>(value & 1u)));
193+
return static_cast<int32_t>((value >> 1U) ^ static_cast<uint32_t>(-static_cast<int32_t>(value & 1U)));
194194
}
195195

196196
/**
197197
* Decodes a 64 bit ZigZag-encoded integer.
198198
*/
199199
inline constexpr int64_t decode_zigzag64(uint64_t value) noexcept {
200-
return static_cast<int64_t>((value >> 1u) ^ static_cast<uint64_t>(-static_cast<int64_t>(value & 1u)));
200+
return static_cast<int64_t>((value >> 1U) ^ static_cast<uint64_t>(-static_cast<int64_t>(value & 1U)));
201201
}
202202

203203
} // end namespace protozero

contrib/protozero/include/protozero/version.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ documentation.
2323
#define PROTOZERO_VERSION_MINOR 6
2424

2525
/// The patch number
26-
#define PROTOZERO_VERSION_PATCH 7
26+
#define PROTOZERO_VERSION_PATCH 8
2727

2828
/// The complete version number
2929
#define PROTOZERO_VERSION_CODE (PROTOZERO_VERSION_MAJOR * 10000 + PROTOZERO_VERSION_MINOR * 100 + PROTOZERO_VERSION_PATCH)
3030

3131
/// Version number as string
32-
#define PROTOZERO_VERSION_STRING "1.6.7"
32+
#define PROTOZERO_VERSION_STRING "1.6.8"
3333

3434
#endif // PROTOZERO_VERSION_HPP

0 commit comments

Comments
 (0)