Commit Graph

3094 Commits

Author SHA1 Message Date
Thomas Jarosch fcb6759f43 The usual astyle run 2011-12-03 17:01:56 +01:00
Daniel Marjamäki 50dfdf7c2e Fixed #3350 (Analysis failed) 2011-12-03 15:15:15 +01:00
Daniel Marjamäki c90558f730 Fixed #3358 (False null pointer dereference positive with ternary ?: operator) 2011-12-03 13:10:07 +01:00
Daniel Marjamäki b7988a3dab Fixed #3336 (False positive: Member function is not used (used by template function)) 2011-12-03 12:19:26 +01:00
PKEuS 1f438b0505 Fixed #3375 (Improve check: Detect unreachable code) 2011-12-03 11:43:23 +01:00
Daniel Marjamäki 69d3d4a17d Fixed gcc compiler warnings 2011-12-03 09:57:56 +01:00
Daniel Marjamäki fb3115a199 Fixed #3267 (False positive: resource leak in vdr-xinelib) 2011-12-03 09:53:36 +01:00
Edoardo Prezioso 00bae586e9 Add 'throw' to the flow control statements list for simplification of dead code. 2011-12-03 02:04:29 +01:00
Edoardo Prezioso 42a557432d Remove some redundant semicolons - part 3 2011-12-02 23:04:06 +01:00
Edoardo Prezioso c2ddb67316 Remove some redundant semicolons - part 2 2011-12-02 22:58:29 +01:00
Edoardo Prezioso ff1cb241a8 Remove some redundant semicolons - part 1 2011-12-02 22:39:33 +01:00
Daniel Marjamäki 9a84c5845a Fixed #3373 (False posititive: incorrect %* handling in sscanf) 2011-12-02 17:09:32 +01:00
Daniel Marjamäki 6763e596b9 Fixed #3345 (false positive: possible null pointer dereference (guarded by &&)) 2011-12-02 06:11:55 +01:00
Richard Quirk d2c8b9be56 Fix possible null pointer dereference 2011-12-01 19:57:04 +01:00
Richard Quirk b2ea78543b Fix false positive with non-const function calls 2011-12-01 19:57:04 +01:00
Richard Quirk a880469c5a Refactor the same expression check
Work out if a function is inconclusive when creating the entry in the
Expressions class instead of when checking the counts at the end. Store
the result in a new bool flag in the ExpressionTokens helper struct.

The pointer to symbol database and ref to list of const functions are
temporarily stored in  the Expressions helper class to avoid passing
them in too on every endExpr(tok) call.

