Commit Graph

21798 Commits

Author SHA1 Message Date
fu7mu4 e7f929e5dd update translation in Ja (#2426) 2019-12-05 13:26:58 +01:00
amai2012 7fdaa4ae89 Sync dmake and Makefile (change missing from 3a71eb834d) 2019-12-04 20:27:48 +01:00
Dmitry-Me 571de5844f Improve test coverage for functions returning bool values 2019-12-04 18:12:10 +03:00
versat e712df7cb4 Run astyle [ci skip] 2019-12-04 13:53:10 +01:00
John Marshall 297efcd049 Avoid some additional memleakOnRealloc false positives (#2422)
* Avoid some additional memleakOnRealloc false positives

checkReallocUsage() already contains code to suppress the
`p = realloc(p, size)` error message when the pointer has been
previously copied from another variable (hence there is an additional
copy of the original pointer value) within the same function, as in
the added realloc21() test case.

Extend this so that `p = *pp` and `p = ptr->foo` are also recognized
as copies from another variable with the same original pointer value,
as in the added realloc22() and realloc23() test cases.

* Rewrite as a single findmatch() expression
2019-12-04 12:13:44 +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
Dmitry-Me cf7ef2e703 Valid code for incrementing raw pointer (#2418) 2019-12-03 18:33:05 +01:00
Paul Fultz II 36977becba Fix issue 9196: Lambda confuses check (#2415) 2019-12-03 18:30:52 +01:00
amai2012 0e8a145d6c Run astyle 2019-12-02 22:04:22 +01:00
amai2012 3a71eb834d Run xmllint on cppcheck-errors.rng. Speed up creation of example XML output for validateXML target 2019-12-02 22:03:59 +01:00
Dmitry-Me b14a976c6c Improve test coverage for postfix increment of raw pointers 2019-12-02 18:12:14 +03:00
Paul Fultz II 78b4485670 Regression for issue 8653: valueFlowAfterCondition: compound conditional (#2416) 2019-12-02 11:35:51 +01:00
Paul Fultz II 9cb39b1d7e Fix issue 9482: False positive: Reference to temporary returned using trailing return type (#2413) 2019-12-01 15:10:02 +01:00
Paul Fultz II 2bdb7dc236 Fix issue 9390: valueFlowTerminatingCondition bailout: Skipping function due to incomplete variable NULL (#2412)
* Fix issue 9390: valueFlowTerminatingCondition bailout: Skipping function due to incomplete variable NULL

* Uncomment keyword

* Add nullptr as well
2019-12-01 15:09:21 +01:00
Georgy Komarov 6bacc1987c misra.py: Fix R12.4 and R13.1 crashes on large initializer lists (#2410)
Fixed usage of hasSideEffectsRecursive which was causes crashes
of rules 12.4 and 13.1.

Add more tests for these rules.

See trac ticket: https://trac.cppcheck.net/ticket/9487
2019-12-01 15:03:33 +01:00
Paul Fultz II f77347d7b4 Fix crash 9492: Crash in FwdAnalysis::checkRecursive() (condTok is nullptr) (#2411)
* Fix crash 9492: Crash in FwdAnalysis::checkRecursive() (condTok is nullptr)

* Formatting
2019-12-01 14:53:03 +01:00
Georgy Komarov c1770414ba misra.py: Fix crash on c++ code (#2414) 2019-12-01 14:51:12 +01:00
Paul Fultz II a71f58ffc2 Fix issue 9441: false positive: new(std::nothrow) and nullPointerRedundantCheck (#2403)
* Fix issue 9441: false positive: new(std::nothrow) and nullPointerRedundantCheck

* Skip new if it is a variable
2019-12-01 12:16:31 +01:00
Sebastian 95bbc7a1e2
GUI: Print and log messages when addon execution fails (#2408)
This adds an entry to the "Analysis Log" and prints a message via
`qWarning()` when the execution of an addon fails because either the
process failed to finish normally (for example if python binary is not
found) or because the script has issues (for example because of an
unhandled exception).
2019-11-30 12:58:06 +01:00
Sebastian 8d114a40e4
misra-test.c: Add more tests for rule 14.2 (including FP and FN) (#2399)
Adding more tests for rule 14.2 revealed a false negative when the
loop counter is changed inside the loop.
Corresponding line in the example suite:
https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/blob/master/R_14_02.c#L39
Also a false positive has been revealed when the loop counter is
initialized in a function that is called in the first `for` clause.
Corresponding line in the example suite:
https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/blob/master/R_14_02.c#L43
2019-11-30 11:27:31 +01:00
Sebastian c942c24289
GUI: Fix and update translation files (#2404)
The Korean language file was missing the "language" attribute, so it was
no longer updated before.
The Russian language file had the attribute "sourcelanguage" set to
"ru_RU" which does not make sense and led to some wrong/strange entries.
The France and Korean translation files were missing the "location"
entries, so the GUI-preview with the translated text was not shown and
there were no references to the source-code.
All these errors are fixed.
For the German file I translated the new hint about addons requiring
Python being installed.
2019-11-30 11:20:49 +01:00
Georgy Komarov bd6f236481 misra.py: Fix 5.3 FP (#2405)
* misra.py: Fix 5.3 FP

This will close https://trac.cppcheck.net/ticket/9497

* fix names conflict

* fix naming
2019-11-30 10:05:57 +01:00
Paul Fultz II 79a2e61721 Fix issue 6850: Valueflow: pointer alias, conditional value (#2402) 2019-11-30 09:22:03 +01:00
Adrien Chardon 91dd8d3b6f Improve cli --help (#2387) 2019-11-29 11:29:04 +01:00
Paul Fultz II f9d33c07f8 Fix issue 9458: Crash with shadow variables in a lambda (#2406)
* Fix issue 9458: Crash with shadow variables in a lambda

* Format
2019-11-29 09:45:02 +01:00
IOBYTE f554a71dea fix #9495 (Crash when parsing angle brackets in template with type traits (assertion failure)) (#2407) 2019-11-29 09:44:27 +01:00
Daniel Marjamäki 676a837af6 Fixed #9335 (FP constStatement "Found a statement that begins with string constant") 2019-11-28 17:49:33 +01:00
Dmitry-Me ff36ebcff2 Improve test coverage for testing AST 2019-11-28 18:11:55 +03:00
Sebastian fd900ab8b2 testnullpointer.cpp: Add test for dereferencing returned NULL pointer (#2401)
This adds a regression test to make sure that directly dereferencing a
returned NULL pointer issues a warning.
This has been asked on Stack Overflow:
https://stackoverflow.com/q/58981369
Cppcheck 1.89 does not warn for such a code, but 1.90 dev does. So it
is a good idea to make sure it is detected in the future too I guess.
2019-11-27 19:41:36 +01:00
Dmitry-Me 8af2ee968e Fix incorrect usage of "unlikely" hint 2019-11-27 18:08:10 +03:00
Dmitry-Me 45e617f50b Fix -Wint-conversion warning 2019-11-27 18:08:10 +03:00
Sebastian e46191e6e8
misra-test.c: Add more tests for rule 10.1 (including FP and FN) (#2398)
Add some more tests for rule 10.1. They are given as examples in the
MISRA document. The 10.1 test that causes a false positive for 10.6 can be
found under the 10.6 tests.
Track ticket for false positive:
https://trac.cppcheck.net/ticket/9488
Trac ticket for the false negative:
https://trac.cppcheck.net/ticket/9489
2019-11-27 09:09:17 +01:00
Daniel Marjamäki 937c82efbe AST: initializer list with lambda 2019-11-27 06:44:58 +01:00
Dmitry-Me 8f72a714d1 Fix -Wint-conversion warning 2019-11-26 18:03:47 +03:00
Bo Rydberg e6d692d960 Fix daca2 using latest version of package (#2393)
* Add semver import for sorting ls-lR list

* Fix using latest release version of package

* Import semver with pip in travis file
2019-11-24 13:05:21 +01:00
Georgy Komarov 2c28440f15 cert.py: Add ENV33-C-EX1 exception (#2396)
* cert.py: Add ENV33-C-EX1 exception

ENV33-C-EX1: It is permissible to call system() with a null pointer
argument to determine the presence of a command processor for the
system. [1]

[1]: https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152177

* Handle different null-pointer constants
2019-11-24 10:31:08 +01:00
Sebastian c3c3d6770c
Fix #9478: Valueflow: printf does not change value (#2388)
Format-string arguments are now marked to have `in` direction, except
for `scan`-functions (like `scanf`) where these arguments are explicitly
marked to have `out` direction.
2019-11-24 01:40:31 +01:00
Daniel Marjamäki ab2274b8ad AST: lambdas and scopes in expressions 2019-11-23 21:36:36 +01:00
Daniel Marjamäki ebd32cfd73 Syntax error: if (retval==) 2019-11-23 18:50:46 +01:00
IOBYTE fb1d60bfb1 fix syntax error for num.operator std::string()[0] (#2389) 2019-11-23 17:42:24 +01:00
Georgy Komarov 14469aced8 cert.py: Fix EXP05C crash (#2392)
* cert.py: Fix EXP05 crash

* Fix arguments check
2019-11-23 17:41:47 +01:00
Sebastian 1b28fb2d1a
donate-cpu.py: Verify argument for jobs (-jN) (#2386)
Yesterday, I observed that some client with a wrong jobs setting
(only "-j") requested one package after another and always uploaded
results where it only said that the argument "-j" is invalid for
Cppcheck.
This check should avoid such cases where results are overwritten with
useless data and the server is kept busy for nothing.
2019-11-22 22:04:41 +01:00
Dmitry-Me 5a48ac0c6e Improve test coverage for invalid use of bool parameters 2019-11-22 18:11:38 +03:00
Sebastian 5f2f19a646
dmake: Update Visual Studio solution and project (#2385)
This also fixes syntax errors for modern code that is not supported
by old Visual Studio IDEs/compilers.
2019-11-21 19:39:19 +01:00
Dmitry-Me b3ed9f8231 Make iterator checks useful 2019-11-21 18:15:26 +03:00
Sebastian cc34fee989
.travis.yml: Add *.json file validation (#2362) 2019-11-21 09:12:25 +01:00
versat 946c5e4dbc astyle client/server: Remove scripts because they are not used
If someone needs them please tell us and we can restore the scripts
and let the server run again.
2019-11-21 08:06:26 +01:00
Sebastian 590ec74998
astyle client/server: Update server address + minor changes (#2383) 2019-11-21 08:01:05 +01:00
Georgy Komarov b9bc5d6d78 cert.py: Add ENV33-C (#2377) 2019-11-21 06:46:46 +01:00
IOBYTE df952926f8 fix syntax error for a.operator++() ? a.operator--() : 0 (#2382) 2019-11-20 22:13:32 +01:00