Commit Graph

1887 Commits

Author SHA1 Message Date
Daniel Marjamäki 616914c1ff Tokenizer: simple refactorings. and added a few comments 2011-01-06 12:07:37 +01:00
Raphael Geissert 6ec4497919 [PATCH] Check for calls to memset() where 0 bytes are to be filled
Inspired by Silvio Cesare's work
2011-01-06 11:31:58 +01:00
Daniel Marjamäki d1854e330b Fixed #2413 (fflush() with NULL argument is valid.) 2011-01-06 08:12:34 +01:00
Robert Reif 03a484554c Fixed #2415 (false positive: Member variable not initialized in constructor calling assignment operator) 2011-01-06 07:56:34 +01:00
Daniel Marjamäki c74b2e3cbf Fixed #2411 (possible null pointer dereference (aborting via function pointer not detected)) 2011-01-05 21:48:26 +01:00
Daniel Marjamäki 033e759c39 command line: added 'information' id to enable 2011-01-05 21:20:21 +01:00
Daniel Marjamäki 21af64049c Fixed #2401 (false positive: Uninitialized variable: result) 2011-01-05 20:44:04 +01:00
Daniel Marjamäki 68de938d23 Uninitialized variables. Fixed false positive when there are multiple related conditions. ticket: #2399 2011-01-05 19:54:56 +01:00
Daniel Marjamäki a0d62e041f Tokenizer: Fixed memory corruption 2011-01-05 19:38:22 +01:00
Robert Reif 157498e694 Fixed #2412 (typedef: struct with inheritance) 2011-01-05 17:42:55 +01:00
Robert Reif ed6f683573 typedef: better handling. ticket: #2414 2011-01-05 17:39:53 +01:00
Zachary Blair 188871c428 Removed an unnecessary newline in the message. Ticket #2343 2011-01-05 00:06:53 -08:00
Zachary Blair 3f97bd5477 Fixed #2343 (The ftime obsolete function warning seems wrong) 2011-01-04 23:21:02 -08:00
Kimmo Varis bb719774b1 Improve suspicious condition (string::find) message.
See forum thread:
https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192
2011-01-04 23:19:23 +02:00
Kimmo Varis 66e8b7bc1e Improve dangerous iterator usage (after erase()) message.
See forum thread:
https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192
2011-01-04 23:18:48 +02:00
Kimmo Varis b750a52f6d Improve strncat 3rd parameter usage warning message.
See forum thread:
https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192
2011-01-04 23:17:44 +02:00
Daniel Marjamäki d700f25518 Fixed #2399 (Tokenizer::simplifyKnownVariables: variables in conditions) 2011-01-04 21:35:35 +01:00
Daniel Marjamäki 63c1ee375e Fixed #2398 (false positive: Uninitialized variable) 2011-01-04 19:36:29 +01:00
Daniel Marjamäki c2a194ead0 Fixed #2393 (Token::Match called with varid 0) 2011-01-04 18:34:51 +01:00
Daniel Marjamäki 2c6421d162 Merge branch 'master' of https://github.com/rgeissert/cppcheck into rgeissert-realloc 2011-01-04 18:21:18 +01:00
Daniel Marjamäki 85897c3991 Merge branch 'debug-warnings' of https://github.com/rgeissert/cppcheck into rgeissert-debug-warnings 2011-01-04 18:17:39 +01:00
Robert Reif 63208e87d3 typedef: delete unhandled typedefs. ticket: #2348 2011-01-04 07:43:40 +01:00
Robert Reif a782d3ddf7 typedef: fix testcase 4. ticket: #2375 2011-01-04 07:39:41 +01:00
Robert Reif 63ad1fbe69 Fixed #2400 (Tests crashing in Windows) 2011-01-04 07:34:32 +01:00
Raphael Geissert 2b1ec9a07f Mention the name of the variable in the inconclusive leak msg 2011-01-03 20:40:31 -06:00
Markus Elfring e459ed1de3 Fixed #2389 (mistakable warning from 'CheckClass::uninitVarError') 2011-01-03 19:03:42 +01:00
Raphael Geissert 3d9550b0bf Simplify "x = realloc (0, n);" to "x = malloc(n);" 2011-01-02 17:46:10 -06:00
Raphael Geissert e75a81669e Move simplification of realloc after simplification of math ops 2011-01-02 16:41:34 -06:00
Daniel Marjamäki d2714fefda typedef: Fixed testcase. ticket: #2375 2011-01-02 17:28:47 +01:00
Daniel Marjamäki 97f7a36e91 Buffer overruns: Added comments 2011-01-02 14:16:58 +01:00
Daniel Marjamäki 2e7e118cb8 Fixed #2392 (Preprocessor: Wrong simplification of __VA_ARGS__) 2011-01-02 11:19:37 +01:00
Daniel Marjamäki b5876f00ff Fixed #2391 (cstdlib file and memory function check misbehavior) 2011-01-02 08:32:51 +01:00
Daniel Marjamäki 4ec9d418ff Fixed #2215 (Improve check: Writing outside malloc bounds not detected) 2011-01-01 20:56:21 +01:00
Daniel Marjamäki 789d944912 typedef: don't simplify typedef after 'case'. it means that there is a typedef and constant with the same names. Ticket: #2386 2011-01-01 20:20:03 +01:00
Daniel Marjamäki 2a77dd3df1 Fixed #2246 (Improve check: Memory leak, function is not noreturn if return value is taken) 2011-01-01 20:14:01 +01:00
Daniel Marjamäki c8775344d6 uninitialized variables: Added some comments 2011-01-01 18:24:27 +01:00
Daniel Marjamäki 3c238882a2 Fixed TODO testcase. Use symbol database instead of token list. Ticket: #2375 2011-01-01 17:54:37 +01:00
Daniel Marjamäki 3eabb4ebe0 Added comments in the memory leaks checking 2011-01-01 13:28:34 +01:00
Daniel Marjamäki 0cc49188c0 Memory leaks: localized variables 2011-01-01 12:27:57 +01:00
Daniel Marjamäki 62145431a7 Tokenizer: Added more comments 2011-01-01 11:40:32 +01:00
Daniel Marjamäki e385323b65 Tokenizer: Added doxygen comments 2011-01-01 11:26:48 +01:00
Daniel Marjamäki 71acf78c64 Tokenizer: added doxygen comments 2011-01-01 09:26:24 +01:00
Zachary Blair 68700b3561 Fixed #2382 (Catching exceptions by value instead of reference) 2010-12-31 12:48:24 -08:00
Daniel Marjamäki 2da3fea1b8 Fixed #2386 (segmentation fault occurs in the checking when typedef has same name as an enum constant) 2010-12-31 20:55:28 +01:00
Daniel Marjamäki 3e5614a5a3 Null Pointer: Refactoring - broke out CheckNullPointer::isPointer 2010-12-31 18:30:04 +01:00
Daniel Marjamäki 04eb9cf305 Fixed #2378 (Refactoring: create utility function that skips redundant if/for/while) 2010-12-31 18:07:46 +01:00
Daniel Marjamäki ed6c76ce04 Fixed #2385 (False positive: array index out of bounds) 2010-12-31 17:43:38 +01:00
Daniel Marjamäki b04885cd4f astyle formatting 2010-12-31 15:57:08 +01:00
Daniel Marjamäki 4d8fae186b added more comments 2010-12-31 15:56:41 +01:00
Daniel Marjamäki b634242a58 Added comments for CheckNullPointer::nullPointerLinkedList 2010-12-31 14:37:34 +01:00
Daniel Marjamäki 377bcbe729 Remove redundant condition 2010-12-31 14:24:15 +01:00
Daniel Marjamäki 1a8c410c06 gcc: fixed compiler warning (suggest parantheses around assignment) 2010-12-31 14:18:24 +01:00
Daniel Marjamäki 3de9d9cb31 Refactoring and commenting CheckNullPointer::nullPointerAfterLoop 2010-12-31 14:17:10 +01:00
Daniel Marjamäki 59c86b5876 added doxygen comments 2010-12-31 14:16:22 +01:00
Daniel Marjamäki 1fa730d963 added some comments 2010-12-31 13:58:17 +01:00
Pete Johns 502cfe7243 Fixed #2384 ("The function 's::f' can be const" reported for pointer-to-pointer)
Moved check for pointer variables into isVariableDeclaration()

