Commit Graph

170 Commits

Author SHA1 Message Date
Daniel Marjamäki a810678b83 Addons: handle inline suppressions internally in cppcheckdata 2020-12-05 11:37:09 +01:00
Daniel Marjamäki 02d927f0f9 Temporarily disable misra suppressions test 2020-12-04 21:16:02 +01:00
Ivar Andreas Bonsaksen 9029fff59d
Fixed #9993 (false positive: misra-c2012-9.2) (#2908) 2020-11-18 10:50:35 +01:00
Ivar Andreas Bonsaksen 0e7ec1eddf
Fixed #9988 (false positive: misra-c2012-9.2) (#2904) 2020-11-16 17:31:00 +01:00
kskjerve 4d3f76b63c
MISRA rule 9.2 The initializer for an aggregate or union shall be enclosed in braces (#2899) 2020-11-16 09:27:17 +01:00
Daniel Marjamäki 43c4a48d48 Fixed #9971 (missing system includes in addon/test test files) 2020-11-15 12:46:28 +01:00
Lars Even Almaas 3a91b998d6
MISRA rule 10.2 Expressions of essentially character type in additions and subtraction (#2897) 2020-11-12 11:37:28 +01:00
Daniel Marjamäki 2ae91b9ffe Try to fix addon suppressions tests 2020-11-11 20:28:26 +01:00
Lars Even Almaas 9d70926fcd
MISRA rule 15.4 Only one break/goto from iteration statement (#2892) 2020-11-09 15:11:08 +01:00
Georgy Komarov 9cbb09076c
misra.py: Fix R7.2 crash on va_args (#2886) 2020-11-05 23:54:12 +01:00
Lars Even Almaas c1212f823f
MISRA rule 7.2 Require 'u' prefix when using large unsigned integer constants (#2881) 2020-11-05 13:38:09 +01:00
Georgy Komarov 6f7f508967
misra.py: Fix 7.4 false positive (#2883)
Fix false positives for the function calls with "const pointer to const
value" arguments: https://trac.cppcheck.net/ticket/9967.

The variable.valueType.constness have same encoding as encoding as
ValueType::constness in Cppcheck.
2020-11-05 08:13:23 +01:00
Lars Even Almaas 05b804d126
MISRA Rule 7.4 Check if variables assigned as string literals are const (#2866) 2020-11-04 13:45:02 +01:00
Georgy Komarov b87aaaac52
Fix and impove MISRA 6.1 and 6.2 rules (#2863) 2020-10-28 20:54:43 +01:00
Lars Even Almaas 79b9dd5345
MISRA Rule 6.1/6.2 Bit field check (#2861) 2020-10-27 16:00:19 +01:00
amai2012 2fa837c716
threadsafety shall not warn about const vars (in C++11) (#2847)
threadsafety shall not warn about const vars (in C++11) 
For C++03 a new id threadsafety-const was created.
2020-10-23 11:58:25 +02:00
Georgy Komarov 3944e70e02
misra.py: Treat enum constants as constant known at compile time (#2823)
C89 standard defines enum members as enumeration contants at ch.
6.4.4.3, and they are always known at compile time.

This commit fix false positives for rule 18.8 (and possible other rules
that check "constentess") with enumeration members.

Fix Trac#9913
2020-09-25 21:02:34 +02:00
Daniel Marjamäki 6e4085f3d8 Misra: Write 12.3 warnings in structs/classes 2020-09-08 09:29:57 +02:00
Daniel Marjamäki f3fa7a6f5e misra: updated test addons/test/misra/misra-test.cpp 2020-09-06 13:25:37 +02:00
Georgy Komarov 4738da3d69
misra.py: Fix R12.3 FP on calling functions in function arguments (#2778) 2020-09-05 07:53:56 +02:00
Georgy Komarov 3bae716fd4
misra.py: Fix 20.7 false positive for multi-character arguments
See: https://trac.cppcheck.net/ticket/9633#comment:3
2020-08-08 13:03:19 +03:00
Georgy Komarov dc1faa71ed
misra.py: Fix false negatives in string concatenation for rule 20.7
This will fix Trac#9633
2020-07-24 07:15:40 +03:00
Georgy Komarov fc504ed6c3
misra.py: Fix false positives on macro expansion
This will fix Trac#9634
2020-07-21 20:03:04 +03:00
Carl-Oskar Larsson 2abf542838
Misra severity (#2674) 2020-06-08 15:58:17 +02:00
Georgy Komarov 90550d24c4
misra.py: Fix crash on volatile macro argument (#2654) 2020-05-21 08:34:28 +02:00
Ken-Patrick Lehrmann a96a879b6d
Fix crash in addons/test/test-misra.py (#2652) 2020-05-20 16:02:13 +02:00
Georgy Komarov 61926ed7c3
misra.py: Fix false positive for rule 15.6 (#2631) 2020-05-07 16:54:27 +02:00
Georgy Komarov 20b02bff30
misra.py: Fix 20.7 FP for struct members (#2624)
This will close Trac#9673
2020-04-27 09:10:58 +02:00
Georgy Komarov 4e5a8fac4a
misra.py: Handle stdint.h essential types (#2555)
Add stdint.h essential types to misra.py checks. This will fix false
negatives for rules 10.6 and 10.8.
2020-02-27 11:28:48 +01:00
Georgy Komarov 9155f3a83a
misra.py: Check switch-clauses in R15.3 (#2538)
* misra.py: Check switch-clauses in R15.3

* break on violation
2020-02-16 00:03:18 +01:00
Georgy Komarov 2138091fa3
misra.py: Fix rule 20.2 false negative (#2534) 2020-02-12 17:11:56 +01:00
Georgy Komarov 403a61bc11
misra.py: Handle spaces in directive arguments (#2532) 2020-02-11 20:59:11 +01:00
Daniel Marjamäki 099dd57eb8 Fixed #9625 (false negative: misra-c2012-13.1) 2020-02-11 18:00:41 +01:00
Georgy Komarov 0ff23dbd0b misra.py: Handle more cases in Rule 20.3 check (#2529)
This commit add two additional cases for rule 20.3:

1. Support violations in the following format: `#include file.h`
2. Better multiline include directives and inline comments support.

See added test cases for examples.
2020-02-10 08:56:26 +01:00
Georgy Komarov f438cc6105
misra.py: Fix rule 21.1 false positives (#2526)
According MISRA standard, rule 21.1 should hanlde define/undef
directives only. There are no mentions of other C identifiers in the
standard document.
2020-02-09 16:22:26 +01:00
Georgy Komarov 6d4eff46be
misra.py: Fix false negative for rule 20.4 (#2528)
Define different sets of reserved keywords for C90 and C99.
This will fix false negative for compliant example, defined in MISRA
document, and close trac 9506.
2020-02-09 10:46:13 +01:00
Georgy Komarov 86d0f62d36 misra.py: Fix 12.3 FP in initializer lists (#2489)
See: trac 9581
2020-01-15 09:55:59 +01:00
Georgy Komarov 730ea4163b misra.py: Handle essential type categories for ternary operations (#2455)
This commit will add feature to detect essential type categories
for operators of ternary operation.

This fixes issues with rule 10.1 and close the following ticket:
https://trac.cppcheck.net/ticket/9543
2019-12-21 07:40:15 +01:00
Georgy Komarov aadb35888f misra.py: Fix 12.3 FP (#2454)
This will close https://trac.cppcheck.net/ticket/9544
2019-12-19 15:55:51 +01:00
Georgy Komarov d0dd200444 misra.py: Fix R12.3 false negative in variables declaration (#2453)
Make rule 12.3 check detect commas in the variables declaration code.
2019-12-19 08:36:10 +01:00
Daniel Marjamäki 7977bbf456 Revert "misra.py: Fix R12.3 false negative in variables declaration (#2431)"
This reverts commit 7ce8ae408a.
2019-12-18 13:31:52 +01:00
Georgy Komarov 7ce8ae408a misra.py: Fix R12.3 false negative in variables declaration (#2431)
* misra.py: Allow executeCheck take multiple args

* misra.py: Fix R12.3 FN in variables declaration

Make rule 12.3 check detect commas in variables declaration code.

* Fix excluded lines

* Add support for global variables

* Fix FN when linenr from other file was excluded

* Add a few more tests

* Handle more cases

Handle additional cases to check commans in variables declaration
including:
* multiline variables declaration
* functions and structures initialized in the same line
* expanding macroses in initialization

* Fix FP in global struct initialization

* Add another test
2019-12-18 11:05:57 +01:00
Georgy Komarov c46e44e39e misra.py: R14.2: Verify for loop counter modification (#2409)
* misra.py: R14.2: Verify for counter modification

Add additional check to detect modification of loop counter in loop
body. Related issue: https://trac.cppcheck.net/ticket/9490

Add small fix that treat all assignment operators defined in N1750
6.5.16 as has side affects. This will affects rules 13.1, 13.3, 13.5
and allow to catch some false negatives.

* Add tests for fixed FPs for R13.{1,5,6}

* fix

* use isAssignmentOp from cppcheck data

* remove unused set

* handle case with empty body or syntax error

* add test with outer variable

* Fix FP in nested loops, add tests

* Fix FP on outer variables

* Fixup false positives for not loop counters
2019-12-15 18:23:12 +01:00
Georgy Komarov f87cd9818c misra.py: Fix false negative for rule 10.1 (#2449)
This will close Trac 9489.
2019-12-15 18:10:22 +01:00
Daniel Marjamäki 5e07528af5 Fixed #9505 (MISRA 20.7 check suggests code change that leads to invalid code) 2019-12-14 16:31:41 +01:00
Francesc Elies 40aefa1ba4 [windows] cannot run test-misra (binary not found) (#2441)
set PYTHONPATH=addons
    python -m pytest addons/test/test-misra.py
2019-12-10 18:32:41 +01:00
Daniel Marjamäki 3d3e6f384c Fix #9505 (MISRA 20.7 check suggests code change that leads to invalid code) 2019-12-08 20:07:52 +01:00
Daniel Marjamäki 4a4b6fe39b MISRA: Remove rule 5.3, Cppcheck core has these warnings 2019-12-08 19:01:51 +01:00
Daniel Marjamäki 55afaebdac Fixed #9506 (false positive: MISRA 12.4) 2019-12-08 18:52:52 +01:00
Sebastian fb96e5433a
y2038 addon: Fix that check can never return True, add tests (#2417)
* y2038 addon: Fix that check can never return True, add tests

At the beginning of `check_y2038_safe()` the variable `y2038safe` should
be initialized with `True` and only be set to `False` if there are any
issues. Otherwise it could never become `True`.
In the unit tests the return value of `check_y2038_safe()` is now
verified. But it does not yet work for the "good" example. The "good"
example also returns `False` since it finds warnings in the include
file. So this verification is marked with a "FIXME" comment.

* y2038 tests: Add "good" test file that does not use time functionality

The test file y2038-test-5-good-no-time-used.c does not use any time
functionality so the y2038 addon is not allowed to issue any warnings
and the check must return with `True` (code is safe).
2019-12-03 18:49:11 +01:00