flipperzero-firmware icon indicating copy to clipboard operation
flipperzero-firmware copied to clipboard

[FL-2811] Fix PVS-Studio warnings

Open gsurkov opened this issue 3 years ago • 2 comments

What's new

  • Fix warnings generated by PVS-Studio by fixing the problems and suppressing the false positives either globally via the .pvsconfig file or via special comments in the code.
  • Refactor some code (without changing its functionality).
  • Add float_is_equal function within the float_tools library for safe equality test for float values.

Verification

  1. Prepare the firmware:
./fbt COMPACT=1 version_json proto_ver icons firmware_cdb dolphin_internal dolphin_blocking _fap_icons api_syms
  1. Run pvs-studio: ./run-pvs.sh (see attached file).
  2. Open pvs-reports/index.html. No warnings should be present.
  3. Run unit tests?
  4. Use the firmware and hope that it doesn't break.

PVS-Studio launch script

#!/bin/bash

set -e

SRC_DIR='flipperzero-firmware'
REPORTS_DIR='pvs-reports'

if [ -d "$REPORTS_DIR" ]; then rm -rf "$REPORTS_DIR"; fi

cd "$SRC_DIR"

. scripts/toolchain/fbtenv.sh
pvs-studio-analyzer analyze @.pvsoptions -C gccarm -j $(nproc) -f build/f7-firmware-DC/compile_commands.json  --ignore-ccache
plog-converter -a GA:1,2,3 -t fullhtml PVS-Studio.log -o "../$REPORTS_DIR"

cd ..

Checklist (For Reviewer)

  • [ ] PR has description of feature/bug or link to Confluence/Jira task
  • [ ] Description contains actions to verify feature/bugfix
  • [ ] I've built this code, uploaded it to the device and verified feature/bugfix

gsurkov avatar Dec 16 '22 18:12 gsurkov

PVS-Studio report for commit 7e9b55cc:

github-actions[bot] avatar Dec 16 '22 18:12 github-actions[bot]

Compiled firmware for commit 7e9b55cc:

github-actions[bot] avatar Dec 16 '22 18:12 github-actions[bot]