Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions other/docker/pvs/pvs.Dockerfile
Original file line number Diff line number Diff line change
@@ -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="[email protected]" 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
23 changes: 23 additions & 0 deletions other/docker/pvs/pvs.Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions other/docker/pvs/run
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 2 additions & 2 deletions toxcore/crypto_core_test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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<uint32_t>(byte);
}
out << '"';
return out;
Expand Down
2 changes: 1 addition & 1 deletion toxcore/test_util.hh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ template <typename T, std::size_t N>
std::array<T, N> to_array(T const (&arr)[N])
{
std::array<T, N> stdarr;
std::copy(arr, arr + N, stdarr.begin());
std::copy(arr, &arr[N], stdarr.begin());
return stdarr;
}

Expand Down