Can now handle multiple scopes and multiple levels of indirection. Simplified check for strucs and unions, too, reducing the size of getVarList().

skipScopeIdentifiers() and skipPointers() should probably be methods on class Token.
2010-12-31 22:12:32 +11:00
Zachary Blair d11b5163b7 Fixed #2382 (Catching exceptions by value instead of reference) 2010-12-31 03:01:38 -08:00
Daniel Marjamäki f1f1a21c23 Borland C++: Fixed compiler errors 2010-12-31 10:24:51 +01:00
Daniel Marjamäki d8f241e033 gcc: fixed -Wconversion errors 2010-12-31 09:51:27 +01:00
Daniel Marjamäki 68b9c6ec94 gcc: Fixed -Wconversion warnings in symbol database 2010-12-31 09:39:42 +01:00
Daniel Marjamäki cab338dffe gcc: fixed -Wconversion warnings in tokenizer 2010-12-31 09:38:03 +01:00
Daniel Marjamäki fa3853803b gcc: fixed -Wconversion warnings 2010-12-31 09:30:56 +01:00
Daniel Marjamäki f3ce02462e improved TODO comments 2010-12-30 22:41:22 +01:00
Daniel Marjamäki c7f2ddf63c CheckStl: Added comments 2010-12-30 22:36:25 +01:00
Daniel Marjamäki d005245188 fixed doxygen warnings 2010-12-30 22:13:31 +01:00
Daniel Marjamäki 742f5897b9 gcc: fixed compiler warning 2010-12-30 22:13:10 +01:00
Daniel Marjamäki 3d60d33280 Added comments 2010-12-30 22:07:27 +01:00
Daniel Marjamäki 8bdb05da6e Uninitialized variables: typeof doesn't dereference. Ticket: #2367 2010-12-30 21:30:46 +01:00
Daniel Marjamäki 307178d3c2 Tokenizer: Better handling of duplicate enums. Ticket: #2381 2010-12-30 20:55:23 +01:00
Daniel Marjamäki 7ec169f66a Fixed #2321 (false positive: (performance) Prefer prefix ++/-- operators for non-primitive types.) 2010-12-30 14:27:32 +01:00
Pete Johns 2e61736c73 Refactoring following #2377 (Technically the member function xxx can be const)
symboldatabase now recognises variables with arbitrarily many scopes.

