Commit Graph

192 Commits

Author SHA1 Message Date
Swasti Shrivastava 04ece4f65b
Fix #12079: Misra: calling unknown function in condition => false pos… (#5568)
…itive 14.4, missing misra-config warning
2023-10-19 19:38:20 +02:00
Swasti Shrivastava ad4e688ff8
Fix #10652: FP: misra-c2012-10.4 (char)'1' != (char) (#5556) 2023-10-16 18:53:51 +02:00
Swasti Shrivastava dde956b085
Fix 10855,11752:False positive: misra-c2012-22.10 (#5557) 2023-10-15 17:33:35 +02:00
Daniel Marjamäki cc44966fb5
std.cfg: remove wrong macro replacements for UINT32_C etc. (#5527)
The replacements should be platform dependent.
2023-10-08 14:44:07 +02:00
Daniel Marjamäki 204e75dc59
Fixed #11909 (misra addon: rule 1.2 detect some gcc language extensions) (#5390) 2023-09-01 16:44:14 +02:00
Tim Blume b70e1df26c
fix crash while checking misra_9 when initializing a union with {{0,0}} (#5250)
This fixes a crash with following error:
```
Traceback (most recent call last):
  File "/usr/local/share/Cppcheck/addons/runaddon.py", line 8, in <module>
    runpy.run_path(addon, run_name='__main__')
  File "<frozen runpy>", line 291, in run_path
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/share/Cppcheck/addons/misra.py", line 4737, in <module>
    main()
  File "/usr/local/share/Cppcheck/addons/misra.py", line 4679, in main
    checker.parseDump(item)
  File "/usr/local/share/Cppcheck/addons/misra.py", line 4335, in parseDump
    self.executeCheck(902, self.misra_9_2, cfg)
  File "/usr/local/share/Cppcheck/addons/misra.py", line 4246, in executeCheck
    check_function(*args)
  File "/usr/local/share/Cppcheck/addons/misra.py", line 2104, in misra_9_2
    misra_9.misra_9_x(self, data, 902)
  File "/usr/local/share/Cppcheck/addons/misra_9.py", line 414, in misra_9_x
    parser.parseInitializer(ed, eq.astOperand2)
  File "/usr/local/share/Cppcheck/addons/misra_9.py", line 320, in parseInitializer
    child = self.root.getChildByValueElement(self.ed)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'getChildByValueElement'
```

A minimal example and testcase is added. 
The extra check for nextChild seems to fix it, however i did not read
the whole codebase, so maybe this creates other issues.

---------

Co-authored-by: Tim Blume <tbl@sevenstax-intern.de>
2023-08-31 09:38:03 +02:00
Daniel Marjamäki 18b526b08a
CI: Fix selfcheck cppcheck warnings (#5359) 2023-08-22 14:49:08 +02:00
andymacg 5a136c3f38
Fix #11877 FP misra 10.4 On array member comparison (#5342)
I also changed the comment header to run tests on misra-test-avr8.c
because I thought that was the intention to use it like misra-test.c; if
not, I can revert.
2023-08-22 12:18:12 +02:00
andymacg 5bb4c6f5bc
Fix #11878 FP misra-c2012-18.7 on function pointer parameter with array-type args (#5343)
https://trac.cppcheck.net/ticket/11878#ticket
2023-08-22 12:03:12 +02:00
chrchr-github 7f22ef4e14
Set ValueType for auto with ternary (#5304) 2023-08-18 10:33:26 +02:00
Daniel Marjamäki 3508464c6d
dump: fix dump output for typedef info, file is <stdout> (#5236) 2023-07-12 11:21:59 +02:00
Daniel Marjamäki 9c5275f514
misra: fix 9.x checking when string literals are used to initialize char arrays (#5234) 2023-07-11 17:57:55 +02:00
Daniel Marjamäki 80c42fcaf3
misra: Fix crash in misra_9.py when struct type is unknown and there is string initialization (#5233) 2023-07-11 13:40:19 +02:00
Daniel Marjamäki a04990d4e3
misra 9.2: do not crash when checking. string literal is allowed to initialize array member. (#5232) 2023-07-10 22:50:24 +02:00
Daniel Marjamäki 2cd1f0f387
misra: Fix crash in misra_9x when there is unknown constant used as array size (#5229) 2023-07-10 12:25:28 +02:00
Daniel Marjamäki 276aace331
Misra: Fix crash (#5228) 2023-07-09 19:17:59 +02:00
Daniel Marjamäki 260a214ef1
Fix #11812 (Crash: misra addon, infinite recursion) (#5207) 2023-07-04 04:11:03 +02:00
Daniel Marjamäki 91dedf05b5
Fix #11793 (False positive: Misra addon crash for struct initialization when struct has a function pointer array) (#5190) 2023-06-25 11:37:49 +02:00
Daniel Marjamäki 6b9fac41f4
Fixed #11734 (stylistic warnings from addons are not filtered when style is not enabled) (#5091) 2023-05-27 10:24:00 +02:00
Daniel Marjamäki 2cb4c4126a
Fix #11443 (FP: misra-c2012-5.7 on anonymous struct) (#5033) 2023-05-07 20:22:26 +02:00
Daniel Marjamäki 4cf9a704b4
Fixed #11707 (False positive: misra 9.3 partial array initializations) (#5034) 2023-05-05 17:22:58 +02:00
apuly 30ff1aad9a
misra: fix misra-3_1 false positive for URIs in block comments (#4939)
* misra: fix misra-3_1 false positive for URIs in block comments

* added unit test, improved new misra 3.1 based on false positives

---------

Co-authored-by: Paul B <unconfigured@null.spigotmc.org>
2023-04-11 16:13:10 +02:00
Daniel Marjamäki 5830047fcb misra: fix misra-10.7 false positive for constant expression 2023-01-02 18:52:33 +01:00
g-chauvel be658e2392
misra_14_2 various fixes (#4324) 2022-08-21 20:11:10 +02:00
Daniel Marjamäki 13c80d6cce Fixed #11180 (False positive: misra-c2012-8.1 for code 'unsigned x;') 2022-07-28 20:34:56 +02:00
Daniel Marjamäki 359f6b3680 misra: enable more checks for misra c++ 2008 checking 2022-06-07 20:55:55 +02:00
Daniel Marjamäki ec13f5fe5c misra: When checking C++ code only activate certain misra c++ compliant rules. It will be supported to run the addon on C++ code. 2022-06-06 22:22:52 +02:00
Daniel Marjamäki 8dbc1b802a misra: fix crash 2022-05-17 22:15:49 +02:00
Daniel Marjamäki b444c002e2 Fixed #11000 (misra: crash) 2022-05-03 22:03:35 +02:00
Daniel Marjamäki ea63b8e2bb misra: fix void parameter check 2022-04-01 21:34:47 +02:00
Paul Fultz II 5bea50cd36
Fix 10908: FP: uninitvar after for-loop (#3942) 2022-03-31 21:24:20 +02:00
Paul Fultz II 32ded1602b
Fix warnings in switch statements on clang (#3943) 2022-03-30 19:30:02 +02:00
Daniel Marjamäki a6c1653ed2 Fixed #10853 (False positive: misra-c2012-16.3: macro parameter "default") 2022-03-13 19:58:27 +01:00
Daniel Marjamäki df2c8f3a65 Fixed #10862 (Misplaced warning: misra-2.2: macros) 2022-03-13 13:15:38 +01:00
José Martins b1e92fc399
Misra false positive fixes for rules 8.7 and 5.9 (#3844)
* Fix misra 8.7 false positives on single function usage

When there is a single usage of a function, we should first check if the
file it is used in, is the same one it was defined in. When this is not the
case, there is no violatior to be reported.

* Fix misra rule 5.9 false positives for exception

The exception for rule 5.9 described in the guidelines allows for
multiple definitions of internal linkage obejcts when these regard a
static inlined function defined in the same header file.

* Fix neglecting of inline keyword flag upon simplifications

When the inline keyword is being "simplified" and the inline flag is
degated to the next token. However, this information might be lost if the next
token itself is simplified/deleted in a futher pass. Therefore, we must
propagated the flag to all the next named tokens, so we can make sure the
function name token itself is tagged with this property.

* add tests for misra addon rules 8.7 and 5.9
2022-02-27 19:17:48 +01:00
Daniel Marjamäki 68b00b3cfc misra: fix 7.2 checking 2022-02-12 12:44:44 +01:00
Daniel Marjamäki 515649217f fix 2022-02-12 07:47:26 +01:00
Daniel Marjamäki 31f16d01d6 fix in misra test code 2022-01-18 20:59:30 +01:00
Daniel Marjamäki 5ebcd1dd52 misra; update test there was a warning about missing return 2022-01-18 20:55:30 +01:00
Daniel Marjamäki 5491670792 Fixed #10528 (FP: misra-c2012-8.4) 2021-12-22 18:55:28 +01:00
Daniel Marjamäki 593683ab69 Fixed #9459 (MISRA Rule 2.2: Find dead code in arithmetic operators) 2021-11-17 17:44:54 +01:00
Daniel Marjamäki 4f9a563570 Fixed #10583 (False positive: misra-15.6) 2021-11-15 21:27:36 +01:00
Daniel Marjamäki 2a64ad8dbb Fixed #10481 (misra.py: Bailing out from checking test.c since there was an internal error: Failed to ...) 2021-09-25 21:53:55 +02:00
Daniel Marjamäki 3c1ae77962 Fixed #10499 (FP: misra-c2012-10.4) 2021-09-23 10:44:38 +02:00
Dani Martin f01ffddca6
Fix in MISRA rule 6.1 check (#3458) 2021-09-22 19:25:02 +02:00
Daniel Marjamäki 4ad09f181a Fixed #10480 (FP: misra-c2012-10.4 (char)) 2021-09-22 13:02:11 +02:00
Daniel Marjamäki 47ea670eb3 Fixed #10486 (FP: misra-c2012-8.4) 2021-09-20 21:27:05 +02:00
Daniel Marjamäki adb703c09d Fixed #10487 (FP: misra-c2012-10.6 (bit fields)) 2021-09-20 20:27:43 +02:00
Daniel Marjamäki ee475b181d Fixed #10488 (FP: misra-c2012-10.7) 2021-09-19 20:22:30 +02:00
Daniel Marjamäki a6c98e9e60 Fixed #10482 (FP: misra-c2012-12.2) 2021-09-17 14:21:25 +02:00