diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ad43c2a..eeffafdf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -491,6 +491,7 @@ if(RUN_CLANG_TIDY) "cppcoreguidelines-macro-usage" "cppcoreguidelines-narrowing-conventions" "cppcoreguidelines-no-malloc" + "cppcoreguidelines-pro-bounds-array-to-pointer-decay" "cppcoreguidelines-pro-bounds-constant-array-index" "cppcoreguidelines-pro-bounds-pointer-arithmetic" "cppcoreguidelines-pro-type-const-cast" diff --git a/src/api/helpers/crc.cpp b/src/api/helpers/crc.cpp index aa9bc647..abee0014 100644 --- a/src/api/helpers/crc.cpp +++ b/src/api/helpers/crc.cpp @@ -55,17 +55,17 @@ uint32_t GetCrc32(const std::filesystem::path& filename) { std::ifstream ifile(filename, std::ios::binary); ifile.exceptions(std::ios_base::badbit | std::ios_base::failbit); - static const size_t bufferSize = 8192; - char buffer[bufferSize]; + static constexpr size_t BUFFER_SIZE = 8192; + std::array buffer; boost::crc_32_type result; size_t bytesLeft = GetStreamSize(ifile); while (bytesLeft > 0) { - if (bytesLeft > bufferSize) - ifile.read(buffer, bufferSize); + if (bytesLeft > buffer.size()) + ifile.read(buffer.data(), buffer.size()); else - ifile.read(buffer, bytesLeft); + ifile.read(buffer.data(), bytesLeft); - result.process_bytes(buffer, ifile.gcount()); + result.process_bytes(buffer.data(), ifile.gcount()); bytesLeft -= ifile.gcount(); }