Skip to content
Commits on Source (6)
---
Checks: '*,-cert-dcl21-cpp,-cert-err60-cpp,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-type-reinterpret-cast,-google-runtime-references'
Checks: '*,-cert-dcl21-cpp,-cert-err60-cpp,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-type-reinterpret-cast,-fuchsia-*,-google-runtime-references,-hicpp-no-array-decay'
#
# Disabled checks:
#
......@@ -9,42 +9,26 @@ Checks: '*,-cert-dcl21-cpp,-cert-err60-cpp,-cppcoreguidelines-pro-bound
# cert-err60-cpp
# Reports std::runtime_error as broken which we can't do anything about.
#
# cppcoreguidelines-pro-bounds-array-to-pointer-decay
# Limited use and many false positives including for all asserts.
#
# cppcoreguidelines-pro-bounds-pointer-arithmetic
# This is a low-level library, it needs to do pointer arithmetic.
#
# cppcoreguidelines-pro-bounds-array-to-pointer-decay
# Limited use and many false positives including for all asserts
#
# cppcoreguidelines-pro-type-reinterpret-cast
# This is a low-level library, it needs to do reinterpret-casts.
#
# fuchsia-*
# Much too strict.
#
# google-runtime-references
# This is just a matter of preference, and we can't change the interfaces
# now anyways.
#
# hicpp-no-array-decay
# Limited use and many false positives including for all asserts.
#
WarningsAsErrors: '*'
HeaderFilterRegex: '\/include\/'
AnalyzeTemporaryDtors: false
CheckOptions:
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
...
......@@ -89,6 +89,8 @@ matrix:
env: BUILD='Debug' CC=clang-5.0 CXX=clang++-5.0
CXXFLAGS="-fsanitize=address,undefined,integer -fno-sanitize-recover=all -fno-omit-frame-pointer"
LDFLAGS="-fsanitize=address,undefined,integer"
# LSAN doesn't work on container-based system
sudo: required
addons: *clang50
- os: linux
compiler: "gcc-4.7"
......
......@@ -15,6 +15,19 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
## [1.6.2] - 2018-03-09
### Changed
- Update included catch.hpp to v1.12.0.
- Move basic unit tests into their own directory (`test/unit`).
- Improved clang-tidy config and fixed some code producing warnings.
### Fixed
- Buffer overflow in pbf-decoder tool.
## [1.6.1] - 2017-11-16
### Added
......@@ -288,7 +301,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Make pbf reader and writer code endianess-aware.
[unreleased]: https://github.com/osmcode/libosmium/compare/v1.6.1...HEAD
[unreleased]: https://github.com/osmcode/libosmium/compare/v1.6.2...HEAD
[1.6.2]: https://github.com/osmcode/libosmium/compare/v1.6.1...v1.6.2
[1.6.1]: https://github.com/osmcode/libosmium/compare/v1.6.0...v1.6.1
[1.6.0]: https://github.com/osmcode/libosmium/compare/v1.5.3...v1.6.0
[1.5.3]: https://github.com/osmcode/libosmium/compare/v1.5.2...v1.5.3
......
......@@ -14,7 +14,7 @@ project(protozero)
set(PROTOZERO_VERSION_MAJOR 1)
set(PROTOZERO_VERSION_MINOR 6)
set(PROTOZERO_VERSION_PATCH 1)
set(PROTOZERO_VERSION_PATCH 2)
set(PROTOZERO_VERSION
"${PROTOZERO_VERSION_MAJOR}.${PROTOZERO_VERSION_MINOR}.${PROTOZERO_VERSION_PATCH}")
......@@ -58,7 +58,7 @@ find_package(Protobuf)
#
#-----------------------------------------------------------------------------
message(STATUS "Looking for clang-tidy")
find_program(CLANG_TIDY NAMES clang-tidy clang-tidy-5.0)
find_program(CLANG_TIDY NAMES clang-tidy clang-tidy-6.0 clang-tidy-5.0)
if(CLANG_TIDY)
message(STATUS "Looking for clang-tidy - found ${CLANG_TIDY}")
......@@ -66,8 +66,8 @@ if(CLANG_TIDY)
${CLANG_TIDY}
-p ${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/test/*.cpp
${CMAKE_SOURCE_DIR}/test/t/*/reader_test_cases.cpp
${CMAKE_SOURCE_DIR}/test/t/*/writer_test_cases.cpp
${CMAKE_SOURCE_DIR}/test/t/*/*.cpp
${CMAKE_SOURCE_DIR}/test/unit/*.cpp
${CMAKE_SOURCE_DIR}/tools/*.cpp
)
add_dependencies(clang-tidy writer_tests)
......@@ -94,6 +94,7 @@ if(CPPCHECK)
${CMAKE_SOURCE_DIR}/test/*.cpp
${CMAKE_SOURCE_DIR}/test/include/*.hpp
${CMAKE_SOURCE_DIR}/test/t/*/*.cpp
${CMAKE_SOURCE_DIR}/test/unit/*.cpp
${CMAKE_SOURCE_DIR}/tools/*.cpp
)
else()
......
......@@ -80,8 +80,8 @@ Extensive tests are included. Build them using CMake:
Call `ctest` to run the tests.
The reader tests are always build, the writer tests are only build if the
Google Protobuf library is found when running CMake.
The unit and reader tests are always build, the writer tests are only build if
the Google Protobuf library is found when running CMake.
See `test/README.md` for more details about the test.
......@@ -148,6 +148,7 @@ details.
* [Mapnik](https://github.com/mapbox/mapnik-vector-tile)
* [OSRM](https://github.com/Project-OSRM/osrm-backend)
* [Tippecanoe](https://github.com/mapbox/tippecanoe)
* [Vtzero](https://github.com/mapbox/vtzero)
Are you using Protozero? Tell us! Send a pull request with changes to this
README.
......
......@@ -31,9 +31,13 @@ init:
- git config --global core.autocrlf %autocrlf%
- git config --get core.autocrlf
# The option --ask=20 is a workaround for a problem with the MSYS2 update
# process. Without it the following error is printed and the appveyor script
# halts: "msys2-runtime and catgets are in conflict. Remove catgets?"
# See also: https://github.com/Alexpux/MSYS2-packages/issues/1141
install:
- if [%config%]==[MSYS2] (
C:\msys64\usr\bin\pacman --noconfirm --sync --refresh --refresh --sysupgrade --sysupgrade
C:\msys64\usr\bin\pacman --noconfirm --sync --refresh --refresh --sysupgrade --sysupgrade --ask=20
&& C:\msys64\usr\bin\pacman -Rc --noconfirm mingw-w64-x86_64-gcc-libs
)
......
......@@ -39,7 +39,7 @@
# find include path
find_path(PROTOZERO_INCLUDE_DIR protozero/version.hpp
PATH_SUFFIXES include
PATHS ../protozero
PATHS ${CMAKE_SOURCE_DIR}/../protozero
)
# Check version number
......
protozero (1.6.1-2) UNRELEASED; urgency=medium
protozero (1.6.2-1) unstable; urgency=medium
* New upstream release.
* Update copyright-format URL to use HTTPS.
* Don't use libjs-jquery for Doxygen docs.
* Bump Standards-Version to 4.1.3, no changes.
-- Bas Couwenberg <sebastic@debian.org> Sun, 21 Jan 2018 10:29:25 +0100
-- Bas Couwenberg <sebastic@debian.org> Fri, 09 Mar 2018 20:39:21 +0100
protozero (1.6.1-1) unstable; urgency=medium
......
......@@ -10,7 +10,7 @@ Build-Depends: debhelper (>= 9),
libprotobuf-dev,
protobuf-compiler,
pkg-config
Standards-Version: 4.1.1
Standards-Version: 4.1.3
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-grass/protozero.git/
Vcs-Git: https://anonscm.debian.org/git/pkg-grass/protozero.git
Homepage: https://github.com/mapbox/protozero
......@@ -40,8 +40,7 @@ Description: Minimalistic protocol buffer decoder and encoder in C++
Package: libprotozero-doc
Architecture: all
Section: doc
Depends: libjs-jquery,
${misc:Depends}
Depends: ${misc:Depends}
Description: Minimalistic protocol buffer decoder and encoder in C++ - docs
protozero is a minimalistic protocol buffer decoder and encoder in C++.
.
......
usr/share/javascript/jquery/jquery.js usr/share/doc/libprotozero-doc/html/jquery.js
......@@ -16,11 +16,10 @@ documentation.
* @brief Contains functions to swap bytes in values (for different endianness).
*/
#include <cassert>
#include <cstdint>
#include <protozero/config.hpp>
#include <cstdint>
namespace protozero {
namespace detail {
......
......@@ -16,14 +16,14 @@ documentation.
* @brief Contains the implementation of the data_view class.
*/
#include <protozero/config.hpp>
#include <algorithm>
#include <cstddef>
#include <cstring>
#include <string>
#include <utility>
#include <protozero/config.hpp>
namespace protozero {
#ifdef PROTOZERO_USE_VIEW
......@@ -64,7 +64,7 @@ public:
*
* @param str String with the data.
*/
data_view(const std::string& str) noexcept // NOLINT clang-tidy: google-explicit-constructor
data_view(const std::string& str) noexcept // NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
: m_data(str.data()),
m_size(str.size()) {
}
......@@ -74,7 +74,7 @@ public:
*
* @param ptr Pointer to the data.
*/
data_view(const char* ptr) noexcept // NOLINT clang-tidy: google-explicit-constructor
data_view(const char* ptr) noexcept // NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
: m_data(ptr),
m_size(std::strlen(ptr)) {
}
......
......@@ -29,7 +29,9 @@ namespace protozero {
*/
struct exception : std::exception {
/// Returns the explanatory string.
const char* what() const noexcept override { return "pbf exception"; }
const char* what() const noexcept override {
return "pbf exception";
}
};
/**
......@@ -38,7 +40,9 @@ struct exception : std::exception {
*/
struct varint_too_long_exception : exception {
/// Returns the explanatory string.
const char* what() const noexcept override { return "varint too long exception"; }
const char* what() const noexcept override {
return "varint too long exception";
}
};
/**
......@@ -47,7 +51,9 @@ struct varint_too_long_exception : exception {
*/
struct unknown_pbf_wire_type_exception : exception {
/// Returns the explanatory string.
const char* what() const noexcept override { return "unknown pbf field type exception"; }
const char* what() const noexcept override {
return "unknown pbf field type exception";
}
};
/**
......@@ -60,7 +66,9 @@ struct unknown_pbf_wire_type_exception : exception {
*/
struct end_of_buffer_exception : exception {
/// Returns the explanatory string.
const char* what() const noexcept override { return "end of buffer exception"; }
const char* what() const noexcept override {
return "end of buffer exception";
}
};
/**
......@@ -71,7 +79,9 @@ struct end_of_buffer_exception : exception {
*/
struct invalid_tag_exception : exception {
/// Returns the explanatory string.
const char* what() const noexcept override { return "invalid tag exception"; }
const char* what() const noexcept override {
return "invalid tag exception";
}
};
/**
......@@ -81,7 +91,9 @@ struct invalid_tag_exception : exception {
*/
struct invalid_length_exception : exception {
/// Returns the explanatory string.
const char* what() const noexcept override { return "invalid length exception"; }
const char* what() const noexcept override {
return "invalid length exception";
}
};
} // end namespace protozero
......
......@@ -16,11 +16,6 @@ documentation.
* @brief Contains the iterators for access to packed repeated fields.
*/
#include <algorithm>
#include <cstring>
#include <iterator>
#include <utility>
#include <protozero/config.hpp>
#include <protozero/varint.hpp>
......@@ -28,6 +23,11 @@ documentation.
# include <protozero/byteswap.hpp>
#endif
#include <algorithm>
#include <cstring>
#include <iterator>
#include <utility>
namespace protozero {
/**
......@@ -306,7 +306,7 @@ public:
// significant bit not set. We can use this to quickly figure out
// how many varints there are without actually decoding the varints.
return std::count_if(begin.m_data, end.m_data, [](char c) noexcept {
return (static_cast<unsigned char>(c) & 0x80) == 0;
return (static_cast<unsigned char>(c) & 0x80u) == 0;
});
}
......@@ -410,42 +410,42 @@ namespace std {
template <>
inline typename protozero::const_varint_iterator<int32_t>::difference_type
distance<protozero::const_varint_iterator<int32_t>>(protozero::const_varint_iterator<int32_t> first, // NOLINT clang-tidy: readability-inconsistent-declaration-parameter-name
distance<protozero::const_varint_iterator<int32_t>>(protozero::const_varint_iterator<int32_t> first, // NOLINT(readability-inconsistent-declaration-parameter-name)
protozero::const_varint_iterator<int32_t> last) {
return protozero::const_varint_iterator<int32_t>::distance(first, last);
}
template <>
inline typename protozero::const_varint_iterator<int64_t>::difference_type
distance<protozero::const_varint_iterator<int64_t>>(protozero::const_varint_iterator<int64_t> first, // NOLINT clang-tidy: readability-inconsistent-declaration-parameter-name
distance<protozero::const_varint_iterator<int64_t>>(protozero::const_varint_iterator<int64_t> first, // NOLINT(readability-inconsistent-declaration-parameter-name)
protozero::const_varint_iterator<int64_t> last) {
return protozero::const_varint_iterator<int64_t>::distance(first, last);
}
template <>
inline typename protozero::const_varint_iterator<uint32_t>::difference_type
distance<protozero::const_varint_iterator<uint32_t>>(protozero::const_varint_iterator<uint32_t> first, // NOLINT clang-tidy: readability-inconsistent-declaration-parameter-name
distance<protozero::const_varint_iterator<uint32_t>>(protozero::const_varint_iterator<uint32_t> first, // NOLINT(readability-inconsistent-declaration-parameter-name)
protozero::const_varint_iterator<uint32_t> last) {
return protozero::const_varint_iterator<uint32_t>::distance(first, last);
}
template <>
inline typename protozero::const_varint_iterator<uint64_t>::difference_type
distance<protozero::const_varint_iterator<uint64_t>>(protozero::const_varint_iterator<uint64_t> first, // NOLINT clang-tidy: readability-inconsistent-declaration-parameter-name
distance<protozero::const_varint_iterator<uint64_t>>(protozero::const_varint_iterator<uint64_t> first, // NOLINT(readability-inconsistent-declaration-parameter-name)
protozero::const_varint_iterator<uint64_t> last) {
return protozero::const_varint_iterator<uint64_t>::distance(first, last);
}
template <>
inline typename protozero::const_svarint_iterator<int32_t>::difference_type
distance<protozero::const_svarint_iterator<int32_t>>(protozero::const_svarint_iterator<int32_t> first, // NOLINT clang-tidy: readability-inconsistent-declaration-parameter-name
distance<protozero::const_svarint_iterator<int32_t>>(protozero::const_svarint_iterator<int32_t> first, // NOLINT(readability-inconsistent-declaration-parameter-name)
protozero::const_svarint_iterator<int32_t> last) {
return protozero::const_svarint_iterator<int32_t>::distance(first, last);
}
template <>
inline typename protozero::const_svarint_iterator<int64_t>::difference_type
distance<protozero::const_svarint_iterator<int64_t>>(protozero::const_svarint_iterator<int64_t> first, // NOLINT clang-tidy: readability-inconsistent-declaration-parameter-name
distance<protozero::const_svarint_iterator<int64_t>>(protozero::const_svarint_iterator<int64_t> first, // NOLINT(readability-inconsistent-declaration-parameter-name)
protozero::const_svarint_iterator<int64_t> last) {
return protozero::const_svarint_iterator<int64_t>::distance(first, last);
}
......
......@@ -16,11 +16,11 @@ documentation.
* @brief Contains the pbf_builder template class.
*/
#include <type_traits>
#include <protozero/pbf_writer.hpp>
#include <protozero/types.hpp>
#include <type_traits>
namespace protozero {
/**
......
......@@ -16,11 +16,11 @@ documentation.
* @brief Contains the pbf_message template class.
*/
#include <type_traits>
#include <protozero/pbf_reader.hpp>
#include <protozero/types.hpp>
#include <type_traits>
namespace protozero {
/**
......@@ -77,7 +77,7 @@ public:
* parent class.
*/
template <typename... Args>
pbf_message(Args&&... args) noexcept : // NOLINT clang-tidy: google-explicit-constructor
pbf_message(Args&&... args) noexcept : // NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
pbf_reader(std::forward<Args>(args)...) {
}
......
......@@ -16,12 +16,6 @@ documentation.
* @brief Contains the pbf_reader class.
*/
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <string>
#include <utility>
#include <protozero/config.hpp>
#include <protozero/data_view.hpp>
#include <protozero/exception.hpp>
......@@ -33,6 +27,12 @@ documentation.
# include <protozero/byteswap.hpp>
#endif
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <string>
#include <utility>
namespace protozero {
/**
......@@ -117,9 +117,9 @@ class pbf_reader {
}
m_data += len;
#ifndef NDEBUG
// In debug builds reset the tag to zero so that we can detect (some)
// wrong code.
#ifndef NDEBUG
m_tag = 0;
#endif
}
......@@ -241,7 +241,7 @@ public:
* are still fields available and to `false` if the last field has been
* read.
*/
operator bool() const noexcept { // NOLINT clang-tidy: google-explicit-constructor
operator bool() const noexcept { // NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
return m_data < m_end;
}
......@@ -279,7 +279,7 @@ public:
}
const auto value = get_varint<uint32_t>();
m_tag = pbf_tag_type(value >> 3);
m_tag = 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
......@@ -287,7 +287,7 @@ public:
throw invalid_tag_exception{};
}
m_wire_type = pbf_wire_type(value & 0x07);
m_wire_type = pbf_wire_type(value & 0x07u);
switch (m_wire_type) {
case pbf_wire_type::varint:
case pbf_wire_type::fixed64:
......
......@@ -16,15 +16,6 @@ documentation.
* @brief Contains the pbf_writer class.
*/
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <initializer_list>
#include <iterator>
#include <limits>
#include <string>
#include <utility>
#include <protozero/config.hpp>
#include <protozero/data_view.hpp>
#include <protozero/types.hpp>
......@@ -34,6 +25,15 @@ documentation.
# include <protozero/byteswap.hpp>
#endif
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <initializer_list>
#include <iterator>
#include <limits>
#include <string>
#include <utility>
namespace protozero {
namespace detail {
......@@ -78,8 +78,8 @@ class pbf_writer {
}
void add_field(pbf_tag_type tag, pbf_wire_type type) {
protozero_assert(((tag > 0 && tag < 19000) || (tag > 19999 && tag <= ((1 << 29) - 1))) && "tag out of range");
const uint32_t b = (tag << 3) | uint32_t(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);
add_varint(b);
}
......
......@@ -16,6 +16,8 @@ documentation.
* @brief Contains the declaration of low-level types used in the pbf format.
*/
#include <protozero/config.hpp>
#include <algorithm>
#include <cstddef>
#include <cstdint>
......@@ -23,8 +25,6 @@ documentation.
#include <string>
#include <utility>
#include <protozero/config.hpp>
namespace protozero {
/**
......@@ -40,8 +40,7 @@ using pbf_tag_type = uint32_t;
enum class pbf_wire_type : uint32_t {
varint = 0, // int32/64, uint32/64, sint32/64, bool, enum
fixed64 = 1, // fixed64, sfixed64, double
length_delimited = 2, // string, bytes, embedded messages,
// packed repeated fields
length_delimited = 2, // string, bytes, nested messages, packed repeated fields
fixed32 = 5, // fixed32, sfixed32, float
unknown = 99 // used for default setting in this library
};
......@@ -54,7 +53,7 @@ enum class pbf_wire_type : uint32_t {
*/
template <typename T>
constexpr inline uint32_t tag_and_type(T tag, pbf_wire_type wire_type) noexcept {
return (static_cast<uint32_t>(static_cast<pbf_tag_type>(tag)) << 3) | static_cast<uint32_t>(wire_type);
return (static_cast<uint32_t>(static_cast<pbf_tag_type>(tag)) << 3u) | static_cast<uint32_t>(wire_type);
}
/**
......
......@@ -16,10 +16,10 @@ documentation.
* @brief Contains low-level varint and zigzag encoding and decoding functions.
*/
#include <cstdint>
#include <protozero/exception.hpp>
#include <cstdint>
namespace protozero {
/**
......@@ -39,22 +39,22 @@ namespace detail {
if (iend - begin >= max_varint_length) { // fast path
do {
int64_t b;
b = *p++; val = uint64_t((b & 0x7f) ); if (b >= 0) { break; }
b = *p++; val |= uint64_t((b & 0x7f) << 7); if (b >= 0) { break; }
b = *p++; val |= uint64_t((b & 0x7f) << 14); if (b >= 0) { break; }
b = *p++; val |= uint64_t((b & 0x7f) << 21); if (b >= 0) { break; }
b = *p++; val |= uint64_t((b & 0x7f) << 28); if (b >= 0) { break; }
b = *p++; val |= uint64_t((b & 0x7f) << 35); if (b >= 0) { break; }
b = *p++; val |= uint64_t((b & 0x7f) << 42); if (b >= 0) { break; }
b = *p++; val |= uint64_t((b & 0x7f) << 49); if (b >= 0) { break; }
b = *p++; val |= uint64_t((b & 0x7f) << 56); if (b >= 0) { break; }
b = *p++; val |= uint64_t((b & 0x01) << 63); if (b >= 0) { break; }
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; }
throw varint_too_long_exception{};
} while (false);
} else {
int shift = 0;
unsigned int shift = 0;
while (p != iend && *p < 0) {
val |= uint64_t(*p++ & 0x7f) << shift;
val |= uint64_t(*p++ & 0x7fu) << shift;
shift += 7;
}
if (p == iend) {
......@@ -88,7 +88,7 @@ namespace detail {
*/
inline uint64_t decode_varint(const char** data, const char* end) {
// If this is a one-byte varint, decode it here.
if (end != *data && ((**data & 0x80) == 0)) {
if (end != *data && ((**data & 0x80u) == 0)) {
const auto val = static_cast<uint64_t>(**data);
++(*data);
return val;
......@@ -145,9 +145,9 @@ template <typename T>
inline int write_varint(T data, uint64_t value) {
int n = 1;
while (value >= 0x80) {
*data++ = char((value & 0x7f) | 0x80);
value >>= 7;
while (value >= 0x80u) {
*data++ = char((value & 0x7fu) | 0x80u);
value >>= 7u;
++n;
}
*data++ = char(value);
......@@ -159,28 +159,28 @@ inline int write_varint(T data, uint64_t value) {
* ZigZag encodes a 32 bit integer.
*/
inline constexpr uint32_t encode_zigzag32(int32_t value) noexcept {
return (static_cast<uint32_t>(value) << 1) ^ (static_cast<uint32_t>(value >> 31));
return (static_cast<uint32_t>(value) << 1u) ^ (static_cast<uint32_t>(value >> 31u));
}
/**
* ZigZag encodes a 64 bit integer.
*/
inline constexpr uint64_t encode_zigzag64(int64_t value) noexcept {
return (static_cast<uint64_t>(value) << 1) ^ (static_cast<uint64_t>(value >> 63));
return (static_cast<uint64_t>(value) << 1u) ^ (static_cast<uint64_t>(value >> 63u));
}
/**
* Decodes a 32 bit ZigZag-encoded integer.
*/
inline constexpr int32_t decode_zigzag32(uint32_t value) noexcept {
return static_cast<int32_t>(value >> 1) ^ -static_cast<int32_t>(value & 1);
return static_cast<int32_t>(value >> 1u) ^ -static_cast<int32_t>(value & 1u);
}
/**
* Decodes a 64 bit ZigZag-encoded integer.
*/
inline constexpr int64_t decode_zigzag64(uint64_t value) noexcept {
return static_cast<int64_t>(value >> 1) ^ -static_cast<int64_t>(value & 1);
return static_cast<int64_t>(value >> 1u) ^ -static_cast<int64_t>(value & 1u);
}
} // end namespace protozero
......