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
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
7283152d58
Fixed MSVC warning - removed unused variable/function declaration.
2013-02-28 12:51:48 -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
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
Daniel Marjamäki
df55ce14a0
Fixed #4503 (False positive: Incomplete statement (std::vector<int> v{1};))
2013-02-24 10:00:03 +01:00
Daniel Marjamki
5c7e1cf9ff
Fixed #4387 (false positive 'constStatement' in 1.57)
2013-02-23 16:26:25 +01:00
Daniel Marjamäki
1c584208b4
Fixed #4329 (False duplicateBranch when branches use conditionally defined macros)
2013-02-18 17:18:33 +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
89cf24f23f
Refactorization: use Function::nestedIn instead of Function::functionScope->functionOf, which is valid even if the function implementation is not seen.
2013-02-16 01:43:16 -08:00
PKEuS
7b3493322d
Fixed crash when running cppcheck on itself introduced in previous commit
2013-02-15 11:17:14 -08:00
PKEuS
44887df04f
Fixed false positive redundantAssignment when calling function in assignment ( #4513 )
2013-02-15 09:40:34 -08: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
017b4a8a7f
Treat references like global variables in CheckOther::checkRedundantAssignment() as they might refer to such. ( #4425 )
2013-02-15 08:09:31 -08: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
Daniel Marjamäki
1e550f9fdf
Reverted fix for #4547 : It causes fp. See #4573
2013-02-12 16:13:08 +01:00
Ettl Martin
dade326a99
#4566 implemented new check: redundantGetAndSetUserId on posix systems
2013-02-11 20:26:27 +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
Stefan Naewe
e786a2fa5e
lib/checkother: fix compiler warning about unused member
...
Found by clang:
lib/checkother.cpp:2992:31: warning: private field '_symbolDatabase' is not used
[-Wunused-private-field]
const SymbolDatabase *_symbolDatabase;
Signed-off-by: Stefan Naewe <stefan.naewe@googlemail.com>
2013-02-08 12:15:42 +01:00
Robert Reif
42588e9729
Fixed #4535 (Simplify checks by caching symbol database Variable pointer in Token)
2013-02-06 06:39:58 +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
e2faed355b
Fixed #4485 (False positive: Same expression of '-' when checking if float is inf)
2013-01-31 17:29:31 +01:00
Robert Reif
ec1c86c152
Symbol database: more function/variable cleanup. Ticket: #4494
2013-01-31 06:41:18 +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
Robert Reif
859793731d
SymbolDatabase: Refactor findFunction handling. Ticket: #4494
2013-01-28 06:47:48 +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
Zachary Blair
a1cbed3df8
Fixed #4109 (if (c == 1) c == 0; Isn't picked up)
2013-01-17 23:03:04 -08:00
Thomas Jarosch
b1eec7c6b7
Small refactoring to compile more matches
...
*** Timing of the test suite ***
Four runs were used to calculate the average run time.
Before: ~1,103s
After: ~1,066s
Speed up: 3,35%
*** Timing of internal projects using STL ***
Before: ~8,301s
After: ~8,207s
Speed up: 1,13%
So the real world speed up is roughly 1%.
2013-01-17 10:26:03 +01:00
Thomas Jarosch
c8b619ef86
Let the match compiler catch some more patterns
2013-01-16 22:05:28 +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
rofl0r
de72ae9f45
sanitize the descriptive text displayed for "varFuncNullUB"
2013-01-14 18:11:16 +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
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
Zachary Blair
f3c3b7c910
Fixed #4405 (False positive: Memory in freed twice (throw))
2013-01-05 19:02:19 -08:00
Reijo Tomperi
5d5f7085bf
Updating year 2012 -> 2013 to .cpp and .h files and man page.
2013-01-01 18:29:08 +02:00
Thomas Jarosch
1f87c6d669
Fix crash on empty brackets
...
Relevant parts from the backtrace:
2012-12-28 20:16:51 +01:00
Daniel Marjamäki
31297cf7d3
Opposite inner conditions: Clean up copy/pasted code
2012-12-24 12:21:48 +01:00
Daniel Marjamäki
7e8019e474
Fixed #4403 (False positive 'Conversion of string literal <string> to bool always evaluates to true.' with BOOST_ASSERT)
2012-12-20 20:48:48 +01:00
PKEuS
068c695bd1
Fixed false positive when ternary operator is used: case A&&B?B:A:
2012-12-07 12:44:30 -08:00
PKEuS
0ac4c3baf4
New check: Find suspicious case labels like 'case A||B:'
2012-12-07 12:27:32 -08:00
PKEuS
65db8b8b9f
Fixed #4229
2012-12-07 11:45:20 -08:00
Edoardo Prezioso
5101f3c029
Use the new pattern: '%comp%' where possible.
...
Change also the description comment of the Token::Match by adding the new pattern and the forgotten '%op%'.
2012-12-01 01:31:35 +01:00
Robert Reif
6b8e83a181
speed up checks by caching commonly looked up stuff in the symbol database (checkother, checkstl, checkunusedvar). Ticket: #4266
2012-11-16 06:50:49 +01:00
Daniel Marjamäki
79cd601ae7
Fixed #4356 (False positive at variable initialization)
2012-11-15 07:48:45 +01:00
Robert Reif
09eed80938
speed up checks by caching commonly looked up stuff in the symbol database (CheckOther). Ticket: #4266
2012-11-15 07:11:45 +01:00
Robert Reif
04d04c33c2
speed up checks by caching commonly looked up stuff in the symbol database (CheckOther). Ticket #4266
2012-11-14 18:12:33 +01:00
Robert Reif
6578b78077
speed up checks by caching commonly looked up stuff in the symbol database (checkIncorrectLogicOperator). Ticket: #4266 .
2012-11-13 18:30:33 +01:00
PKEuS
3e03838025
Fixed verbose messages in CheckOther::incorrectLogicOperatorError which didn't contain all information of the short message.
2012-11-10 11:31:36 +01:00
PKEuS
ce961578c2
New checks (inconclusive): Suspicious calculation with sizeof()
...
- Check for sizeof(ptr)/something: This indicates that programmer was trying to calculate array size, but sizeof(ptr) doesn't return the length of the memory area, but size of a pointer.
- Check for sizeof()*sizeof(): This indicates that programmer misunderstood what sizeof() does: It does return the length in bytes of the given variable, not e.g. the number of elements in an array.
2012-11-09 18:08:20 +01:00
PKEuS
aa2ad41629
Print message "Found calculation inside sizeof()" also for increment/decrement operator.
2012-11-06 11:39:47 -08:00
PKEuS
bbe06c65c0
Added support for wide-strings (wcs* functions, std::wstring, std::*wstringstream) at many places.
2012-11-06 10:54:52 -08:00
Zachary Blair
51d128c918
Fixed #2029 (free invalid address) by reporting previously-unreported errors as "inconclusive"
2012-11-05 21:02:51 -08:00
PKEuS
1c399c86ca
Improved fix for #4311 ; Added back support for "this." (fixes again #4291 )
...
Added TODO unit test for missing varid.
2012-11-03 21:16:05 +01:00
Daniel Marjamäki
6c2563c467
Fixed #4311 (False positive: warning (selfAssignment): Redundant assignment of 'm_bar' to itself.
2012-11-03 13:18:43 +01:00
PKEuS
a36e008967
Fixed #4314 : Using CheckNullPointer::isPointerDeRef() here is overkill and doesn't work as intended, since this function is designed to return 'false' if it isn't sure.
2012-11-03 10:25:32 +01:00
Daniel Marjamäki
e7483af028
Opposite inner conditions - made check 'experimental' because there are unsolved false positives.
2012-10-21 18:18:29 +02:00
Baris Demiray
d84d360afc
Fixed #4291 (Variable ID is not set when variable is accessed through 'this')
2012-10-19 06:18:13 +02:00
Robert Reif
c7961b147d
speed up checks by caching commonly looked up stuff in the symbol database
2012-10-11 06:12:24 +02:00
Robert Reif
bbfd676b4e
speed up checks by caching commonly looked up stuff in the symbol database
2012-10-10 20:42:07 +02:00
Robert Reif
8ccbde117a
Fixed #4261 (CheckOther::checkComparisonOfFuncReturningBool using wrong function scope test)
2012-10-08 16:15:07 +02:00
Alexander Mai
3656366c7e
Fixed #4257 (False Positive: String literal compared with variable - for non-pointer variable)
2012-10-07 16:26:03 +02:00
Daniel Marjamäki
2f069f550f
Removed Java/C# handling
2012-10-02 18:44:36 +02:00
Edoardo Prezioso
72666e10d1
Related to previous commit: reduce scope level, remove the now redundant check.
2012-10-02 15:19:29 +02:00
Edoardo Prezioso
60de3e75af
CheckOther::checkComparisonOfBoolWithBool,checkComparisonOfFuncReturningBool: use symbolDatabase to check only tokens in executable code.
2012-10-01 15:38:31 +02:00
PKEuS
7a1e64fdd4
Replaced unsafe local isFunction() function by symboldatabase.
2012-09-29 11:32:11 +02:00
PKEuS
c17853949d
Fixed scope handling problems with CheckOther::checkComparisonOfFuncReturningBool(), removed its experimental status.
2012-09-29 11:23:30 +02:00
Daniel Marjamäki
52be4a5925
Disabled checkComparisonOfBoolWithBool since there are false positives. Ticket #2617
2012-09-28 19:11:36 +02:00
Daniel Marjamäki
ff4f8b58f3
Disable checkComparisonOfFuncReturningBool check because of false warnings. Ticket #2617
2012-09-28 18:51:10 +02:00
Edoardo Prezioso
7362ca9e8f
Fixed #4242 (segmentation fault of cppcheck (invalid code: '<'))
2012-09-28 11:24:35 +02:00
Mohit Mate
9e297c95f2
Fixed #2617 (improve check: comparing boolean with '<')
2012-09-26 18:18:36 +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
PKEuS
5237ed2de9
Message refactorization: checkother.cpp
2012-09-16 19:44:02 +02:00
PKEuS
9a624576f4
Revert "CheckOther::clarifyStatement: improved message to show what's the 'bad' and the 'good' expression."
...
This reverts commit f8591f9004
.
2012-09-15 20:19:02 +02:00
Daniel Marjamäki
7ec825cd5d
Cppcheck: Fixed Cppcheck warning about variable scope
2012-09-15 15:54:52 +02:00
PKEuS
22a8e3f4e6
Replaced Tokenizer::getFunctionTokenByName() by SymbolDatabase::findFunctionByName(), which handles scopes slightly better.
2012-09-11 18:03:47 +02:00
PKEuS
5940d77a62
Disabled C++ specific checks and simplifications when checking a C or non-C++ file.
2012-09-10 19:02:32 +02:00
PKEuS
a4b5824dec
New internal check: checkRedundantNextPrevious().
...
Fixed findings by new internal check
2012-09-07 12:36:40 +02:00
PKEuS
e4a693eaab
Refactorizations:
...
- Fixed several findings of CheckInternal.
- Removed some debug code from CheckOther::checkRedundantAssignment().
2012-09-07 11:59:20 +02:00
Edoardo Prezioso
097d0816d0
Fixed #4150 (new ineffective statement check warning wrong).
2012-09-06 17:48:30 +02:00
Arpit Chaudhary
67e40a85e5
Improved check for shifting by negative values and removed false positives
2012-09-05 16:09:40 +02:00
Nilesh Kumar
c7633fc73c
Fixed #3645
2012-09-05 13:48:00 +02:00
Zachary Blair
8546bcc94e
Fixed #2029 (new check: free invalid address)
2012-09-04 23:31:23 -07:00
Daniel Marjamäki
2197b84d78
astyle formatting
2012-09-04 16:29:23 +02:00
Edoardo Prezioso
f8591f9004
CheckOther::clarifyStatement: improved message to show what's the 'bad' and the 'good' expression.
2012-09-04 02:07:55 +02:00
anuraggarg011
b156c727b0
Fixed #3939 : Support ****foo++;
2012-09-03 17:10:27 +02:00
Ankita Gupta
c3a65dca40
Fixed #3793 (improve check: calculation in sizeof)
2012-09-03 15:56:10 +02:00
PKEuS
27cafd495a
Don't bailout for noreturn functions in checkRedundantAssignments outside switch.
2012-09-03 12:03:30 +02:00
PKEuS
d98ee357d4
Fixed crash #4135 when using Q_DECLARE_METATYPE
2012-09-03 11:30:36 +02:00
PKEuS
2be2738c6e
Moved duplicate code into function in CheckOther::checkRedundantAssignment()
2012-09-03 10:46:51 +02:00
PKEuS
81ff721113
Fixed variable shadow warning
2012-09-02 17:00:16 +02:00
PKEuS
7bd732efe4
Invented a fix that compiles on GCC and doesn't crash.
2012-09-02 16:53:38 +02:00
PKEuS
794a491515
Fixed two other compilation errors on GCC.
2012-09-02 16:42:38 +02:00
PKEuS
2d64b69cf4
New check: Detect redundant assignment to a variable and redundant copying to a buffer
...
This check partially replaces the check for redundant assignments in switch
2012-09-02 13:09:32 +02:00
pranav1509
6f6baa67e4
Added more patterns to redundant condition check.
2012-09-01 13:39:32 +02:00
PKEuS
808c3468c9
New check: detect suspicious comparison of string literal with char* variable
...
Bugfix: Update Token type when varId is set
2012-08-24 14:25:17 +02:00
PKEuS
76fbcce13f
Restored (intentional) content of screwed up commits 1bcdf4ce3d
and 674f7980d519712ff16d8f874dfe55a84deb4b5b:
...
- New check (Inconclusive): Array filled incompletely with memset/memcpy/memmove
-- This check only warns if the number of elements is given as size in bytes to memset, memcpy or memmove and if the size of an element is larger than 1 Byte. It does not warn for random numbers
- New check: Detect ineffective statements like '*foo++;' (Should be: '(*foo)++;')
Sorry for the inconveniences.
2012-08-24 11:28:50 +02:00
Edoardo Prezioso
0f1accc2da
Revert latest two commits as they break the compilation and the style. PKEuS???
2012-08-24 00:10:19 +02:00