flipperzero-firmware
flipperzero-firmware copied to clipboard
[FL-2811] Fix PVS-Studio warnings
What's new
- Fix warnings generated by PVS-Studio by fixing the problems and suppressing the false positives either globally via the
.pvsconfigfile or via special comments in the code. - Refactor some code (without changing its functionality).
- Add
float_is_equalfunction within thefloat_toolslibrary for safe equality test for float values.
Verification
- Prepare the firmware:
./fbt COMPACT=1 version_json proto_ver icons firmware_cdb dolphin_internal dolphin_blocking _fap_icons api_syms
- Run pvs-studio:
./run-pvs.sh(see attached file). - Open
pvs-reports/index.html. No warnings should be present. - Run unit tests?
- 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