From dbf620770d692d2ce2d9ea29a0c5826b3e65cb25 Mon Sep 17 00:00:00 2001 From: Fabien Date: Thu, 14 Jan 2021 11:22:51 +0100 Subject: [PATCH] [LINTER] Fix a couple cppcheck issues Summary: This diff adds 2 cppcheck exceptions: - One for a bug with the current debian version (1.86): ``` Error (CPPCHECK) containerOutOfBounds Out of bounds access in expression 'test.at(1)' because 'test' is empty and 'at' may be non-zero. 48 bool sanity_test_range_fmt() { 49 std::string test; 50 try { >>> 51 test.at(1); ^ 52 } catch (const std::out_of_range &) { 53 return true; 54 } catch (...) { ``` - One issue which is a false positive that we create deliberately for a sanity check. This one is not found by Debian's version but is by the ArchLinux version (2.3). Test Plan: On Debian (1.86) and Arch (2.3): arc lint --everything Reviewers: #bitcoin_abc, PiRK Reviewed By: #bitcoin_abc, PiRK Differential Revision: https://reviews.bitcoinabc.org/D8909 --- arcanist/linter/CppCheckLinter.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arcanist/linter/CppCheckLinter.php b/arcanist/linter/CppCheckLinter.php index 56bd2c67fc..f2e53cbcdb 100644 --- a/arcanist/linter/CppCheckLinter.php +++ b/arcanist/linter/CppCheckLinter.php @@ -34,9 +34,19 @@ final class CppCheckLinter extends ArcanistExternalLinter { "Class 'CCoinsViewCache' has a constructor with 1 argument that is not explicit.", "Class 'CCoinsViewCursor' has a constructor with 1 argument that is not explicit.", ), + "src/compat/glibcxx_sanity.cpp" => array( + // This is a deliberate sanity check and not a real issue + "Out of bounds access in expression 'test.at(1)' because 'test' is empty and 'at' may be non-zero.", + ), "src/cuckoocache.h" => array( "Struct 'KeyOnly' has a constructor with 1 argument that is not explicit.", ), + "src/init.cpp" => array( + // This is a cppcheck issue, occurring on Debian Buster's version 1.86. + // This no longer occurs with version 2.3, and maybe other earlier + // versions (untested). FIXME: remove when the bug is fixed. + "Syntax Error: AST broken, binary operator '=' doesn't have two operands.", + ), "src/net.h" => array( "Class 'CNetMessage' has a constructor with 1 argument that is not explicit.", ),