Use a const reference to ExpressionTokens in the check loop to avoid
repeating the it->second several times, which clarifies what that code
does.
2011-12-01 19:57:04 +01:00
PKEuS 5017646488 Coding fixes and refactorings 2011-12-01 19:43:51 +01:00
Daniel Marjamäki c7e2a198cb Fixed Visual Studio compiler warnings 2011-12-01 18:32:14 +01:00
Daniel Marjamäki 93b21c6cc5 Fixed Visual Studio compiler warnings 2011-12-01 18:27:25 +01:00
Daniel Marjamäki 98480bf504 Fixed #3354 (Incorrect both sides of '||' expression match when using increment in expression.) 2011-12-01 17:46:33 +01:00
Daniel Marjamäki fddfd16758 checkDuplicateExpressions: validate tokens instead of string. Fix for my previous commit. 2011-12-01 17:43:29 +01:00
Daniel Marjamäki 31b576de3b Fixed #3334 (Test for same expression on both sides of '&' reports false positive) 2011-12-01 17:07:55 +01:00
Edoardo Prezioso 767413adad 1)internal check found a 'findmatch' with simple string argument;
2)Style: uniform 'while (...)' when inside it there's an assignment;
3)Replace '0' with 'NULL' where there's comparison with a pointer.
2011-12-01 12:04:47 +01:00
Zachary Blair 344d7e2f34 Fixed #3283 (False negative: array index out of bounds not found for constant string and known array index value) 2011-11-30 19:17:09 -08:00
Daniel Marjamäki 0bf17213ec Merge pull request #65 from makulik/master
Solution for ticket #3353 'Allow explicit undef's for configuration'
2011-11-30 12:42:11 -08:00
Daniel Marjamäki 323019c48f Fixed #3355 (False positive: member variable initialization (::ZeroMemory)) 2011-11-30 21:28:16 +01:00
Edoardo Prezioso 1084e4bece 1) Shut up GCC compiler for 'missing braces around assignment';
2) Tokenizer::simplifyGoto: Code refactoring in order to skip code inside '()|[]' parentheses without counting.
2011-11-30 20:58:39 +01:00
makulik 1e8fc71f8e Solution for ticket #3353 'Allow explicit undef's for configuration'
Signed-off-by: makulik <g-makulik@t-online.de>
2011-11-30 20:24:01 +01:00
PKEuS ee3e10ea97 Fixed #3364 (Crash in printf parsing) 2011-11-30 20:23:29 +01:00
Daniel Marjamäki d0247f3a8d Fixed #3268 (False positive: resource leak in vdr-xineliboutput) 2011-11-30 20:07:56 +01:00
Daniel Marjamäki dcd3f4fe3d Fixed #3267 (False positive (experimental): resource leak in vdr-xinelib) 2011-11-30 19:43:02 +01:00
Daniel Marjamäki 414e0ecc3c Uninitvar: Reactivated the checking 2011-11-30 18:57:52 +01:00
Daniel Marjamäki 0d48cd390b astyle formatting 2011-11-29 20:44:23 +01:00
Edoardo Prezioso 5c90c69ccf Fixed ticket #3366 (Build breakage) 2011-11-29 19:46:36 +01:00
Daniel Marjamäki b61c01c6a4 Fixed #3356 (false positive: (warning) Comparison of a boolean with integer that is neither 1 nor 0) 2011-11-29 18:14:57 +01:00
Daniel Marjamäki b538f49a6e Merge pull request #61 from richq/sameexpr
Fix for #3317 - same expression on both side of '&&' false positives
2011-11-29 08:50:02 -08:00
PKEuS be0acad11f Improvements to Nullpointer dereference on function call check:
printf format string parser improved (similar to my recent patch
on the argument counter), frexp/modf supported (#1572), Code
cleanup
2011-11-28 22:32:07 +02:00
Daniel Marjamäki 39af75abb4 Fixed #3303 (false positive: memory leak (reference count)) 2011-11-28 20:08:29 +01:00
Daniel Marjamäki 522da8d258 sizeof for numeric constant : disabled check. see ticket #3179 2011-11-27 18:50:21 +01:00
Marek Zmysłowski e0b50719f4 Fixed #909 (improve check: out of bounds of memchr function and out of bounds check) 2011-11-27 07:54:52 +01:00
PKEuS 2d3a232ef6 code refactoring 2011-11-27 07:30:58 +01:00
PKEuS 71c8669261 Fixed #3311, #3313 and #3339 (printf format string false positives) 2011-11-27 07:29:09 +01:00
PKEuS 6b1594244e code cleanups and refactorings 2011-11-26 21:15:16 +01:00
PKEuS 6b6f780057 code cleanups and refactorings 2011-11-26 21:02:04 +01:00
Daniel Marjamäki 50c320ef27 memory leaks: Made leak checking inconclusive instead of experimental 2011-11-25 14:47:45 +01:00
Marek Zmysłowski 3ae96600b5 Fixed #3212 (Simplify the double pointer cast) 2011-11-25 07:23:54 +01:00
Thomas Jarosch 5025d1019f Use Token::simpleMatch instead of Token::Match
"--enable=internal" reported:
[lib/tokenize.cpp:3563]: (warning) Found simple pattern inside Token::Match() call: ") ;"
2011-11-24 10:11:45 +01:00
Richard Quirk d28cf42d4c Fix ticket #3317 (same expression false positives)
Add a check for function calls that have no side effects. That means
known const methods and a list including strcmp, strlen, etc.

If the function is not known to be side effect-free then no style
warning is given.

Add test cases for the duplicate expressions.
2011-11-23 21:39:03 +01:00
Richard Quirk 511ac0ab1f Remove false positives for nested logic 2011-11-23 21:39:03 +01:00
Richard Quirk b0574cd02e Fix ticket #2233 (unused private static function) 2011-11-23 21:28:08 +01:00
Richard Quirk d76657fec8 Fix false positives for null pointer on exit 2011-11-23 21:27:15 +01:00
Daniel Marjamäki 2e08c8c5b1 DJGPP: Fixed a few compiler errors by using std::size_t instead of size_t 2011-11-22 21:14:14 +01:00
Daniel Marjamäki 345220b36f removed unused include 2011-11-22 19:54:15 +01:00
Daniel Marjamäki 1b1fd9d39c Fixed #3196 (False positive: member variable not initialized in constructor (union)) 2011-11-22 19:26:00 +01:00
Daniel Marjamäki add2b3706b Fixed #3352 (False positive: member variable not initialized (3D array)) 2011-11-22 18:45:25 +01:00
Daniel Marjamäki 17f891ad34 Tokenizer::setVarId: Fixed problem with class declarations with inheritance. skip them. 2011-11-21 21:18:56 +01:00
Daniel Marjamäki 0dd05e0d56 Fixed #3347 (False positive: unused function (taking address)) 2011-11-21 19:12:54 +01:00
Daniel Marjamäki 9aa8a49677 Tokenizer::setVarId: fixed 'using' bug 2011-11-21 18:04:42 +01:00
Daniel Marjamäki 648fcb9e42 operator= should return reference: Made check inconclusive. See ticket #3296 2011-11-21 08:00:10 +01:00
Daniel Marjamäki 5b5ea29f23 Mismatching format string parameters. Made check experimental. See tickets #3311, #3313 and #3339 2011-11-21 07:31:06 +01:00
Reijo Tomperi eebd1393ff "Internal error. Token::Match called with varid 0." didn't work when error was in a header file. Fixed that. 2011-11-21 00:41:26 +02:00
Reijo Tomperi 7d7d68b192 Make --debug-fp work with new exception also. 2011-11-21 00:04:09 +02:00
Reijo Tomperi 91e89380c2 astyle fix 2011-11-20 23:43:55 +02:00
Reijo Tomperi e0ea4228cd "Internal error. Token::Match called with varid 0." will now cause check to abort and write a proper error log with filename. Previously filename was empty and format was always xml. 2011-11-20 23:38:37 +02:00
Daniel Marjamäki 004dcf834b Fixed #3281 (Tokenizer::simplifyKnownVariables : static constant value is not used) 2011-11-20 21:50:26 +01:00
Marek Zmysłowski 9a8c48b36e Fixed #3255 (Error message for std::string::c_str() is not descriptive) 2011-11-20 19:26:07 +01:00
Edoardo Prezioso 6889a28d31 1) Run runastyle;
2) Clarify some comments in 'Tokenizer::simplifyFlowControl' and in 'Tokenizer::eraseDeadCode';
3) Add some 'const' variables inside 'Tokenizer::eraseDeadCode'.
2011-11-20 19:06:55 +01:00
Edoardo Prezioso d0d5a2fcd8 Completed ticket #3230 (Refactoring: add function to remove tokens when a label is found.) and fixed ticket #3264 (False positive: Variable is assigned a value that is never used). 2011-11-20 18:37:00 +01:00
Daniel Marjamäki 77925dc629 Class checking: made 'technically function x can be const' inconclusive 2011-11-20 16:54:06 +01:00
Daniel Marjamäki b26811cdf5 astyle formatting 2011-11-20 16:50:41 +01:00
Richard Quirk 91713ffe84 Fix false positives for %[ in scanf 2011-11-20 16:48:54 +01:00
Daniel Marjamäki 097637a66c Fixed #3316 (Cppcheck reporting internal errors - code compiles cleanly) 2011-11-20 16:22:21 +01:00
Edoardo Prezioso a32b05197d Change every 'tokAt(1)' to 'next()' and every 'tokAt(-1)' to 'previous()'.
Added a safety check to ensure that a 'previous()' call doesn't crash (not sure if it's needed or not).
2011-11-20 15:59:37 +01:00
Daniel Marjamäki b92959809c Uninitvar: Made checking experimental 2011-11-20 15:19:56 +01:00
Edoardo Prezioso 11dd3c09ce Change every 'tokAt(1)->' to 'next()->' because 'tokAt(1) == 0' is equivalent to 'next() == 0', hence the equivalent cppcheck crash. 2011-11-20 15:09:57 +01:00
Edoardo Prezioso 42e369a4b4 Change every 'tokAt(..)->link()' to 'linkAt(..)'. 2011-11-20 14:24:27 +01:00
Daniel Marjamäki 690702a742 Memory leaks: Made CheckMemoryLeakInFunction experimental 2011-11-20 14:11:22 +01:00
Daniel Marjamäki 1cf45a5cde Fixed #3280 (False positive: assigned value that is never used) 2011-11-20 12:09:07 +01:00
Daniel Marjamäki 8c091ff968 Fixed #3340 (Internal error. Token::Match called with varid 0... union is causing problems) 2011-11-20 08:13:28 +01:00
Daniel Marjamäki 2a5b4b1842 Fixed #3328 (False negative: out of bounds) 2011-11-19 15:28:06 +01:00
Daniel Marjamäki fc42fc956c Reverted previous commit. There are testrunner problems when the code is removed. 2011-11-19 15:14:45 +01:00
Daniel Marjamäki 5511f3fbfd removed cleanup code that will crash in some environments. it's somewhat redundant. 2011-11-19 14:50:04 +01:00
Daniel Marjamäki 13eecb9109 Fixed #3329 (cppcheck core dump on Sun machine) 2011-11-19 14:44:55 +01:00
Edoardo Prezioso c3b54066bd Merge branch 'master' of github.com:danmar/cppcheck 2011-11-19 13:36:05 +01:00
Edoardo Prezioso ccdb18f213 Add a sanity check and an error message to linkAt when the index is outside the tokens range. 2011-11-19 13:34:36 +01:00
Daniel Marjamäki c025bf9d57 Fixed #3332 (mismatching comparison: Hard to understand) 2011-11-19 08:38:54 +01:00
Daniel Marjamäki 033fef36da improved error message 'mismatching comparison' 2011-11-18 20:07:42 +01:00
Daniel Marjamäki e78131f9e6 Preprocessor: better handling of #define A 0 => #if A==0. ticket #3331 2011-11-17 19:19:43 +01:00
Marek Zmysłowski 994f08fdf0 Fixed #886 (new check: wrong value passed to isgraph function) 2011-11-17 16:31:16 +01:00
Stefan Weil 68a1b69d32 Preprocessor: Fix comments (backspace -> backslash)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2011-11-15 19:30:43 +01:00
Stefan Weil 00ead7fb2e support any number of --append=<file> options
If one or more append files are given on the command line,
they are simply concatenated.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2011-11-15 19:27:36 +01:00
Stefan Weil 785bc3d04b Optimize handling of --append=<file> option (execution time, memory)
Whitespace was removed from the append data for every configuration
and every file: n(configuration) * n(files).

