Commit Graph

280 Commits

Author SHA1 Message Date
XhmikosR 2762a30e48 Prefer prefix operator. 2013-10-01 09:20:19 +03:00
Daniel Marjamäki e3b7bce72b Fixed #4907 (False positive 'uninitStructMember' on structs with unions) 2013-09-30 06:35:31 +02:00
Daniel Marjamäki 698e9e2b59 reverted ee14ea4f. I think this fix was too generic. If there is a union in the struct then only the union members should be skipped. 2013-09-23 17:52:42 +02:00
Daniel Marjamäki ee14ea4fc2 Fixed #4907 (False positive "uninitStructMember" on structs with unions) 2013-09-23 07:20:20 +02:00
Daniel Marjamäki 64454068ec Fixed #4934 (false positive: Uninitialized variable (loop with inner condition '(x=1)')) 2013-09-23 06:07:01 +02:00
Simon Martin 894f537eba Remove warnings emitted by clang's -Wsign-conversion 2013-09-22 13:22:52 +02:00
Lucas Manuel Rodriguez acd65a6829 Fixed #4991: False Positive - Dangerous usage of 'arr' (not null-terminated) 2013-08-29 08:12:05 -03:00
Alexander Mai 7a324cef25 Fixed various Cppcheck inconclusive warnings 2013-07-30 12:52:27 +02:00
Daniel Marjamäki 2a1af1acda CheckUninitVar: Assertion for '} while (' after 'do {..' in debug builds. Bail out in release builds to avoid segfaults. 2013-07-28 12:41:38 +02:00
Daniel Marjamäki 9c67af058a SymbolDatabase: Renamed Variable::varId() to Variable::declarationId() to make it more clear how it works. 2013-07-20 12:31:04 +02:00
Daniel Marjamäki 7443883b9c Library: Improved handling in CheckNullPointer::parseFunctionCall for Library data 2013-07-15 18:55:40 +02:00
Daniel Marjamäki 66d8fa62d1 Library: added init attribute to <alloc> 2013-07-15 08:44:00 +02:00
Daniel Marjamäki 8f332af849 Uninitialized variables: Avoid FP when using '?:' 2013-07-10 16:44:35 +02:00
Daniel Marjamäki 2875ee1ecf astyle formatting 2013-07-07 10:26:20 +02:00
Daniel Marjamäki 2ef0a40aec Fixed #4893 (FP Uninitialized variable on sizeof of itself) 2013-07-06 08:52:47 +02:00
Daniel Marjamäki ef83525cd0 CheckUninitVar: Fixed GCC warning 2013-07-04 07:58:30 +02:00
Daniel Marjamäki ba23b65179 Fixed #4885 (FP Uninitialized variable when using comma) 2013-06-29 09:33:51 +02:00
Daniel Marjamäki 6997d38881 Uninitialized variables: fixed false positive in while loop 2013-06-27 18:28:00 +02:00
Daniel Marjamäki 6b01d2d5a8 Fixed #4747 (Can not find uninitialized variable (variable used in rhs in assignment)) 2013-06-27 16:53:15 +02:00
Daniel Marjamäki 9624a89b34 Uninitialized variables: improved debug warning when bailing out 2013-06-26 20:59:08 +02:00
Daniel Marjamäki 2265c61734 Fixed #4879 (false positive: uninitialized variable in inner for inside while (regression)) 2013-06-26 17:02:57 +02:00
Daniel Marjamäki cfd960d794 Fixed #3765 (false negative: unitialized variable) 2013-06-25 18:40:41 +02:00
Daniel Marjamäki ae36472a1b Fixed #4778 (FP: Uninitialized variable: av) 2013-06-14 07:21:53 +02:00
Daniel Marjamäki 065853a59a Fixed #4652 (False positive: variable value tracking into loop body) 2013-05-29 16:16:12 +02:00
Frank Zingsheim bca751b9f4 Fixed #4773 (Regression: wrong detection of unitialized variable) 2013-05-06 18:45:00 +02:00
Daniel Marjamäki bfb1bc50e3 Fixed #4760 (false negative: (error) usage of uninitialized variable (struct member)) 2013-05-02 20:34:15 +02:00
Daniel Marjamäki 44cb070e13 Fixed #4737 (False positive: Uninitialized variable 'do_something(&((char*)&var)[0],1);') 2013-05-01 13:52:28 +02:00
Daniel Marjamäki 7fdaba43ed Uninitialized variables: Fixed fp when initializing struct with function in loop body 2013-04-10 20:46:44 +02:00
Daniel Marjamäki 96a5429cee Uninitialized variables: Assume that function initializes struct if it is unknown if it does 2013-04-10 20:04:32 +02:00
Daniel Marjamäki 4c8b17c040 Fixed #4717 (False positive: Uninitialized variable inside ({..})) 2013-04-09 17:02:11 +02:00
Daniel Marjamäki 0a17829021 removed extra newline 2013-04-08 19:52:48 +02:00
Daniel Marjamäki 894a2435ae Fixed #4718 (False positive: unititialized variable (value flow)) 2013-04-08 19:34:39 +02:00
Daniel Marjamäki c9469993e2 Uninitialized variables: Fixed false positives when using sizeof inside loop 2013-03-22 08:10:46 +01:00
Daniel Marjamäki a79354d51c Uninitialized variables: Fixed false positive when taking address of uninitialized array that is a struct member 2013-03-20 16:59:45 +01:00
Daniel Marjamäki 1f04e2c228 Fixed #4439 (False positive: Uninitialized variable (casting address)) 2013-03-13 17:32:47 +01:00
PKEuS 66a3555897 Implement initial support for Types in Symboldatabase:
- For each class/struct/union, a Type instance is added to SymbolDatabase::typeList.
- A scope is no longer created for declared but not defined types