Extracted method isVariableDeclaration()

Added unit tests for isVariableDeclaration in new file testsymboldatabase.cpp

Extracted givenACodeSampleToTokenize helper class into testutils.h to reduce duplication.
2010-12-30 19:46:44 +11:00
Pete Johns 5d0ace3a50 Fixed #2377 (Technically the member function xxx can be const)
TODO: Add unit test for getVarList() and refactor variable check.

[Removed my testcase for #2377 and removed two TODOs.]
2010-12-30 17:56:28 +11:00
Daniel Marjamäki 3d3593e6e7 Fixed #2374 (False 'memory leak' report (assigning to map in subfunction)) 2010-12-29 22:18:23 +01:00
Robert Reif 3900ac731e simplifyTypedef: Better handling of 'typedef int RexxFunctionHandler();'. Ticket: #2348 2010-12-29 20:25:47 +01:00
Robert Reif 3f1f50e970 simplifyTypedef: operator typedef. Ticket: #2375 2010-12-29 20:22:06 +01:00
Daniel Marjamäki 38e7209d26 Fixed #2373 (Using XML2 in --errorlist output) 2010-12-29 12:43:29 +01:00
Daniel Marjamäki fd27be2440 Fixed #2372 (internal error in logicaloperator check (varid=0)) 2010-12-29 10:07:28 +01:00
Robert Reif 137d0e2ba7 typedef: fixed problem with 'typedef int pread_f(int);'. ticket: #2348 2010-12-29 09:18:41 +01:00
Robert Reif e82b1f8946 typedef: fix typedef simplification. ticket: #2348 2010-12-28 21:21:13 +01:00
Daniel Marjamäki bdf0cb7115 Fixed #2370 (false negative: Buffer access out-of-bounds (for with if, no break)) 2010-12-28 20:46:31 +01:00
Daniel Marjamäki 0667fcf53c Fixed #2355 (simplifyTypedef: wrong simplification of 'typedef FMAC1 void (*a)();') 2010-12-28 14:04:44 +01:00
Robert Reif 1b92eeae1e Fixed #2354 (simplifyTypedef: function pointers are not simplified into valid code) 2010-12-28 08:01:32 +01:00
Daniel Marjamäki d4e3e7e201 Fixed #2367 (false positive: (error) Uninitialized variable: s) 2010-12-27 21:19:10 +01:00
Daniel Marjamäki 448c03c6e6 Fixed #2367 (false positive: (error) Uninitialized variable: s) 2010-12-27 21:05:33 +01:00
Daniel Marjamäki 92acca3d0c Fixed #2368 (assigned a value that is never used) 2010-12-27 20:49:07 +01:00
Kimmo Varis e8b81f909d Change 'Scope of variable'-message to information message. 2010-12-27 16:48:03 +02:00
Daniel Marjamäki 660de98c0c Fixed #2365 (Internal error: Token::Match called with varid 0) 2010-12-27 14:06:32 +01:00
Daniel Marjamäki 2367cfcf1e Fixed #2361 (false positive on t[0X10]) 2010-12-27 08:09:05 +01:00
Kimmo Varis 12f2850777 Improve the message about const function.
See discussion thread:
https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192
2010-12-26 23:44:03 +02:00
Kimmo Varis f5f2a2ce2a Improve message for container type range check.
See thread:
https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192&start=0
2010-12-26 23:44:02 +02:00
Kimmo Varis ad89a84796 Improve error message about overlapping buffers for s[n]printf().
See forum thread:
https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192&start=0
2010-12-26 23:44:01 +02:00
Daniel Marjamäki 6aa400fd80 Buffer overrun: UB when pointer arithmetic result points out of bounds. Ticket #1774 2010-12-26 21:23:28 +01:00
Daniel Marjamäki 6178459c15 Fixed #2304 (Tokenizer::simplifyKnownVariables: known strcpy parameter) 2010-12-26 20:34:07 +01:00
Daniel Marjamäki 5f3d2a7e35 Fixed #2090 (False negative: null pointer dereference 's=0; strcpy(s,p);') 2010-12-26 19:29:58 +01:00
Daniel Marjamäki f4581d833d Tokenizer: Bailout if @ is encountered in the code 2010-12-26 15:07:14 +01:00
Daniel Marjamäki 243a524909 Fixed #2350 (false positive: possible null pointer dereference) 2010-12-26 13:38:16 +01:00
Pete Johns 59acbb3da0 Fixed Linux build.
OSX built without limits.h
2010-12-26 23:08:51 +11:00
Pete Johns 64e2c8668c Fixed #2358 (Compilation fail on Mac)
Added test case to prove it works. Not a true unit-test as it accesses the file-system.
2010-12-26 23:04:07 +11:00
Daniel Marjamäki 4fd8d2e056 Fixed #2326 (Preprocessor: inline-suppr does not work for id=missingInclude) 2010-12-26 11:14:57 +01:00
Pete Johns 7943d8ce53 canonicalize_file_name() is a GNU-extension.
Replaced with call to realpath() to build on non-Linux systems, such as Mac OSX.
2010-12-26 14:15:42 +11:00
Daniel Marjamäki ecad249ae2 Fixed #2346 (False positive: pointer is assigned value that is never used. used here: 'pCol = pCol->GetNext()') 2010-12-25 19:17:53 +01:00
Daniel Marjamäki 10ee43790d Fixed #2339 (Tokenizer::setVarId : Wrong handling of 'int gr = id - (TLFPressProperties::OIL_FLUID * nb);') 2010-12-25 12:40:44 +01:00
Daniel Marjamäki 6f8f0e1aa1 Fixed #2353 (Tokenizer::simplifyKnownVariables: wrong simplification after return) 2010-12-25 10:07:57 +01:00
Daniel Marjamäki 81c5576eb4 Misused scope objects: Don't use this check if the checked file is a pure C file. Ticket: #2352 2010-12-25 08:43:52 +01:00
Daniel Marjamäki 65041cf0ff Fixed #2349 (Empty 'msg' in output when using '-j') 2010-12-24 11:13:57 +01:00
Daniel Marjamäki 335d164cdf Fixed #2356 (False positive reported with iterator deletion) 2010-12-24 10:33:48 +01:00
Daniel Marjamäki 18fd12006a Tokenizer::simplifyGoto: Don't simplify 'goto' inside unhandled macro calls. Ticket: #2348 2010-12-23 22:03:58 +01:00
Daniel Marjamäki 472ecd8805 Tokenizer: Fixed calculation simplification of '0*(*p)'. Ticket: #2348 2010-12-23 18:59:18 +01:00
Daniel Marjamäki aff3623fec Fixed #2345 (False positive: uninitialized variable (in sub-condition in if inside a loop)) 2010-12-23 09:16:29 +01:00
Daniel Marjamäki b89f486d0d Fixed #2344 (FileLister Unix: Don't convert to absolute paths) 2010-12-22 21:01:51 +01:00
Daniel Marjamäki be46d453c4 Information: Added new severity 2010-12-22 19:53:17 +01:00
Daniel Marjamäki 22a1f3332f xml2: changed the format of the cppcheck-version info 2010-12-22 18:45:09 +01:00
Robert Reif fc7e2d1ac1 Fixed #2341 (false positive for function pointer returning typedef) 2010-12-22 18:37:23 +01:00
Daniel Marjamäki 00e9822cb3 Fixed #2337 (False Positive: memory leak) 2010-12-22 18:32:00 +01:00
Daniel Marjamäki 3a612d7cd8 xml2: Added cppcheck-version 2010-12-22 10:29:23 +01:00
Daniel Marjamäki f392dbef95 Fixed #2338 (False positive: Deallocating a deallocated pointer) 2010-12-22 08:24:50 +01:00
Daniel Marjamäki 6951c32683 Fixed #2336 (False positive: memory leak (passing pointer to subfunction)) 2010-12-21 21:12:45 +01:00
Daniel Marjamäki 0f9415a5fb Fixed #2330 (unreadVariable error for a fstream object when only extraction operator (>>) is used) 2010-12-21 19:02:00 +01:00
Robert Reif 244974a61a unused variables: fixed false negatives with the help of the symbol database. ticket: #2317 2010-12-21 08:13:40 +01:00
Daniel Marjamäki f73cce9eca Fixed #2317 ((style) Variable is allocated memory that is never used) 2010-12-20 18:31:16 +01:00
Daniel Marjamäki cdc8801be0 Fixed #2334 (Internal class index function (no need to 'strchr')) 2010-12-20 18:13:26 +01:00
Daniel Marjamäki c0bedb5036 Fixed #2331 (Token::Match is called with varid 0) 2010-12-19 21:27:28 +01:00
Daniel Marjamäki 02892499d2 Fixed #2286 (Variable 'ownKilled' is assigned a value that is never used) 2010-12-19 18:27:31 +01:00
Daniel Marjamäki 1cd6f16ecf Fixed #2322 (cppcheck follows recursive symlinks) 2010-12-19 11:22:27 +01:00
Daniel Marjamäki 8247270f35 Fixed #2328 (false positive: buffer overrun (for loop with a break => the end value is not reached)) 2010-12-19 10:39:43 +01:00
Daniel Marjamäki 41ac2c252f Fixed #2325 (Tokenizer: Remove for-loop if condition is false) 2010-12-18 21:43:12 +01:00
Robert Reif a2aa601899 CheckOther: Use SymbolDatabase. Ticket: #2318 2010-12-18 20:35:40 +01:00
Kimmo Varis 062eabf246 Don't use relative paths in lib.pri.
Using relative path in included file binds it to be usable only
included from one directory. Instead use variable for giving the
base path for files.
2010-12-18 17:03:46 +02:00
Daniel Marjamäki 79ea453913 Preprocessor: Report 'missing system include' with debug severity. temporary solution until the handling of system includes is better. 2010-12-18 14:45:53 +01:00
Daniel Marjamäki 8ffc2b0ac6 Tokenizer: better handling for switch/break in the simplifyKnownVariables. Ticket: #2324 2010-12-18 11:14:31 +01:00
Daniel Marjamäki f6c00fc478 Fixed #2323 (false positive: Buffer access out of bounds) 2010-12-18 10:54:36 +01:00
Daniel Marjamäki fc9c450eed Fixed #2320 (false positive: Uninitialized variable: kbuf) 2010-12-18 10:06:21 +01:00
Daniel Marjamäki 7eb9855104 Tokenizer: Remove redundant parantheses in rhs. Ticket: #2320 2010-12-18 09:44:58 +01:00
Daniel Marjamäki 18933ea0e6 QMake: auto-generate the visual studio project files with qmake 2010-12-17 21:43:47 +01:00
Daniel Marjamäki 814efb2512 Fixed #2313 (False Positive: memory leak) 2010-12-17 21:34:22 +01:00
Daniel Marjamäki c2335f845e Fixed #2306 (False positive: array of std::string is reported as uninitialized) 2010-12-17 21:20:04 +01:00
Daniel Marjamäki 696550abd3 Fixed #2299 (false positive: possible nullpointer dereference) 2010-12-17 21:09:12 +01:00
Daniel Marjamäki 845d1491f9 Fixed #2307 (No constructor defined false positive when class is enclosed in namespace) 2010-12-17 20:56:46 +01:00
Daniel Marjamäki e0a0ed6fac removed the NOLONGLONG handling. it seems unlikely it is needed 2010-12-16 21:53:18 +01:00
Daniel Marjamäki 0cebcc8fa9 Fixed #2300 (false positive: possible nullpointer dereference) 2010-12-16 21:41:50 +01:00
Daniel Marjamäki 49ee1533d9 Fixed #2301 (false positive: The given size 3 is mismatching) 2010-12-16 21:27:33 +01:00
Daniel Marjamäki 2d97189486 Fixed #2311 (False positive: Index out of bounds) 2010-12-16 20:16:59 +01:00
Robert Reif f2d69acbfd Symbol database: reuse in CheckOther. Ticket: #2318 2010-12-16 19:04:47 +01:00
Robert Reif bf136f0123 Fixed #2314 (False positive: (style) Template instantiation 'Foo' hides typedef with same name) 2010-12-16 07:48:46 +01:00
Kimmo Varis ac8eb30d68 Fixed #2309 (cppcheck-suppress issue because of path slash/backslash)
Internally we are using forward-slash and only convert to backslash
for Windows output. For suppressing we must use internal
forward-slash format of paths.
2010-12-15 22:39:46 +02:00
vBm 46a11183a5 Fixed some spelling mistakes 2010-12-15 18:45:53 +01:00
Daniel Marjamäki 5ce63a1df0 Fixed #2292 (segmentation fault with cppcheck 1.46 with --errorlist) 2010-12-13 18:17:33 +01:00
Daniel Marjamäki 48241c81f8 dmake: add include path '../externals' to lib.pri in case the pcre.h is placed there. 2010-12-12 17:26:13 +01:00
Daniel Marjamäki 2d3865a671 Add support for user defined rules 2010-12-12 11:56:22 +01:00
Daniel Marjamäki b90e514b32 1.46: updated version information 2010-12-12 08:33:05 +01:00