Removing whitespace immediately after the append data was read can
significantly reduce the execution time and memory usage.
It also allows further improvement because copies to the temporary
object appendCode are no longer needed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2011-11-15 19:27:36 +01:00
Stefan Weil d11f18b5df cmdlineparser: terminate with error message if --append=<filename> fails
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2011-11-15 19:27:36 +01:00
Thomas Jarosch c317c8979c Run astyle 2011-11-14 09:21:42 +01:00
Thomas Jarosch a645235d5a Adapt Token::strAt() to return a const reference like Token::str() does
Saves us a complete conversion from string.c_str() back to std::string.
2011-11-14 09:19:46 +01:00
Richard Quirk 527236b321 Fix false positives for delete of known nulls 2011-11-13 22:38:34 +01:00
Edoardo Prezioso 2c64d299ca Change every 'tokAt(...)->str()' to 'strAt(...)'. 2011-11-13 13:10:59 +01:00
Edoardo Prezioso b28a44dc3b Change: 'next()->next()'->'tokAt(2)', 'previous()->previous()'->'tokAt(-2)'. 2011-11-12 22:33:03 +01:00
Edoardo Prezioso ed6a0e14c4 Add simplification of the consecutive braces before the end of 'tokenize()' function. 2011-11-12 16:59:20 +01:00
Edoardo Prezioso 5cbfbe31c1 Add removal of consecutive braces, i.e.: '{ { ... } }'->'{ ... }'.
Changed a little bit the dead code tests.
2011-11-12 12:07:10 +01:00