Fixed name detection for classes when they are declared like this: "class ::Foo::Sub {..."
2013-03-05 04:33:38 -08:00
PKEuS 0105f8223c Simplified several Token::Match/simpleMatch calls when match string consists of a single pattern
Fixed two CheckInternal error messages
2013-03-01 03:42:04 -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 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 382d7a10e8 Uninitialized variables: improved checking of c++ code 2013-02-15 18:13:47 +01:00
Thomas Jarosch 72a40b4da4 Use Token::simpleMatch for simple patterns
"internal" check reported:
[lib/checkuninitvar.cpp:1101]: (warning) Found simple pattern inside Token::Match() call: "if ("
2013-02-14 12:35:13 +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
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 b660cf89ef astyle formatting 2013-02-10 23:53:01 +01:00
Mathias De Maré dfd557888d Fixed #4565 (false positive: dangerous usage (not null-terminated)) 2013-02-10 13:36:40 +01:00
Daniel Marjamäki 4ac5648656 Uninitialized struct: Fixed false positive in for loop 2013-02-05 17:01:46 +01:00
Daniel Marjamki 9124847211 Uninitialized variable: Refactoring. Use Token::variable() instead of symboldatabase lookup. Ticket: #4535 2013-02-02 16:27:12 +01:00
Daniel Marjamki 9c8d600ca9 Uninitialized variables: Refactor CheckUninitVar::isVariableUsage 2013-02-02 15:21:54 +01:00
Daniel Marjamäki a04f7b1a94 CheckNullPointer::isPointerDeRef: Refactoring - use tok->variable(). Ticket: #4535 2013-02-01 19:10:14 +01:00
Robert Reif ec1c86c152 Symbol database: more function/variable cleanup. Ticket: #4494 2013-01-31 06:41:18 +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 Marjamki 8738223e82 Fixed #4512 (Improve check: Uninitialized variable not detected) 2013-01-26 08:16:53 +01:00
Daniel Marjamki 04ceae7ea7 Uninitialized variables: minor refactorings 2013-01-26 07:28:11 +01:00
Daniel Marjamäki ae43b12bf1 Fixed #4511 (False positive: uninitialized struct member) 2013-01-25 18:20:57 +01:00
Daniel Marjamäki c235737b6c Uninitialized variables: improved checking of loops 2013-01-24 19:41:15 +01:00
Daniel Marjamki 76534ccd1b Uninitialized struct member: Fixed false negatives for return statements 2013-01-20 17:54:32 +01:00
Daniel Marjamki e63f2c3b5b Uninitialized struct member: Avoid false positive when struct member is passed by address 2013-01-20 13:12:40 +01:00
Daniel Marjamki f1c195e652 Fixed #3506 (false negative: not initialized variables ( struct timeval)) 2013-01-19 12:48:56 +01:00
Thomas Jarosch 7c4f0e594b astyle formatting 2013-01-19 11:49:35 +01:00
Daniel Marjamki 3cf0e88fbe Uninitialized struct members: Improved checking when struct member is used in expression 2013-01-19 10:09:58 +01:00
Daniel Marjamäki 7c615f0f12 Fixed #4497 (False positive: uninitialized struct (writing/reading member)) 2013-01-18 21:26:28 +01:00
Daniel Marjamäki c59dab2738 uninitialized struct member: changed severity from warning to error since it is UB 2013-01-17 23:18:37 +01:00
Daniel Marjamäki 2c6b383822 Uninitialized member variables: Improvements 2013-01-17 21:04:22 +01:00
Daniel Marjamäki e32ab4bf65 uninitialized struct members: improved fix 2013-01-17 17:21:21 +01:00
Daniel Marjamäki 93fb6b0c6a Fixed #4493 (FP: uninit struct member (struct is assigned)) 2013-01-17 17:01:04 +01:00
Daniel Marjamäki 5773e69ab1 Uninitialized variables: Add experimental checking of struct members 2013-01-16 20:28:29 +01:00
Andrew C. Martin 4a73c93750 Fix compiler warnings and comment/string typos
- fix g++ warning:

