Make the MISRA addon emit extra warnings for unused arguments placed in
lines other than the function definition. This makes it easier for the
user to find violations.
The MISRA 2012 standard does not say anything about variadic functions
in the definition of rule 2.7. Therefore, these cases should be
considered as false positives.
The example code that reproduces this crash:
```
int misra_8_2_o(
const uint32_t a1,
const uint8_t *const a2
)
{ return *a2 + a1; }
int misra_8_2_p(
const uint32_t a1,
const uint8_t *const a2
);
```
The unit test was not added because it looks like a typo and regressions
are unlikely.
* misra: Fix 8.2 false positives
Fix false positives in rule 8.2 that occurred in cases when we have a
function definition and declaration in the same file.
For example, the following code generated false positives before this
commit:
```
void f(uint8_t * const x);
void f(uint8_t * const x)
{ (void)x; }
```
We need to distinguish the declaration and the definition, so the dump
file generation routine was extended to keep token where the definition
of the function. The analysis in the addon also been improved.
Closes Trac issue: https://trac.cppcheck.net/ticket/10219
This commit allows to specify expected suppressions in the included
header files. This is necessary to verify MISRA checkers, which make
requirements for header files. For example, Rule 8.2 requires adding
prototypes for each function to the header files.
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.
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
When we include the header file with variables definitions, Cppcheck
will write `variables` entries with line numbers from the header to the
dump file.
If the line number in the header file and the source file are equal,
misra.py performs an additional check what leads to false positives.
Minimal example that demonstrates the problem:
`misra_fp.c`:
```c
void test_12_3_fp(void)
{
//Initialize the events queue
QEQueue_init(&me->deferred_event_queue, me->deferred_events_queue_buf, Q_DIM(me->deferred_events_queue_buf));
}
```
`misra_fp.h`:
```c
static const uint32_t timer_max_blocking_call_us;
```
This commit closes trac ticket 9874.
When checking multiple files if the same violation is encountered from
an included file then the violation is both displayed and counted in the
error summary.
Track each violation by location and error number and if the violation
has been previously encountered then do not report it again.
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.
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.
* parser: Parse standards node at start event
This required, because we can loose data at the end event.
* misra.py: Fix 5.4 standard-dependent error
By default Cppcheck use C11 standard, so this change fix false positives
for rule 5.4 with C99.
* travis: force --std=c89 for misra.py
* addons: Reduce memory consumption
Parse dump files incrementaly using ElementTree.iterparse. Clean unused
resources during parsing. This method is explained in following
article: https://www.ibm.com/developerworks/xml/library/x-hiperfparse/
Memory consumption was reduced about 30% (measured with mprof),
execution time increased about 5% (measured with time utility).
More description available in PR.
* Switch to lxml and update iterparse routines
Use lxml module instead default xml.etree. Lxml provides convenient
wrappers around iterparse method that accepts `tag` argument. That
easer incremental parsing routines to select specific tags from roottree
like `dump` and `dumps`.
Element.clear() method was replaced by `lxml_clean` because lxml
keeps additional information to nodes that should be removed.
Added note about large consumption RAM on large dump files.
This commit doesn't solve this problem completely, but provides a way
to improve current parser to add incremental Configuration serialization
later.
* Working on iterative parser
* Added iterative Configurations parser
* fix
* Fix varlist iteration
* make sure that standards node was loaded
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
* 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
* 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