diff --git a/.github/workflows/precheck.yaml b/.github/workflows/precheck.yaml index c609850..f04056c 100644 --- a/.github/workflows/precheck.yaml +++ b/.github/workflows/precheck.yaml @@ -17,7 +17,25 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y build-essential cmake cpplint + sudo apt-get install -y \ + build-essential \ + cmake \ + cpplint \ + clang-tidy \ + clang-format \ + libcurl4-openssl-dev \ + libfftw3-dev - name: Check cpplint - run: cpplint --recursive lib include \ No newline at end of file + run: cpplint $(git ls-files '*.cpp' '*.h') + + - name: Check clang-tidy + run: | + cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON . + clang-tidy -p build/compile_commands.json $(git ls-files '*.cpp' '*.h' | grep -v 'wasm.cpp') + + # TODO(BayernMuller): Add clang-format check + # - name: Check clang-format + # run: | + # clang-format --dry-run --Werror $(git ls-files '*.cpp' '*.h') + diff --git a/lib/utils/crc32.h b/lib/utils/crc32.h index 1f38fe5..40cffe6 100644 --- a/lib/utils/crc32.h +++ b/lib/utils/crc32.h @@ -1,26 +1,29 @@ #ifndef LIB_UTILS_CRC32_H_ #define LIB_UTILS_CRC32_H_ +#include +#include + namespace crc32 { std::uint32_t crc32(const char *buf, std::size_t len) { std::uint32_t crc_table[256]; std::uint32_t crc; - std::size_t i, j; - for (i = 0; i < 256; i++) + for (std::size_t i = 0; i < 256; i++) { crc = i; - for (j = 0; j < 8; j++) + for (std::size_t j = 0; j < 8; j++) crc = crc & 1 ? (crc >> 1) ^ 0xEDB88320UL : crc >> 1; crc_table[i] = crc; - }; + } crc = 0xFFFFFFFFUL; while (len--) + { crc = crc_table[(crc ^ *buf++) & 0xFF] ^ (crc >> 8); - + } return crc ^ 0xFFFFFFFFUL; } } // namespace crc32