From 62f5f248be04cdb6a1d53655864286960c25b819 Mon Sep 17 00:00:00 2001 From: Jens Yllman Date: Tue, 28 Jul 2020 22:19:27 +0200 Subject: [PATCH 1/4] use simplifyPath() to make sure file name is same as in the checks --- lib/suppressions.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/suppressions.cpp b/lib/suppressions.cpp index c5fb02126..7d16038ae 100644 --- a/lib/suppressions.cpp +++ b/lib/suppressions.cpp @@ -373,6 +373,7 @@ void Suppressions::dump(std::ostream & out) const std::list Suppressions::getUnmatchedLocalSuppressions(const std::string &file, const bool unusedFunctionChecking) const { + std::string tmp_file = Path::simplifyPath(file); std::list result; for (const Suppression &s : mSuppressions) { if (s.matched) @@ -381,7 +382,7 @@ std::list Suppressions::getUnmatchedLocalSuppressions continue; if (!unusedFunctionChecking && s.errorId == "unusedFunction") continue; - if (file.empty() || !s.isLocal() || s.fileName != file) + if (tmp_file.empty() || !s.isLocal() || s.fileName != tmp_file) continue; result.push_back(s); } From 10ac0bcf541b4a19d5f6b835e08590f199c9cb50 Mon Sep 17 00:00:00 2001 From: Jens Yllman Date: Wed, 29 Jul 2020 12:13:21 +0200 Subject: [PATCH 2/4] changed variable name to match guidelines --- lib/suppressions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/suppressions.cpp b/lib/suppressions.cpp index 7d16038ae..5ee25511d 100644 --- a/lib/suppressions.cpp +++ b/lib/suppressions.cpp @@ -373,7 +373,7 @@ void Suppressions::dump(std::ostream & out) const std::list Suppressions::getUnmatchedLocalSuppressions(const std::string &file, const bool unusedFunctionChecking) const { - std::string tmp_file = Path::simplifyPath(file); + std::string tmpFile = Path::simplifyPath(file); std::list result; for (const Suppression &s : mSuppressions) { if (s.matched) @@ -382,7 +382,7 @@ std::list Suppressions::getUnmatchedLocalSuppressions continue; if (!unusedFunctionChecking && s.errorId == "unusedFunction") continue; - if (tmp_file.empty() || !s.isLocal() || s.fileName != tmp_file) + if (tmpFile.empty() || !s.isLocal() || s.fileName != tmpFile) continue; result.push_back(s); } From 1cc16deba34c021a71f049fe3c6f12254cb8e711 Mon Sep 17 00:00:00 2001 From: Jens Yllman Date: Thu, 30 Jul 2020 22:22:54 +0200 Subject: [PATCH 3/4] test added to show it works after fix --- test/cli/test-inline-suppress.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/cli/test-inline-suppress.py b/test/cli/test-inline-suppress.py index c94c493af..9f635d662 100644 --- a/test/cli/test-inline-suppress.py +++ b/test/cli/test-inline-suppress.py @@ -19,3 +19,8 @@ def test_unmatched_suppression(): ret, stdout, stderr = cppcheck(['--inline-suppr', '--enable=information', '--error-exitcode=1', 'proj-inline-suppress/2.c']) assert ret == 1 assert 'Unmatched suppression: some_warning_id' in stderr + +def test_unmatched_suppression_2(): + ret, stdout, stderr = cppcheck(['--inline-suppr', '--enable=information', '--error-exitcode=1', './proj-inline-suppress/2.c']) + assert ret == 1 + assert 'Unmatched suppression: some_warning_id' in stderr From 5ba5916a116c6312be366ede99e3c6a3a72ce845 Mon Sep 17 00:00:00 2001 From: Jens Yllman Date: Mon, 3 Aug 2020 10:30:21 +0200 Subject: [PATCH 4/4] clearer name on the test --- test/cli/test-inline-suppress.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cli/test-inline-suppress.py b/test/cli/test-inline-suppress.py index 9f635d662..579748997 100644 --- a/test/cli/test-inline-suppress.py +++ b/test/cli/test-inline-suppress.py @@ -20,7 +20,7 @@ def test_unmatched_suppression(): assert ret == 1 assert 'Unmatched suppression: some_warning_id' in stderr -def test_unmatched_suppression_2(): +def test_unmatched_suppression_path_with_extra_stuf(): ret, stdout, stderr = cppcheck(['--inline-suppr', '--enable=information', '--error-exitcode=1', './proj-inline-suppress/2.c']) assert ret == 1 assert 'Unmatched suppression: some_warning_id' in stderr