Commit Graph

4562 Commits

Author SHA1 Message Date
Daniel Marjamäki 78a3a58a5a Fixed #4628 (False positive: Variable is assigned a value that is never used) 2013-03-04 19:13:49 +01:00
Ettl Martin 687c3a4654 Merge branch 'master' of github.com:danmar/cppcheck 2013-03-04 14:25:51 +01:00
Ettl Martin c9b519bcd1 improved check: checkCastIntToCharAndBack. The check now handles (cin.get() != EOF) patterns. 2013-03-04 14:25:35 +01:00
PKEuS 34b1d75a10 Fixed handling of std::vector::insert() in CheckStl::pushback() 2013-03-04 02:57:09 -08:00
PKEuS c24527dbde Improved handling of dereferences in CheckClass::noMemset(), fixing false negatives and false positives related to multidimensional arrays and arrays of pointers. 2013-03-04 02:47:29 -08:00
PKEuS 8a18f9ec3b Rewrote CheckOther::checkVariableScope() 2013-03-03 10:35:33 -08:00
PKEuS 5c1a05dcbe Refactorizations in CheckOther:
- Make CheckOther::checkCastIntToCharAndBack() work for multiple variables at once
- Improved messages of CheckOther::checkSuspiciousSemicolon() and CheckOther::checkPipeParameterSize()
2013-03-03 09:54:44 -08:00
PKEuS d78c06dc3f Replaced _settings->isEnabled("style") by _settings->isEnabled("warning") wherever warnings are issued 2013-03-03 02:41:59 -08:00
Daniel Marjamäki d7a52eaecd Fixed #4608 (false positive: (style) struct or union member is never used.) 2013-03-01 16:13:04 +01:00
PKEuS 096aae4439 New check: Warn about using malloc() for classes containing virtual methods, std::-objects or constructors 2013-03-01 06:07:20 -08:00
PKEuS 75799446aa Added unit test for #4619 2013-03-01 04:06:51 -08:00
PKEuS f899e6ca30 Changed behaviour of %op% pattern accordingly to changes to Token::isOp(). Added %cop% as replacement for old %op% 2013-03-01 02:43:59 -08:00
PKEuS 670c4de8a9 Changed behaviour of Token::is*Op() functions:
- Rename Token::isOp() to Token::isConstOp() (indicating that the operator does _not_ modify the input variables)
- Create new Token::isOp(), returning true also for ++, -- and assignment operators
- Make Token::isExtendedOp() returning also true for all assignment and ++/-- operators
2013-02-28 12:50:29 -08:00
Daniel Marjamäki ecafe7a129 Fixed #4624 (Wrong error for instances of std::unique_lock (variable is never used)) 2013-02-28 17:02:58 +01:00
zblair ed03e2c845 Fixed #4539 (False positive: Possible null pointer dereference) 2013-02-27 23:45:21 -08:00
Daniel Marjamäki 94da3bd57f Fixed #4617 (False positive (style): noexcept for constructors) 2013-02-28 06:38:57 +01:00
Ettl Martin 8d682233d0 Implemented new check (Ticket #160): Storing getc() retun value in char variable and comparing to EOF. 2013-02-27 21:02:12 +01:00
Robert Reif 509061afff Fixed #4620 (False positive: Uninitialized variable in constructor (1.58)) 2013-02-27 06:59:04 +01:00
Daniel Marjamäki df55ce14a0 Fixed #4503 (False positive: Incomplete statement (std::vector<int> v{1};)) 2013-02-24 10:00:03 +01:00
Daniel Marjamäki 2edf95a1b9 Fixed #4367 (false positive: Class '...' is unsafe, '...' can leak by wrong usage) 2013-02-24 08:14:25 +01:00
Daniel Marjamki 5c7e1cf9ff Fixed #4387 (false positive 'constStatement' in 1.57) 2013-02-23 16:26:25 +01:00
Daniel Marjamki ee435bf885 Fixed #4600 (False positive Uninitialized struct member when using it as 'out parameter') 2013-02-23 15:57:58 +01:00
Daniel Marjamäki bce99a9e2f Fixed #4394 (FP: Variable 'a' is not assigned a value) 2013-02-20 17:43:16 +01:00
Daniel Marjamäki 71b66209b7 Fixed #4300 (segmentation fault of cppcheck (invalid code)) 2013-02-20 06:58:27 +01:00
Alexander Mai 34c3697750 Added unit test for #4525 2013-02-19 21:56:13 +01:00
PKEuS 33cf561d85 Refactorized check for assigning function parameters:
- Fixed false negative: Check is also valid for all non-references, not only for pointers.
- Fixed false negative: Usage before assignment doesn't require bailout
- Fixed false positive #4598 caused by inadequate usage of CheckUninitVar::isVariableUsage
- Made several member functions static
2013-02-18 08:52:49 -08:00
Daniel Marjamäki 1c584208b4 Fixed #4329 (False duplicateBranch when branches use conditionally defined macros) 2013-02-18 17:18:33 +01:00
Robert Reif e6915e7a78 Fixed #4536 (non-static member initializer causes false positive) 2013-02-18 06:33:53 +01:00
Ettl Martin 73e2a8fdb5 Merge branch 'master' of github.com:danmar/cppcheck 2013-02-17 17:34:44 +01:00
Ettl Martin f451dd1137 #3521 implemented new check: wrong buffersize to pipe() function provided. 2013-02-17 17:33:32 +01:00
PKEuS 711d0d7a33 Warn about memset(this, 0, sizeof(*this)); (#1285) 2013-02-16 11:02:43 -08:00
PKEuS 167e11b645 Switch to TinyXml2 2013-02-16 10:01:34 -08:00
Daniel Marjamki 2a660fa3b4 Tokenizer: Fixed removeCast bug. Don't simplify (A)&b to A&b if A might be a type. Related with ticket: #4439 2013-02-16 16:58:36 +01:00
Daniel Marjamki 635b7d5a0e Fixed #4423 (Variable is assigned a value that is never used.) 2013-02-16 16:07:05 +01:00
PKEuS 0d316af4f2 Fixed false positive stlSize for code like "foo + 1 > bar.size()" (#4584) 2013-02-16 02:50:25 -08:00
PKEuS d3087602a1 Fixed false positive "function can be const" if a non-const expression is inside []-brackets (#4406) 2013-02-16 02:20:18 -08:00
PKEuS afe45ff39f Refactorized CheckClass::privateFunctions:
- Resolved todo about nested classes, fixed false negative, fixed wrong unit test
- Removed slow and unnecessary Token::findmatch
- Removed false positive when function implementation in friend class is not seen (#4384)
2013-02-16 01:51:08 -08:00
PKEuS 27f7917349 Changed severity and message formatting of argumentSize message. 2013-02-16 00:52:27 -08:00
PKEuS 44887df04f Fixed false positive redundantAssignment when calling function in assignment (#4513) 2013-02-15 09:40:34 -08:00
Daniel Marjamäki 382d7a10e8 Uninitialized variables: improved checking of c++ code 2013-02-15 18:13:47 +01:00
PKEuS ccd95d1749 Make redundantAssignment message inconclusive when printed on global variables to avoid false warning on semaphores/mutexes (#4467) 2013-02-15 09:01:10 -08:00
PKEuS e2655da1ec Properly handle return/break/continue in CheckIO::checkFileUsage() (#4466) 2013-02-15 08:30:43 -08:00
PKEuS 017b4a8a7f Treat references like global variables in CheckOther::checkRedundantAssignment() as they might refer to such. (#4425) 2013-02-15 08:09:31 -08:00
Robert Reif c5ee083c82 Fixed #4388 (false positive 'noConstructor' in 1.57) 2013-02-15 06:44:07 +01:00
Daniel Marjamki 452dc23742 Fixed #4480 (False positive : Inefficient usage of string::find) 2013-02-14 19:14:20 +01:00
Daniel Marjamäki 08ada4cc63 Fixed #2652 (container .size() check too strict) 2013-02-14 16:59:58 +01:00
Robert Reif a1da067b88 Fixed #4585 (false positive, Variable 'b' is assigned a value that is never used when using+loop) 2013-02-14 06:31:41 +01:00
Robert Reif 5de26bfeb9 Fixed #4574 (noConstructor false positives introduced in cppcheck 1.58) 2013-02-13 06:00:04 +01:00
Frank Zingsheim 213d31b360 Fixed #4547 (Improve check: Duplicate conditions in 'if' and related 'else { if'.)
Local fix in CheckOther::checkDuplicateIf()
2013-02-12 21:43:12 +01:00
Frank Zingsheim 75f69c11b7 Test for #4573 (False positive: variableScope within if/else if) 2013-02-12 21:16:57 +01:00
Daniel Marjamäki 1e550f9fdf Reverted fix for #4547: It causes fp. See #4573 2013-02-12 16:13:08 +01:00
Daniel Marjamäki 28e38a9e56 Fixed #4519 (false positive: (error) Uninitialized variable: eax (inline assembly usage)) 2013-02-12 15:59:23 +01:00
Ettl Martin c192e4d669 spellfixes 2013-02-12 15:21:27 +01:00
Ettl Martin dade326a99 #4566 implemented new check: redundantGetAndSetUserId on posix systems 2013-02-11 20:26:27 +01:00
Daniel Marjamäki 75cf951c56 add return value to test case 2013-02-11 18:39:03 +01:00
Daniel Marjamäki 442db6cdf9 Fixed #4569 (False Positive: Uninitialised variable) 2013-02-11 18:31:14 +01:00
Daniel Marjamäki 94f1d34dcb Fixed #4560 (false positive: (error) Uninitialized variable: s) 2013-02-11 17:05:59 +01:00
Daniel Marjamäki 48e194dc56 Fixed #4572 (Analysis failed: sizeof final) 2013-02-10 23:54:15 +01:00
Mathias De Maré dfd557888d Fixed #4565 (false positive: dangerous usage (not null-terminated)) 2013-02-10 13:36:40 +01:00
Andrew C. Martin bd0d9b9639 fix misspellings & gcc v3.4.6 warnings
1.  fix typos / misspellings
 - Fix misspelling within comments, variable/function names, stdout messages
 - changes the name of an error code: ```stlBoundries``` changed to ```stlBoundaries```.  Alias old name (```stlBoundries```) to the new one.

2.  fix gcc v3.4.6 32bit & 64bit warnings

 - fixes gcc v3.4.6 warnings, except for those in tinyxml and "-Wmissing-declarations" makefile warnings
 - in Preprocessor::handleIncludes(), replace a ```vector <bool>``` with ```stack<bool>``` (see ```vector<bool>``` warning below).
   - this is the only ```vector<bool>``` in the codebase
 - ```vector <bool>``` is actually a case of template specialization, and is not recommended, according to the following links:

http://stackoverflow.com/q/6461487
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2160.html
http://stackoverflow.com/q/670308

 - in the codebase before and after this change, testrunner SEGVs in a number of places on gcc v3.4.6, including ```Check::~Check()```, among others
   - fc42fc95 fixes this particular runtime issue for DJGPP & __sun
2013-02-09 23:43:09 -07:00
Robert Reif fe5de60f32 Fixed #4567 (false negative: The class 'B' does not have a constructor.) 2013-02-08 06:55:45 +01:00
Daniel Marjamäki 463121be71 Fixed #4561 (cppcheck 1.58 crashes on empty signals block in headerfile) 2013-02-07 17:03:08 +01:00
Frank Zingsheim 5144307642 Raise syntax error for if-condition without parentheses according to #2518 #4171 2013-02-05 21:13:57 +01:00
Daniel Marjamäki 4ac5648656 Uninitialized struct: Fixed false positive in for loop 2013-02-05 17:01:46 +01:00
Frank Zingsheim b531195e08 Fixed #4547 (Improve check: Duplicate conditions in 'if' and related 'else { if'.)
Change tokenizer: "else if" -->> "else { if"
2013-02-04 21:12:12 +01:00
Daniel Marjamäki a39a2479da Travis: Fixed false positive in lib/checkbufferoverrun. Ticket: #4486 2013-02-04 19:02:42 +01:00
Daniel Marjamäki 1de54ba88e Fixed #4486 (False positive: Return of address from function with integer return type (p+1-q)) 2013-02-04 18:14:52 +01:00
Frank Zingsheim 89560564ed Refactoring: Add braces to an if-block, for-block, etc. in tokenizer.
Fixed #4521 (Tokenizer: Wrong braces for triple if else)
2013-02-02 16:01:34 +01:00
Daniel Marjamki abd536b84c Null pointer: Changed 'possible null pointer dereference - otherwise condition is redundant' to warning 2013-02-02 15:46:29 +01:00
Daniel Marjamki 75e20a996d assign function pointer: Fixed false positive when pointer is used also. Ticket: #2930 2013-02-02 15:26:14 +01:00
Daniel Marjamki 6bb8dd605a assign function parameters: only show warning when --enable=warning or --enable=style is used. Ticket: #2930 2013-02-02 15:08:43 +01:00
Daniel Marjamäki cbbb582fc9 Fixed #2930 (new check: redundant assignment of pointer function parameter) 2013-02-01 19:16:17 +01:00
Robert Reif 1a58ae4994 Symbol database: handle when forward declaration doesn't match declaration. Ticket: #4531 2013-02-01 06:31:02 +01:00
Daniel Marjamäki e2faed355b Fixed #4485 (False positive: Same expression of '-' when checking if float is inf) 2013-01-31 17:29:31 +01:00
Daniel Marjamäki bd7e3cbac5 Fixed #4540 (memory leak not detected ('.' or '->' is used before Function)) 2013-01-31 17:00:50 +01:00
Daniel Marjamäki fc42aa3a30 Fixed #4523 (false positive: (error) Possible null pointer dereference) 2013-01-30 16:52:12 +01:00
Daniel Marjamäki bc6d31c7c7 unsigned division: don't warn about 'unsigned char' because it is promoted to int. 2013-01-30 16:50:12 +01:00
Daniel Marjamäki 509dd9a989 Fixed #4523 (false positive: (error) Possible null pointer dereference) 2013-01-29 17:12:14 +01:00
Daniel Marjamäki 3679a809dd Uninitialized variables: fixed false positive 2013-01-28 18:08:20 +01:00
Robert Reif 859793731d SymbolDatabase: Refactor findFunction handling. Ticket: #4494 2013-01-28 06:47:48 +01:00
Daniel Marjamäki 4391f0880f Tokenizer: Add special tokenize method for the Preprocessor with only basic simplifications 2013-01-27 17:58:54 +01:00
Daniel Marjamäki 42dd956dff Preprocessor: Better fix for hangs. And added proper unit test. 2013-01-27 02:53:29 +01:00
Robert Reif a0d8fd26fe SymbolDatabase: improved handling of const in function parameters 2013-01-27 02:46:00 +01:00
Frank Zingsheim 6dc9987ad0 Fixed #4517 (Testmemleak should not use Tokenizer on pseudo code) 2013-01-27 02:41:43 +01:00
Daniel Marjamki f69b1f426e Preprocessor: Improved handling of expressions in simplifyVarMap. Ticket: #4516 2013-01-26 16:21:33 +01:00
Daniel Marjamki 641e7cba28 Fixed #4516 (Preprocessor: wrong #if evaluation) 2013-01-26 12:37:46 +01:00
Daniel Marjamki 8738223e82 Fixed #4512 (Improve check: Uninitialized variable not detected) 2013-01-26 08:16:53 +01:00
Daniel Marjamäki ae43b12bf1 Fixed #4511 (False positive: uninitialized struct member) 2013-01-25 18:20:57 +01:00
Robert Reif 3b08b410a2 Symbol database: Improved function lookup (a.b.f()). Ticket: #4494 2013-01-25 06:49:04 +01:00
Daniel Marjamäki c235737b6c Uninitialized variables: improved checking of loops 2013-01-24 19:41:15 +01:00
Erik Lax c2608108dd Fixed #3928 (Tokenizer: Wrong simplification of inner if-else 'if (a) while (b) if (c) x; else y;') 2013-01-24 16:53:20 +01:00
Robert Reif cecd726b11 Symbol database: Improved function lookup for foo.f(). Ticket #4494 2013-01-23 16:53:55 +01:00
Daniel Marjamäki f86e83d813 Memory leaks: Improved handling of allocation functions that contains ::. Ticket: #4494 2013-01-22 21:33:39 +01:00
Erik Lax 444f80c4bb Fixed #4505 2013-01-22 13:49:54 +01:00
Robert Reif ddb604d1a5 Symbol database: function lookup when :: is used. Ticket #4494 2013-01-22 06:55:25 +01:00
Frank Zingsheim 096cb1bd88 Fixed #3686: false positive: Possible null pointer dereference (inconclusive) 2013-01-21 19:38:59 +01:00
Daniel Marjamäki bfafd51ca1 Fixed #4470 (New check: redundant bitand 'x&=1; x&=2;' can be simplified to 'x=0;') 2013-01-21 19:59:34 +01:00
Daniel Marjamki c478a3214f Uninitialized variables: Added TODO test case (while) 2013-01-20 18:40:24 +01:00
Daniel Marjamki 76534ccd1b Uninitialized struct member: Fixed false negatives for return statements 2013-01-20 17:54:32 +01:00
Daniel Marjamki d33341a21a Fixed #4502 (Preprocessor: Treat SystemInclude and UserInclude the same) 2013-01-20 14:42:04 +01:00