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
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 Marjamäki
67c9720299
Tokenizer: fixed simplification of static constants
2013-01-19 21:14:15 +01:00
Daniel Marjamki
bff6ed7af0
Fixed #3500 (false negative: (error) Returning pointer to local array variable)
2013-01-19 13:39:23 +01:00
Daniel Marjamki
f1c195e652
Fixed #3506 (false negative: not initialized variables ( struct timeval))
2013-01-19 12:48:56 +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
Zachary Blair
8647e4c0d0
Fixed a false positive in #4109 (if (c == 1) c == 0; Isn't picked up)
2013-01-18 16:34:15 -08:00
Daniel Marjamäki
7c615f0f12
Fixed #4497 (False positive: uninitialized struct (writing/reading member))
2013-01-18 21:26:28 +01:00
Zachary Blair
a1cbed3df8
Fixed #4109 (if (c == 1) c == 0; Isn't picked up)
2013-01-17 23:03:04 -08:00
Daniel Marjamäki
77e9f65e6b
Uninitialized struct members: Fixed unit test
2013-01-17 23:55:13 +01:00
Daniel Marjamäki
2c6b383822
Uninitialized member variables: Improvements
2013-01-17 21:04:22 +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
Daniel Marjamäki
4cd8c7c608
Merge pull request #128 from acmyo/master
...
Fix compiler warnings and comment/string typos
2013-01-16 08:00:59 -08:00
Daniel Marjamäki
0fb2d309a6
Fixed #4490 (False positive: unused function (function pointer is taken in global scope))
2013-01-16 16:52:57 +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
Daniel Marjamäki
27eedcd0a3
Merge pull request #127 from rofl0r/master
...
sanitize the descriptive text displayed for "varFuncNullUB"
2013-01-15 21:34:03 -08:00
rofl0r
623e30d677
fix unit test for varFuncNullUB
2013-01-15 20:45:53 +01:00
Daniel Marjamäki
2fa35a6f8d
Fixed #4429 (unused functions: handle function declarations better)
2013-01-15 17:00:28 +01:00
Daniel Marjamäki
d46789ee4a
varFuncNullUB: fixed false positive when non-variadic argument is NULL ( #4482 )
2013-01-14 06:44:52 +01:00
Erik Lax
723d95597b
Fixed #4481 (Simplify %str% [ %num% ])
2013-01-13 20:52:38 +01:00
Daniel Marjamäki
f0ce26a2aa
Preprocessor: Let the Tokenizer handle NULL
2013-01-13 15:01:31 +01:00
Daniel Marjamäki
2e56928834
Fixed #4482 (add test for UB due to usage of NULL in variadic functions)
2013-01-13 12:02:10 +01:00
Daniel Marjamäki
97b928b2bc
Fixed #4476 (Tokenizer: wrong simplification of static anonymous-type struct array declaration)
2013-01-10 18:24:01 +01:00
Zachary Blair
309edbbdc5
Fixed #4389 (False positive: Possible null pointer dereference if the default parameter value is used)
2013-01-09 23:22:54 -08:00
Edoardo Prezioso
6236e1dc38
Token::Match: removed harmless special code for initial '!!foo' patterns.
2013-01-09 20:13:33 +01:00
Thomas Jarosch
7dd07d8e77
Properly implement %op% for Token::multiCompare
...
Use tok->isOp() instead of doing it "manually".
This fixes false positives for the C++ template case since
the brackets in "template < something >" are not comparison operators.
Profiling showed using tok->isOp() is actually faster than before (-O2).
2013-01-09 17:05:53 +01:00
Thomas Jarosch
29c66dd9bc
Add another TODO test case for Token::Match
2013-01-08 00:19:12 +01:00
Thomas Jarosch
818362f496
Add TODO test case for a bug in Token::Match multicompare
...
The result of the %op% operator is wrong in the multicompare
case for C++ templates. Detected by comparing the output
of the compiled matches with the on-the-fly match parser.
2013-01-07 23:47:20 +01:00
Frank Zingsheim
498d03458f
Fixed #4385 : lock_guard RAII throws unreadVariable
2013-01-07 20:28:43 +01:00
Daniel Marjamäki
eebfea2b23
Fixed #4381 (Inline type declaration on statics causes warning)
2013-01-07 19:20:15 +01:00
Zachary Blair
f3c3b7c910
Fixed #4405 (False positive: Memory in freed twice (throw))
2013-01-05 19:02:19 -08:00
PKEuS
f5ebbff0a3
Fixed #4460 : Ensure that memset/memcpy is called on a pointer to a class instance.
2013-01-05 12:27:55 -08:00
Edoardo Prezioso
4c73c29cdd
Revert partially the previous commit:
...
The two formulas are true iff 2n = 2 <=> n = 1.
2013-01-05 17:31:08 +01:00
Edoardo Prezioso
1c0c0471df
Simplify some generalized math formulas:
...
Now the 'sin^2+cos^2=1' and the 'sinh^2-cosh^2=-1' code can handle, for example: sin^4+cos^4=1, sinh^10-cosh^10=-1.
Also, the arguments can be also multitokens, so that it's possible to simplify, for example: 'sin^2(k())+cos^2(k())=1'.
2013-01-04 13:06:09 +01:00
Edoardo Prezioso
5485e6866f
Fixed wrong tokenization of some math formulas:
...
The two formulas: sin^2+cos^2 = 1 and sinh^2-cosh^2 = -1 are true iff the two arguments are the same.
2013-01-04 11:28:01 +01:00
Robert Reif
d37906041b
Fixed #4458 (False positive: noCopyConstructor in template class)
2013-01-04 10:35:24 +01:00
Daniel Marjamäki
a3ee72a51d
Fixed #4409 (Cppcheck 1.58 dev hangs when checking mhz.c of lmbench3 (attached code))
2013-01-03 19:14:44 +01:00
Daniel Marjamäki
70059c06de
Fixed #4456 (std::string::compare(char const*) crash)
2013-01-03 08:44:32 +01:00
Daniel Marjamäki
6e58ed3040
Fixed #4454 (False positive: class member (POD) not initialized (when initialized to 0 in initializer list))
2013-01-02 13:59:57 +01:00