Skip to content

Commit dbd04a9

Browse files
committed
Fix todos etc
1 parent 261102c commit dbd04a9

14 files changed

Lines changed: 81 additions & 59 deletions

‎.github/workflows/cppcheck-premium.yml‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
name: selfcheck-premium
2+
name: cppcheck-premium
33

44
on:
55
push:
@@ -19,15 +19,15 @@ jobs:
1919
runs-on: ubuntu-22.04 # run on the latest image only
2020

2121
env:
22-
PREMIUM_VERSION: devdrop-20231104
22+
PREMIUM_VERSION: devdrop-20231105
2323

2424
steps:
2525
- uses: actions/checkout@v3
2626

2727
- name: Download cppcheckpremium
2828
run: |
29-
wget https://files.cppchecksolutions.com/cppcheckpremium-devdrop-20231104-amd64.tar.gz
30-
tar xzvf cppcheckpremium-devdrop-20231104-amd64.tar.gz
29+
wget https://files.cppchecksolutions.com/cppcheckpremium-${{ env.PREMIUM_VERSION }}-amd64.tar.gz
30+
tar xzf cppcheckpremium-${{ env.PREMIUM_VERSION }}-amd64.tar.gz
3131
3232
- name: Generate a license file
3333
run: |
@@ -37,7 +37,7 @@ jobs:
3737
echo 57e08c39523ab54d >> cppcheck.lic
3838
echo path:lib >> cppcheck.lic
3939
40-
- name: Self check
40+
- name: Check
4141
run: |
42-
cppcheckpremium-devdrop-20231104/premiumaddon --check-loc-license cppcheck.lic > cppcheck-premium-loc
43-
cppcheckpremium-devdrop-20231104/cppcheck -D__GNUC__ -D__CPPCHECK__ --suppressions-list=cppcheckpremium-suppressions --platform=unix64 --enable=style --premium=misra-c++-2008 --premium=cert-c++-2016 lib
42+
cppcheckpremium-${{ env.PREMIUM_VERSION }}/premiumaddon --check-loc-license cppcheck.lic > cppcheck-premium-loc
43+
cppcheckpremium-${{ env.PREMIUM_VERSION }}/cppcheck -j$(nproc) -D__GNUC__ -D__CPPCHECK__ --suppressions-list=cppcheckpremium-suppressions --platform=unix64 --enable=style --premium=misra-c++-2008 --premium=cert-c++-2016 --error-exitcode=1 lib

‎cppcheckpremium-suppressions‎

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
11

2-
#FIXME False positives
3-
premium-misra-cpp-2008-4-5-1
2+
# False positives
43
premium-misra-cpp-2008-5-17-1
5-
premium-misra-cpp-2008-12-1-2
6-
premium-misra-cpp-2008-3-3-1
7-
premium-misra-cpp-2008-12-8-2
8-
premium-cert-exp55-cpp
94
premium-misra-cpp-2008-5-0-6
10-
11-
# TODO
12-
premium-misra-cpp-2008-8-4-4
13-
premium-misra-cpp-2008-18-0-2
14-
premium-misra-cpp-2008-9-3-1
15-
premium-cert-err60-cpp
16-
premium-misra-cpp-2008-2-10-4
17-
premium-misra-cpp-2008-4-5-2
185
premium-misra-cpp-2008-7-2-1
6+
premium-misra-cpp-2008-2-10-4
197
premium-misra-cpp-2008-3-3-2
20-
premium-misra-cpp-2008-16-2-3
21-
premium-cert-err56-cpp
22-
premium-misra-cpp-2008-14-5-2
23-
premium-misra-cpp-2008-5-0-12
24-
premium-cert-err61-cpp
8+
premium-misra-cpp-2008-8-4-4
259

2610
# open source warnings are handled by the selfcheck.yml
2711
noExplicitConstructor
@@ -32,12 +16,24 @@ useStlAlgorithm
3216
# we need to declare reserved identifier _CRTDBG_MAP_ALLOC
3317
premium-cert-dcl51-cpp
3418

