diff --git a/other/docker/pvs/pvs.Dockerfile b/other/docker/pvs/pvs.Dockerfile new file mode 100644 index 0000000000..70321f3fba --- /dev/null +++ b/other/docker/pvs/pvs.Dockerfile @@ -0,0 +1,56 @@ +FROM ubuntu:22.04 + +RUN apt-get update && \ + DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \ + ca-certificates \ + cmake \ + curl \ + gcc \ + g++ \ + libconfig-dev \ + libopus-dev \ + libsodium-dev \ + libvpx-dev \ + ninja-build \ + strace \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN curl -o pvs-studio.deb https://cdn.pvs-studio.com/pvs-studio-7.29.79138.387-amd64.deb \ + && dpkg -i pvs-studio.deb \ + && rm pvs-studio.deb +ARG LICENSE_USER="iphydf@gmail.com" LICENSE_KEY="" +RUN pvs-studio-analyzer credentials "$LICENSE_USER" "$LICENSE_KEY" + +WORKDIR /work/c-toxcore +COPY . /work/c-toxcore/ + +RUN cmake . -B_build -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DENABLE_SHARED=OFF + +# MISRA +RUN echo 'analysis-mode=32' > pvs.cfg +RUN pvs-studio-analyzer analyze --cfg pvs.cfg -f _build/compile_commands.json -j"$(nproc)" -o misra.log + +# General Analysis +RUN echo 'analysis-mode=0' > pvs.cfg +RUN pvs-studio-analyzer analyze --cfg pvs.cfg -f _build/compile_commands.json -j"$(nproc)" -o pvs.log + +# Show MISRA errors +RUN plog-converter \ + -E "other;testing;toxav;third_party" \ + -d "V2501,V2511,V2514,V2516,V2519,V2520,V2537,V2547,V2568,V2571,V2572,V2575,V2578,V2594,V2611,V2614,V2620" \ + -a "MISRA:1,2" \ + -t "tasklist" \ + -o "misra.tasks" \ + "misra.log" +RUN cat misra.tasks + +# Show MISRA errors +RUN plog-converter \ + -E "other;testing;toxav;third_party" \ + -d "V501,V547,V641,V802,V1037,V1042,V1051,V1086" \ + -a "GA:1,2,3;OP:1,2,3" \ + -t "tasklist" \ + -o "pvs.tasks" \ + "pvs.log" +RUN cat pvs.tasks diff --git a/other/docker/pvs/pvs.Dockerfile.dockerignore b/other/docker/pvs/pvs.Dockerfile.dockerignore new file mode 100644 index 0000000000..3a3643cba1 --- /dev/null +++ b/other/docker/pvs/pvs.Dockerfile.dockerignore @@ -0,0 +1,23 @@ +# ===== common ===== +# Ignore everything ... +**/* +# ... except sources +!**/*.[ch] +!**/*.cc +!**/*.hh +!CHANGELOG.md +!LICENSE +!README.md +!auto_tests/data/* +!other/bootstrap_daemon/bash-completion/** +!other/bootstrap_daemon/tox-bootstrapd.* +!other/proxy/*.mod +!other/proxy/*.sum +!other/proxy/*.go +# ... and CMake build files (used by most builds). +!**/CMakeLists.txt +!.github/scripts/flags*.sh +!cmake/*.cmake +!other/pkgconfig/* +!other/rpm/* +!so.version diff --git a/other/docker/pvs/run b/other/docker/pvs/run new file mode 100755 index 0000000000..f0efc3ba52 --- /dev/null +++ b/other/docker/pvs/run @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +DOCKERFLAGS=("--build-arg" "LICENSE_KEY=$(echo -n "$(cat $HOME/.pvs-license)")") +. "$(cd "$(dirname "${BASH_SOURCE[0]}")/../sources" && pwd)/run.sh" diff --git a/toxcore/crypto_core_test_util.cc b/toxcore/crypto_core_test_util.cc index b48871a538..d3ea202b54 100644 --- a/toxcore/crypto_core_test_util.cc +++ b/toxcore/crypto_core_test_util.cc @@ -13,7 +13,7 @@ Random_Funcs const Random_Class::vtable = { Random_Class::~Random_Class() = default; -void Test_Random::random_bytes(void *obj, uint8_t *bytes, size_t length) +void Test_Random::random_bytes(void *obj, uint8_t bytes[], size_t length) { std::generate(bytes, &bytes[length], std::ref(lcg)); } @@ -35,7 +35,7 @@ std::ostream &operator<<(std::ostream &out, PublicKey const &pk) { out << '"'; for (uint8_t byte : pk) { - out << std::setw(2) << std::setfill('0') << std::hex << uint32_t(byte); + out << std::setw(2) << std::setfill('0') << std::hex << static_cast(byte); } out << '"'; return out; diff --git a/toxcore/test_util.hh b/toxcore/test_util.hh index 08bc948272..3072f2623f 100644 --- a/toxcore/test_util.hh +++ b/toxcore/test_util.hh @@ -37,7 +37,7 @@ template std::array to_array(T const (&arr)[N]) { std::array stdarr; - std::copy(arr, arr + N, stdarr.begin()); + std::copy(arr, &arr[N], stdarr.begin()); return stdarr; }