> lib/checkother.cpp:3779: warning: comparison between signed and unsigned integer expressions

 - fix suncc warning (see [everything2](http://everything2.com/title/C%252B%252B%253A+static+extern+%2522C%2522)):

> "lib/checkmemoryleak.cpp", line 578: Warning (Anachronism): Formal argument __compar of type extern "C" int(*)(const void*,const void*) in call to bsearch(const void*, const void*, unsigned long, unsigned long, extern "C" int(*)(const void*,const void*)) is being passed int(*)(const void*,const void*).

- prefer empty() / isEmpty() over "size() > 0" (cases not caught by stlSize)

- fix word misspellings (mostly comments, a few output lines)

  - Parenthesis => Parentheses (both variations were used in the codebase)

  - fix typo and wording ("never alwayw") in gui/test/data/benchmark/simple.cpp's CheckOther::unsignedPositive():

```
-  "An unsigned variable will never alwayw be positive so it is either pointless or "
+  "An unsigned variable can't be negative so it is either pointless or "
```
2013-01-16 07:37:07 -07:00
Reijo Tomperi 5d5f7085bf Updating year 2012 -> 2013 to .cpp and .h files and man page. 2013-01-01 18:29:08 +02:00
Daniel Marjamäki de2c133f6a Fixed #4426 (False positive: Unitialized variable warning when comparing addresses) 2012-12-28 12:32:15 +01:00
Daniel Marjamäki 6770cc80be Uninitialized variables: Added debug warning for bailout 2012-12-28 11:42:50 +01:00
Daniel Marjamäki b914466285 Uninitialized variables: fixed false positives by bailing out when variable is conditionally initialized and then there is a conditional return. 2012-12-27 18:45:00 +01:00
acm4me 7da155c8ba Support for Sun Studio C++ compiler 2012-12-27 11:51:12 +01:00
Daniel Marjamäki f16c30248a Uninitialized variables: fixed FP when there are function calls where type* is converted to unknown_type 2012-12-25 14:05:29 +01:00
Daniel Marjamäki f381058293 Uninitialized variables: fixed FP when there are suspicious function calls where type** is converted to type* 2012-12-25 13:58:15 +01:00
Daniel Marjamäki bcc5a82b1d Uninitialized variables: Fixed FP when using typeof on uninitialized data in return statement 2012-12-25 13:31:54 +01:00
Daniel Marjamäki 299c1bb208 Uninitialized variables: handle unsimplified labels better 2012-12-25 10:37:21 +01:00
Daniel Marjamäki 83da4125e3 Uninitialized variables: Better value flow analysis. Fixed false positives. 2012-12-24 19:11:13 +01:00
Daniel Marjamäki 0b4da3d5cd Uninitialized variables: Fixed false positives when variable x is given a nonzero value when variable y is uninitialized. 2012-12-23 16:27:04 +01:00
Daniel Marjamäki 2050cd71db Uninitialized variables: Better testing of function handling 2012-12-21 19:32:56 +01:00
Daniel Marjamäki dc6aa92f3b Uninitialized variables: warn about structs in C code 2012-12-21 18:50:38 +01:00
Daniel Marjamäki cf84c211ed Uninitialized variables: Improved handling of function calls 2012-12-21 17:04:15 +01:00
Daniel Marjamäki 415ee977d8 Uninitialized variables : fixed false positives when passing address of pointer to function. 2012-12-21 16:57:49 +01:00
Daniel Marjamäki ccdea4dc2b Uninitialized variables: Improved checking of functions 2012-12-20 19:45:30 +01:00
Daniel Marjamäki 3913fd8398 Fixed #4320 (False positives 'unassignedVariable' and 'uninitvar') 2012-12-18 19:02:30 +01:00
Daniel Marjamäki 82223227bd Uninitialized variables: Fixed false negative in new checking when using while loops 2012-11-30 06:30:04 +01:00
Daniel Marjamäki 68327b3c64 Uninitialized variables: Fixed TODO testcase 2012-11-29 18:41:48 +01:00
PKEuS 6122819832 Message refactorization: Changed expression "0-terminate" to "null-terminate" as discussed on 24b98feadb 2012-11-03 21:21:19 +01:00
PKEuS 24b98feadb Message refactorization: checkuninitvar.cpp, checkunusedfunctions.cpp, checkunusedvar.cpp 2012-11-01 18:40:20 +01:00
Edoardo Prezioso 8324de1dc0 Fixed 'tokAt(-2)->link() -> linkAt(-2)' thanks to cppcheck internal check. 2012-10-13 14:59:34 +02:00
Daniel Marjamäki 753942df0c Revert "Fixed #4165 (False positive:(error) Uninitialized variable: here)"
This reverts commit 96b1890797.
2012-09-26 16:15:35 +02:00
Daniel Marjamäki 96b1890797 Fixed #4165 (False positive:(error) Uninitialized variable: here) 2012-09-25 20:45:42 +02:00
PKEuS 508e9394d3 Added some nullpointer-checks and removed some redundant ones based on VS2012 code analysis results. 2012-09-17 15:22:51 +02:00
Daniel Marjamäki 84c0368bfd Fixed #3586 (false positive: uninitvar in argument in namespaced function) 2012-09-15 10:48:17 +02:00
Daniel Marjamäki d3bdd84d8b Fixed #4175 (segmentation fault of cppcheck) 2012-09-09 18:56:26 +02:00
Daniel Marjamäki d34924ba6d Uninitialized variables: Fixed false positive when there is assignment in condition 2012-07-17 07:03:40 +02:00
Daniel Marjamäki f9da83f4b5 Fixed #3926 (false postive: (error) Uninitialized variable: exitpattern) 2012-07-03 18:52:23 +02:00
Daniel Marjamäki 2e3a08a8c1 Fixed #3916 (false positive: uninitialized variable when using assignment and , in rhs) 2012-06-27 20:44:19 +02:00