19+
# TODO: Is there unsafe allocations, in case of exceptions) in cppcheck
20+
premium-cert-err58-cpp
21+
3522
# we have global objects
3623
premium-cert-err58-cpp
3724

25+
# TODO: Exception objects must be nothrow copy constructible.
26+
premium-cert-err60-cpp
27+
28+
# TODO should we throw Token?
29+
premium-cert-err61-cpp
30+
3831
# TODO: Detect errors when converting a string to a number. The library function 'atoi()' shall not be used.
3932
premium-cert-err62-cpp
4033

34+
# TODO: Can we reduce some const_cast?
35+
premium-cert-exp55-cpp
36+
4137
# sometimes a void function does not have side effects
4238
premium-misra-cpp-2008-0-1-8
4339

@@ -58,6 +54,9 @@ premium-misra-cpp-2008-2-10-1
5854
# flag |= ..
5955
premium-misra-cpp-2008-4-5-1
6056

57+
# Token/Variable flags are enum constants and we use those in bitwise operations by intention.
58+
premium-misra-cpp-2008-4-5-2
59+
6160
# intentional addition of char to string: const std::string end(':' + cfg + ':' + Path::simplifyPath(sourcefile));
6261
premium-misra-cpp-2008-4-5-3
6362

@@ -73,6 +72,9 @@ premium-misra-cpp-2008-5-0-5
7372
# intentional addition of char literal: c = 'a' + (temp - 10);
7473
premium-misra-cpp-2008-5-0-11
7574

75+
# conversion of char-to-int is intentional sometimes
76+
premium-misra-cpp-2008-5-0-12
77+
7678
# pointer-to-bool conversion is common
7779
premium-misra-cpp-2008-5-0-14
7880

@@ -134,6 +136,9 @@ premium-misra-cpp-2008-8-0-1
134136
# cppcheck does not care about this enumerator rule
135137
premium-misra-cpp-2008-8-5-3
136138

139+
# TODO Fix these
140+
premium-misra-cpp-2008-9-3-1
141+
137142
# we use unions by intention sometimes
138143
premium-misra-cpp-2008-9-5-1
139144

@@ -143,6 +148,9 @@ premium-misra-cpp-2008-10-3-1
143148
# some classes have public members by intention
144149
premium-misra-cpp-2008-11-0-1
145150

151+
# rule should not apply to deleted copy assignment operator
152+
premium-misra-cpp-2008-12-8-2
153+
146154
# TODO: this can be fixed by refactoring the code.
147155
premium-misra-cpp-2008-14-6-2
148156

@@ -155,6 +163,9 @@ premium-misra-cpp-2008-16-2-1
155163
premium-misra-cpp-2008-16-2-2
156164
premium-misra-cpp-2008-16-3-2
157165

166+
# TODO do we need to catch string conversion errors (using atoi)?
167+
premium-misra-cpp-2008-18-0-2
168+
158169
# what standard alternative is there for std::getenv
159170
premium-misra-cpp-2008-18-0-3
160171

‎lib/analyzer.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ struct Analyzer {
3333
struct Action {
3434

3535
Action() = default;
36+
Action(const Action&) = default;
37+
Action& operator=(const Action& rhs) = default;
3638

3739
template<class T,
3840
REQUIRES("T must be convertible to unsigned int", std::is_convertible<T, unsigned int> ),

‎lib/astutils.cpp‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,7 +2241,7 @@ bool isScopeBracket(const Token* tok)
22412241
}
22422242

22432243
template<class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*> )>
2244-
T* getTokenArgumentFunctionImpl(T* tok, int& argn)
2244+
static T* getTokenArgumentFunctionImpl(T* tok, int& argn)
22452245
{
22462246
argn = -1;
22472247
{
@@ -2892,13 +2892,13 @@ const Token* findThisChanged(const Token* start, const Token* end, int indirect,
28922892
}
28932893

28942894
template<class Find>
2895-
const Token* findExpressionChangedImpl(const Token* expr,
2896-
const Token* start,
2897-
const Token* end,
2898-
const Settings* settings,
2899-
bool cpp,
2900-
int depth,
2901-
Find find)
2895+
static const Token* findExpressionChangedImpl(const Token* expr,
2896+
const Token* start,
2897+
const Token* end,
2898+
const Settings* settings,
2899+
bool cpp,
2900+
int depth,
2901+
Find find)
29022902
{
29032903
if (depth < 0)
29042904
return start;
@@ -3095,7 +3095,7 @@ const Token *findLambdaStartToken(const Token *last)
30953095
}
30963096

30973097
template<class T>
3098-
T* findLambdaEndTokenGeneric(T* first)
3098+
static T* findLambdaEndTokenGeneric(T* first)
30993099
{
31003100
auto maybeLambda = [](T* tok) -> bool {
31013101
while (Token::Match(tok, "*|%name%|::|>")) {

‎lib/checkcondition.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ static bool checkFloatRelation(const std::string &op, const double value1, const
995995
}
996996

997997
template<class T>
998-
T getvalue3(const T value1, const T value2)
998+
static T getvalue3(const T value1, const T value2)
999999
{
10001000
const T min = std::min(value1, value2);
10011001
if (min== std::numeric_limits<T>::max())

‎lib/checkers.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19-
#pragma once
19+
#ifndef checkersH
20+
#define checkersH
2021

2122
#include <map>
2223
#include <string>
@@ -44,4 +45,4 @@ namespace checkers {
4445
extern CPPCHECKLIB const std::map<std::string, std::string> misraRuleSeverity;
4546
}
4647

47-
48+
#endif

‎lib/checkersreport.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19-
#pragma once
19+
#ifndef checkersReportH
20+
#define checkersReportH
2021

2122
#include "config.h"
2223

@@ -44,4 +45,4 @@ class CPPCHECKLIB CheckersReport {
4445
int mAllCheckersCount = 0;
4546
};
4647

47-
48+
#endif

‎lib/checknullpointer.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ namespace {
574574

575575
Check::FileInfo *CheckNullPointer::getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const
576576
{
577-
const std::list<CTU::FileInfo::UnsafeUsage> &unsafeUsage = CTU::getUnsafeUsage(tokenizer, settings, isUnsafeUsage);
577+
const std::list<CTU::FileInfo::UnsafeUsage> &unsafeUsage = CTU::getUnsafeUsage(tokenizer, settings, &isUnsafeUsage);
578578
if (unsafeUsage.empty())
579579
return nullptr;
580580

‎lib/checkother.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2384,7 +2384,7 @@ namespace {
23842384
functionsByName[func.tokenDef->str()].push_back(&func);
23852385
}
23862386
for (std::pair<const std::string, std::list<const Function*>>& it : functionsByName) {
2387-
const std::list<const Function*>::const_iterator nc = std::find_if(it.second.cbegin(), it.second.cend(), notconst);
2387+
const std::list<const Function*>::const_iterator nc = std::find_if(it.second.cbegin(), it.second.cend(), &notconst);
23882388
if (nc == it.second.cend()) {
23892389
// ok to add all of them
23902390
constFunctions.splice(constFunctions.end(), it.second);

‎lib/checkuninitvar.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,7 @@ namespace {
17111711

17121712
Check::FileInfo *CheckUninitVar::getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const
17131713
{
1714-
const std::list<CTU::FileInfo::UnsafeUsage> &unsafeUsage = CTU::getUnsafeUsage(tokenizer, settings, ::isVariableUsage);
1714+
const std::list<CTU::FileInfo::UnsafeUsage> &unsafeUsage = CTU::getUnsafeUsage(tokenizer, settings, &::isVariableUsage);
17151715
if (unsafeUsage.empty())
17161716
return nullptr;
17171717

0 commit comments

Comments
 (0)