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
PKEuS
1bcdf4ce3d
New check: Detect ineffective statements like '*foo++;' (Should be: '(*foo)++;')
2012-08-23 12:28:40 -07:00
PKEuS
674f7980d5
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
2012-08-23 11:27:00 -07:00
Arpit Chaudhary
7c8da17c44
Added check for detecting if a variable or number is shifted by negative right operand. Statements like:
...
int i = -1;
a << i;
would result in an error message stating undefined behavior.
2012-08-22 15:44:20 +02:00
Kumar Ashwani
afe030ce9b
Fixed #2628 : Detect redudant usage of operator++/-- in switch.
2012-08-22 14:40:57 +02:00
Edoardo Prezioso
2b5cd2effc
Fixed G++ [-Wparentheses] warning. This also fixed #4073 (Crash on self assignment).
2012-08-21 20:15:04 +02:00
PKEuS
b4b5c80db9
Improved check: Added message when checking sign of a pointer.
2012-08-21 03:28:02 -07:00
PKEuS
b641a10e35
Fixed false negative: memset(foo, 0, sizeof(&foo)); is as suspicious as memset(foo, 0, sizeof(foo));
2012-08-20 10:08:18 -07:00
PKEuS
a243983242
Refactorized type handling in CheckIO and CheckOther:
...
- Added several types (std::) to isComplexType
- Types in namespace std:: are considered to have no side-effects (solved one TODO)
- Scope of a pointer can be limited without side effects
2012-08-20 08:57:28 -07:00
PKEuS
c8773b891d
Refactorization: Make use of Token::scope() replacing certain indentation counters
2012-08-12 03:13:07 -07:00
PKEuS
452f95cea0
More robust template detection in clarifyCondition check based on Token::link. ( #3818 )
...
Create links between < and > only on non-C code.
AStyle fix
2012-08-02 04:03:01 -07:00
Ettl Martin
98d608231d
spelling fixes
2012-07-31 23:35:56 +02:00
PKEuS
4e2a86260f
Really fixed #3941 .
2012-07-29 06:50:05 -07:00
PKEuS
26a2379f9f
Fixed false positive #3941 .
2012-07-29 06:39:43 -07:00
PKEuS
ae6201d289
Fixed false positive "Parameter 'x' is passed as a value" for types like std::vector<T>::size_type ( #3986 )
2012-07-23 01:41:20 -07:00
Zhao Qifa
188d2e143d
add a performance checker for const assignment
2012-07-22 09:17:00 +02:00
PKEuS
41fecb2e6d
Fixed evaluation of redundant conditions ( #3972 )
2012-07-13 06:01:19 -07:00
PKEuS
e8f4dce25f
Added check to CheckInternal: detect invalid patterns like "%typ%"
...
Replaced some Token::Match by Token::simpleMatch (suggestions of internal checks)
2012-07-11 08:45:16 -07:00
Robert Morin
25c1cc4c8e
Improve check: warn when comparing boolean value with < <= > >=. Ticket: #2617
2012-07-03 06:39:13 +02:00
Daniel Marjamäki
162a430354
Fixed #3868 (false positive: (style) Same expression on both sides of '|'.)
2012-06-23 19:54:15 +02:00
Daniel Marjamäki
a15dac9285
simple spell checking 'itis' => 'it is'
2012-06-23 10:08:18 +02:00
Daniel Marjamäki
3db58bb57f
Reviewed C handling in CheckOther::clarifyCondition, never treat x<..> as a template in C files.
2012-06-23 07:29:49 +02:00
Daniel Marjamäki
8aba801360
Fixed #3800 (False negative: Self-assignement of variable declared as 'extern')
2012-06-22 11:23:50 +02:00
Zachary Blair
fa2bca1e09
Ticket #3876 : Improved check by only bailing of loops that contain break or continue
2012-06-16 13:11:09 -07:00
Daniel Marjamäki
89b1b4ea6e
Fixed #3892 (False positive: 'if (var >= 0.0) then if (var >= 0.0) always returns true
2012-06-15 16:54:02 +02:00
Zachary Blair
e2348560e4
Fixed Ticket #3876 (Error (double free) detected that can't possibly happen)
2012-06-10 17:50:31 -07:00
Daniel Marjamäki
905615e991
Fixed #3878 (Sign extension with unsigned char false positive)
2012-06-09 08:43:13 +02:00
PKEuS
e191f0d7d4
Fixed test failures in testio caused by my last commit.
2012-06-08 10:35:08 -07:00
PKEuS
c463d97386
Refactorization:
...
- Implemented consistent behaviour of Variable::typeStartToken/typeEndToken: Skip const and static on all variables.
- Simplified patterns containing "static|" or "const|" when matching typeStartToken.
2012-06-08 09:05:02 -07:00
Daniel Marjamäki
69846b2a06
Fixed #3872 ('char variables in bit operations' warning)
2012-06-08 17:24:54 +02:00
Zachary Blair
2bd171dded
Fixed #3794 (New check: Missing break in switch (duplicate bitwise operation))
2012-05-28 21:19:22 -07:00
PKEuS
9dc8123151
Refactorizations:
...
- Use const string references instead of const strings copies when possible
- Fixed cppcheck warning about postfix increment in CheckIO
- Use symbolDatabase to detect pointers in CheckOther::checkAssignBoolToPointer
2012-05-25 03:09:41 -07:00
PKEuS
e2bab4b6a3
Implemented Function::nestedIn to be able to identify the scope the function belongs to, even if Function::functionScope.functionOf is not available.
...
Refactorized usage of SymbolDatabase in checkOther:
- Don't copy Function instances in checkExpressionRange
- Simplifications by more accurate usage of information in database
2012-05-24 08:40:43 -07:00
PKEuS
97c4af44ca
Refactorizations in checkOther:
...
- More accurate usage of symbolDatabase to reduce code and false negatives
- Avoided unnecessary construction of pattern string
- Only search for class/struct definition before usage
2012-05-24 06:34:59 -07:00
PKEuS
334fc16f29
Refactorized CheckOther::checkSizeofForArrayParameter: Use symboldatabase to detect arrays.
2012-05-24 00:39:16 -07:00
Daniel Marjamäki
77e9106ec0
Fixed #3634 (False positive: compareBoolExpressionWithInt when using boost::tuples)
2012-05-22 19:01:21 +02:00
PKEuS
b81eafe0dc
Splitted CheckIO from CheckOther.
2012-05-20 02:57:07 -07:00
PKEuS
be7b104a8e
Added missing checks to CheckClass::classInfo()
...
Replaced tokAt(1) with next() in checkother.cpp
2012-05-19 01:51:47 -07:00
Andy Maloney
4686294d7e
Fix compiler warning about empty for body
2012-05-18 14:00:10 -04:00
PKEuS
a9cfe2814a
Made some functions const according to cppcheck results
2012-05-17 02:54:17 -07:00
Daniel Marjamäki
f803a18d50
Fixed #3749 (false positive: same expression on both sides of operator)
2012-05-17 07:26:57 +02:00
PKEuS
06a77679d4
Refactorizations:
...
- Added support for pointers in self assignement check
- Removed redundant for loop in checknullpointer.cpp
- Fixed warning about signed/unsigned mismatch in cppcheck.cpp by making Settings::_maxConfig unsigned
2012-05-11 10:38:19 -07:00
PKEuS
ec00824fd3
Fixed #3357 :
...
- Print "inconclusive" tag in cli
- Fixed inconclusive handling in checkbufferoverrun.cpp
- Merged reportInconclusiveError into reportError by adding an additional parameter "bool inconclusive" which is false per default
2012-05-06 10:37:41 -07:00
Ettl Martin
bb8342fbb4
fixed misspelled word 'Comparision' --> 'Comparison'
2012-04-26 23:04:55 +02:00
PKEuS
92737578ac
Refactorizations:
...
- removed unused function CheckOther::concatNames
- Replaced one indendation counter by Token::link() in checkother.cpp
- Forward declaration of Settings in threadexecutor.h
2012-04-26 15:29:39 +02:00
PKEuS
5ac7552e4e
New check: Comparision of modulo results that are always true/false.
2012-04-26 15:23:47 +02:00
PKEuS
dd5e9aa454
Make use of recently implemented Token::type() functionality
2012-04-25 09:56:07 +02:00
PKEuS
6a37c36ee8
Fixed #3741
...
Removed redundant nullpointer check (cppcheck catch)
2012-04-18 16:35:04 +02:00
PKEuS
8e5949c6ce
Added several C++11 algorithms and containers to CheckStl
...
Added pattern "> %varid%" to CheckStl::stlBoundries()
Fixed message in checkOther (#1320 )
2012-04-17 12:54:01 +02:00
PKEuS
bac8ed7127
Refactorized stringification of tokens:
...
- Function that stringifies one token: Token::stringify()
- Functions that stringify a list of tokens: Token::stringifyList()
-- Single and powerful "base" function, used by several "light" functions
Refactorized
- testtokenize.cpp and testsimplifytokens.cpp: Use improved stringification functions instead of several local implementations
- Avoided redundand creation of std::string when using TestTokenizer::tokenizeAndStringify and in cmdlineparser.cpp
2012-04-16 19:51:07 +02:00
Daniel Marjamäki
66227c4da0
Fixed #3609 (clarifyCondition delivers false positives when using Windows-Traits as a template)
2012-04-08 18:07:11 +02:00
Daniel Marjamäki
6360afdcfa
CheckOther: Use reportInconclusiveError to report inconclusive error
2012-04-08 10:47:01 +02:00
PKEuS
b0f571b25c
Fixed #3383 : If there is an empty line between subsequent break statements, only issue a message for inconclusive checking
2012-04-05 10:38:29 +02:00
PKEuS
c1fc7a2218
Improved CheckOther::checkComparisonOfBoolWithInt and CheckOther::checkComparisonOfBoolExpressionWithInt:
...
- Added support for comparision of bool constant with number constant (-> fixed #1877 ) and integer variable with boolean expression
- Moved a check from checkComparisonOfBoolWithInt to checkComparisonOfBoolExpressionWithInt
- Generalized some patterns
- Made error message more accurate concnerning the "neither 0 nor 1" part.
- Reduced number of Token::Match calls
2012-04-02 15:45:51 +02:00
PKEuS
033e4a2c1f
Fixed #3676 .
2012-04-02 11:21:04 +02:00
PKEuS
989ac449e4
Made invalidPointerCast message inconclusive for casting from floating point type* to char* ( Fixed #3639 )
2012-03-25 12:55:39 +02:00
Daniel Marjamäki
1d95416840
astyle formatting
2012-03-25 11:51:59 +02:00
Daniel Marjamäki
ca6a93816b
Merge pull request #89 from HeisSpiter/master
...
Merged two checks to get a better one regarding sizeof
2012-03-25 02:38:04 -07:00
PKEuS
e4d92055e7
Improved sizeofCalculation check:
...
- Bailout on expanded macros for conclusive checking
- Support for more operators
- Removed indendation counter
Improved checkSignOfUnsignedVariable:
- Made the patterns more generic
- Improved verbose error message (-> Fixed #3080 )
2012-03-25 11:32:00 +02:00
Pierre Schweitzer
2b5ddb7858
Merge the strncmp & malloc sizeof checks into a more generic test that handles several cases where sizeof is misused, or could be misused
2012-03-23 21:47:13 +01:00
PKEuS
e938235385
Store functions which are declared but not implemented in the function list of the containing scope -> Fixed #3679
...
Refactorizations:
- Simplified some code
- Improved condition in findVariableType to reduce unnecessary comparisions of empty strings.
2012-03-23 17:59:51 +01:00
Pierre Schweitzer
ec44967e13
Add a new test to check improper sizeof usage. It's for the moment limited to malloc calls.
2012-03-21 21:13:09 +01:00
PKEuS
4587a1a06c
Fixed recently introduced assertion failure in debug mode
2012-03-15 21:06:24 +01:00
PKEuS
b6057a1148
Improved CheckOther::checkIncorrectLogicOperator:
...
- Added a lot of additional pattern
- Rewrote error messages to make them more understandable and better fitting to the situation. (Fixed #3664 )
- Cleanup in unit tests
Improved message of static string comparision check
2012-03-15 20:38:28 +01:00
PKEuS
7cfffc9c9d
Improved CheckOther::checkIncorrectLogicOperator:
...
- Implemented automatic swapping of conditions and operands
- Added several patterns
- Added support for conditions outside of if/while
2012-03-12 19:06:30 +01:00
PKEuS
6f164de609
Improved static string comparision check: Implemented #3214
...
Fixed false negative on argument count of fnprintf/snprintf when first variable argument is a string. (#3655 )
Uncommented call of virtualDestructorError in getErrorMessages in checkclass.h
Refactorizations:
- Rearranged code in checkother.h to make ordering more consistent and to increase encapsulation of private data
- Replaced some single-token-patterns
2012-03-11 11:01:39 +01:00
Daniel Marjamäki
3f1ab5af9b
charvar: dont write warning about char type array index when array is small and the full valid range is accessible with the char type. If there are out of bounds access then, it is not because the type of the variable.
2012-03-10 12:19:28 +01:00
Simon Martin
190cba519d
Fixed shadowing warning
2012-03-09 08:06:58 +01:00
PKEuS
ef6e381d47
Improved bitwise on boolean check to make it working on more code patterns
...
Refactorizations in checkother.cpp:
- Make use of symboldabase instead of: indentation counters, manual detection of variable declarations
- Removed some indexing variables to reduce calls to tokAt and the numbers given to this function
- Use tok->nextArgument() to jump to a specific argument
2012-03-03 21:14:20 +01:00
PKEuS
1ef99e2f21
Improved checkautovariables:
...
- Added support for checking a few more code patterns
- Simplified code by using more information from the symboldatabase
- Moved redundant part of c_str-check to checkstl
Two fixes according to output of pvs studio in testsimplifytokens.cpp
2012-03-01 18:38:20 +01:00
Ettl Martin
2ac907b40a
fixed compiler warning (gcc-4.6.1)
2012-02-27 14:13:34 +01:00
PKEuS
1747813a8b
Added check for invalid pointer casts ( #1255 )
...
Detect sign extension problems when variable is a reference (#3637 )
Refactorizations:
- Tokenizer::getFiles returns a reference instead of a pointer, because its guaranteed that no nullpointer is returned
- Remove signed/unsigned in one step for "%type% signed|unsigned"
- Fixed recently introduced compiler warning in symboldatabase.cpp
2012-02-26 11:56:32 +01:00
Zachary Blair
9d75641ef8
Fixed #3598 (false positive: (error) Memory pointed to by 'a' is freed twice.)
2012-02-16 21:03:38 -08:00
Zachary Blair
8f827aa65f
FIxed #3581 (double free false positive when exception rethrown)
2012-02-04 11:24:40 -08:00
PKEuS
d5c2c7db88
- Moved checkCatchExceptionByValue from CheckOther to CheckExceptionSafety
...
- Fixed false positive: throw outerCatchVar; in inner catch is now correctly handled
- Added eTry and eCatch to Scope::isLocal -> Scopes inside catch are now detected by symbol database
2012-02-02 16:17:42 +01:00
PKEuS
22c1ce8a68
Fixes for #3480 and #3568 .
2012-01-31 15:49:34 +01:00
Edoardo Prezioso
bb703f4d0b
Fixed: (warning) Found simple pattern inside Token::Match() call.
2012-01-28 20:31:12 +01:00
PKEuS
91a01a0a0d
- checkUnsignedDivision checks for variable/variable (inconclusive). General bailout for if-statements.
...
- Make use of recently implemented symboldatabase functions (catch-support, reference-support)
- Other refactorizations
2012-01-28 12:32:28 +01:00
Zachary Blair
589a2461bd
Fixed ticket #3550 (false positive: (error) Memory pointed to by 'pxpm' is freed twice)
2012-01-24 22:43:44 -08:00
PKEuS
36479499e7
- Solved FIXME: Made detection of code that is no pointer-dereference more robust, uncommented code (checknullpointer.cpp)
...
- Removed more indendation level counters
- Make use of symbol database more often
- Other refactorizations
2012-01-21 19:55:32 +01:00
PKEuS
96ae010e48
- Correctly set Scope::function variable in symboldatabase
...
- Refactorizations
- Fixed some cppcheck warnings
2012-01-21 10:08:09 +01:00
Zachary Blair
0415444e28
Merge branch 'master' of github.com:danmar/cppcheck
2012-01-19 23:02:33 -08:00
Zachary Blair
b89adff9fd
Fixed Ticket #3300 (false negative: doublefree of pointer)
2012-01-19 22:59:54 -08:00
Daniel Marjamäki
525e7fba20
Fixed #3490 (False positive: sscanf with %c)
2012-01-18 23:57:08 +01:00
Stefan Weil
7607e4c68d
Fixed #3519 (Wrong line number in warning charBitOpError)
2012-01-18 13:09:46 +01:00
PKEuS
c294b15360
Removed more indendation counters.
2012-01-15 12:31:49 +01:00
Reijo Tomperi
dd18f595b1
Fix #3516 (inaccurate warning: "An unsigned variable will always be positive" (unsigned n; if (n >=0);))
...
http://sourceforge.net/apps/trac/cppcheck/ticket/3516
2012-01-14 12:50:09 +02:00
Daniel Marjamäki
65ce55e675
Fixed #3472 (false positive: (error) Passing value 0 to log() leads to undefined result)
2012-01-08 12:07:25 +01:00
PKEuS
eabdc9082e
Fixed false positives related to %*[] in scanf format string ( #3468 )
2012-01-04 11:22:42 +01:00
PKEuS
621d43e9e4
Fixed #3461 : Support for %m* on scanf-functions
2012-01-02 14:05:58 +01:00
Reijo Tomperi
8cae17fda8
Update year to 2012
2012-01-01 01:05:37 +02:00
Erik Lax
3d0c1a3301
Fix #3457 (Statement following goto can be executed)
...
http://sourceforge.net/apps/trac/cppcheck/ticket/3457
2012-01-01 00:11:03 +02:00
Reijo Tomperi
65b58bcb99
Partial fix to #3452 (ErrorLogger: complain/raise assertion when error message has extra newlines etc)
...
http://sourceforge.net/apps/trac/cppcheck/ticket/3452
Add assert for newlines.
2011-12-30 01:22:16 +02:00
Marek Zmysłowski
dd8316474a
Fixed #3335 (new check: warn about potential missuse of isgraph-like functions)
2011-12-29 08:08:37 +01:00
Reijo Tomperi
90e1a397a2
Refactoring: Remove duplicate function from tokenizer: code_is_c() -> isC()
2011-12-29 00:36:16 +02:00
Edoardo Prezioso
bbac4f1faf
Fix ticket #3451 (A (style) type warning witout message text).
2011-12-28 17:15:04 +01:00
Daniel Marjamäki
8e94e2261b
Comparing bool with int: Fixed false positives
2011-12-23 19:11:51 +01:00
PKEuS
8213a15b2a
improving checkSizeofForStrncmpSize
2011-12-23 18:11:34 +01:00
Daniel Marjamäki
e9d697b636
Fixed #3419 (false positive: (style) Same expression on both sides of '&'.)
2011-12-23 16:08:53 +01:00
PKEuS
409364747c
Fixed #3441 (segmentation fault of cppcheck (%: return ; ()))
2011-12-23 12:46:59 +01:00
Daniel Marjamäki
df8504f0ea
Clarify calculation: Fixed false positives when there are various function calls
2011-12-23 12:13:39 +01:00
Daniel Marjamäki
fd0d9c8694
CheckOther: Added line break to make the code more readable
2011-12-20 20:54:14 +01:00
Daniel Marjamäki
f8181df340
Fixed #3410 (Comparing bool against bool produces false positive)
2011-12-20 06:38:05 +01:00
PKEuS
6dc2a6e7ab
Refactorized CheckUnusedVar
2011-12-18 20:15:41 +01:00
PKEuS
0205582161
Fixed #3327 (printf with std::string as parameter)
2011-12-18 19:41:21 +01:00
PKEuS
f306246c7f
Improved support for references and pointers in SymbolDatabase
...
Replaced several isPointer functions by Variable::isPointer function
Refactorizations & Make use of symbolDatabase more often
2011-12-17 19:04:03 +01:00
PKEuS
4abee3a345
Refactorings. Use reportError instead of reportInconclusiveError.
2011-12-17 11:39:20 +01:00
PKEuS
a311904a0f
Patch that fixes some bailouts for isEnabled('style') in both directions. Improved checkSizeofForNumericParameter's error message, made it 'warning', made it non-experimental.
2011-12-16 19:21:14 +01:00
PKEuS
c9f5117cf5
Fixed #3407 (False positive: (inconclusive) Found duplicate branches for if and else. (inline assembler))
2011-12-13 21:42:38 +01:00
PKEuS
91a0a071d0
Take symbol database into use or improve its usage in some checks.
2011-12-09 23:28:10 +02:00
PKEuS
97eecb78a7
Fixed #3381 (false positive: (style) Statements following return, break, continue, goto or throw will never be executed)
2011-12-07 18:20:52 +01:00
PKEuS
501d7ccb2d
Optimize checkother.cpp by taking symbolDatabase into use.
2011-12-04 20:49:01 +02:00
PKEuS
1f438b0505
Fixed #3375 (Improve check: Detect unreachable code)
2011-12-03 11:43:23 +01:00
Daniel Marjamäki
69d3d4a17d
Fixed gcc compiler warnings
2011-12-03 09:57:56 +01:00
Daniel Marjamäki
9a84c5845a
Fixed #3373 (False posititive: incorrect %* handling in sscanf)
2011-12-02 17:09:32 +01:00
Richard Quirk
d2c8b9be56
Fix possible null pointer dereference
2011-12-01 19:57:04 +01:00
Richard Quirk
b2ea78543b
Fix false positive with non-const function calls
2011-12-01 19:57:04 +01:00
Richard Quirk
a880469c5a
Refactor the same expression check
...
Work out if a function is inconclusive when creating the entry in the
Expressions class instead of when checking the counts at the end. Store
the result in a new bool flag in the ExpressionTokens helper struct.
The pointer to symbol database and ref to list of const functions are
temporarily stored in the Expressions helper class to avoid passing
them in too on every endExpr(tok) call.
Use a const reference to ExpressionTokens in the check loop to avoid
repeating the it->second several times, which clarifies what that code
does.
2011-12-01 19:57:04 +01:00
PKEuS
5017646488
Coding fixes and refactorings
2011-12-01 19:43:51 +01:00
Daniel Marjamäki
93b21c6cc5
Fixed Visual Studio compiler warnings
2011-12-01 18:27:25 +01:00
Daniel Marjamäki
98480bf504
Fixed #3354 (Incorrect both sides of '||' expression match when using increment in expression.)
2011-12-01 17:46:33 +01:00
Daniel Marjamäki
fddfd16758
checkDuplicateExpressions: validate tokens instead of string. Fix for my previous commit.
2011-12-01 17:43:29 +01:00
Daniel Marjamäki
31b576de3b
Fixed #3334 (Test for same expression on both sides of '&' reports false positive)
2011-12-01 17:07:55 +01:00
Edoardo Prezioso
767413adad
1)internal check found a 'findmatch' with simple string argument;
...
2)Style: uniform 'while (...)' when inside it there's an assignment;
3)Replace '0' with 'NULL' where there's comparison with a pointer.
2011-12-01 12:04:47 +01:00
PKEuS
ee3e10ea97
Fixed #3364 (Crash in printf parsing)
2011-11-30 20:23:29 +01:00
Daniel Marjamäki
0d48cd390b
astyle formatting
2011-11-29 20:44:23 +01:00
Edoardo Prezioso
5c90c69ccf
Fixed ticket #3366 (Build breakage)
2011-11-29 19:46:36 +01:00
Daniel Marjamäki
b61c01c6a4
Fixed #3356 (false positive: (warning) Comparison of a boolean with integer that is neither 1 nor 0)
2011-11-29 18:14:57 +01:00
Daniel Marjamäki
b538f49a6e
Merge pull request #61 from richq/sameexpr
...
Fix for #3317 - same expression on both side of '&&' false positives
2011-11-29 08:50:02 -08:00
Daniel Marjamäki
522da8d258
sizeof for numeric constant : disabled check. see ticket #3179
2011-11-27 18:50:21 +01:00
PKEuS
71c8669261
Fixed #3311 , #3313 and #3339 (printf format string false positives)
2011-11-27 07:29:09 +01:00
PKEuS
6b1594244e
code cleanups and refactorings
2011-11-26 21:15:16 +01:00
Richard Quirk
d28cf42d4c
Fix ticket #3317 (same expression false positives)
...
Add a check for function calls that have no side effects. That means
known const methods and a list including strcmp, strlen, etc.
If the function is not known to be side effect-free then no style
warning is given.
Add test cases for the duplicate expressions.
2011-11-23 21:39:03 +01:00
Richard Quirk
511ac0ab1f
Remove false positives for nested logic
2011-11-23 21:39:03 +01:00
Daniel Marjamäki
2e08c8c5b1
DJGPP: Fixed a few compiler errors by using std::size_t instead of size_t
2011-11-22 21:14:14 +01:00
Daniel Marjamäki
5b5ea29f23
Mismatching format string parameters. Made check experimental. See tickets #3311 , #3313 and #3339
2011-11-21 07:31:06 +01:00
Richard Quirk
91713ffe84
Fix false positives for %[ in scanf
2011-11-20 16:48:54 +01:00
Edoardo Prezioso
a32b05197d
Change every 'tokAt(1)' to 'next()' and every 'tokAt(-1)' to 'previous()'.
...
Added a safety check to ensure that a 'previous()' call doesn't crash (not sure if it's needed or not).
2011-11-20 15:59:37 +01:00
Edoardo Prezioso
11dd3c09ce
Change every 'tokAt(1)->' to 'next()->' because 'tokAt(1) == 0' is equivalent to 'next() == 0', hence the equivalent cppcheck crash.
2011-11-20 15:09:57 +01:00
Edoardo Prezioso
42e369a4b4
Change every 'tokAt(..)->link()' to 'linkAt(..)'.
2011-11-20 14:24:27 +01:00
Marek Zmysłowski
994f08fdf0
Fixed #886 (new check: wrong value passed to isgraph function)
2011-11-17 16:31:16 +01:00
Edoardo Prezioso
2c64d299ca
Change every 'tokAt(...)->str()' to 'strAt(...)'.
2011-11-13 13:10:59 +01:00
Thomas Jarosch
c010ca33a5
Run astyle
2011-11-09 20:34:58 +01:00
Daniel Marjamäki
b7cc9779c4
Merge pull request #59 from richq/sameexpr
...
Improved same expression check for ticket #3274
2011-11-08 23:56:36 -08:00
Reijo Tomperi
7a294c1f79
Fix #3307 (Invalid format string/parameter mismatch warning)
...
http://sourceforge.net/apps/trac/cppcheck/ticket/3307
2011-11-09 00:16:37 +02:00
Richard Quirk
d1bc8819f9
Fix for same expression separated by commas
...
The code branch tested by the previous check for && is now different, so
I've changed the test to use == instead. There was also a missing case
when the expression was followed by a comma instead of being preceded by
one.
2011-11-08 21:56:54 +01:00
Richard Quirk
d5664dd6cf
Improved %or% and & checks
2011-11-08 21:56:54 +01:00
Richard Quirk
4cb97edbaf
Improved same expression check for ticket #3274
...
Expand the logic for the check for the same expression on both sides of
the || and && operators. Now expressions can be more complex, with the
"alt" variable helping to fudge operator precedence to avoid false
positives.
2011-11-08 21:54:42 +01:00
Daniel Marjamäki
fa076598ad
Fixed #3233 (false positive: (style) Checking if unsigned variable 'i' is less than zero.)
2011-11-06 18:24:37 +01:00
Edoardo Prezioso
6e2f2816de
Improve same expression check: remove '%op%' pattern and add ',' for the same expressions as an argument inside a function.
...
Improve compound assignment simplification: use already defined 'isAssignmentOp' and extend the adding parenthesis to a generic operator, not only to the arithmetical ones. See: http://en.cppreference.com/w/cpp/language/operator_precedence
2011-11-06 14:35:53 +01:00
Daniel Marjamäki
f092779a4d
Fixed #3282 (Invalid report that an array index is of type char.)
2011-11-06 11:26:28 +01:00
Daniel Marjamäki
e11c1f7975
Fixed #3265 (false positive: comparison of bool with nonzero integer)
2011-11-06 08:21:34 +01:00
Edoardo Prezioso
99463d3368
Improve same expression check: take count of operations and assignments before the same expression and add missing 'return' pattern to the struct member variable part of the check.
2011-11-05 22:25:01 +01:00
Daniel Marjamäki
d4a8184339
Fixed #3251 (Redundant code: Found a statement that begins with numeric constant)
2011-11-05 20:28:52 +01:00
Richard Quirk
a3f2c1e651
Improve for same expression on both sides of operator
2011-11-05 15:46:11 +01:00
PKEuS
0c469bae41
Fixed #3089 (New Check: Detect wrong usage of printf/scanf)
2011-11-05 07:29:53 +01:00
Edoardo Prezioso
4295439e53
Fixed ticket #3269 (Regression, I think it's somehow related to symbol database)
2011-10-31 15:05:52 +01:00
Edoardo Prezioso
ba5909ef1d
General code tweaking, nothing strange.
2011-10-31 02:24:59 +01:00
Edoardo Prezioso
4fc7e86d7d
Fixed: with checkConst and checkVariableScope wanted still required "information" settings instead of "style".
2011-10-30 10:58:15 +01:00
Daniel Marjamäki
3c509589b5
use reportInconclusiveError instead of reportError if checking is inconclusive
2011-10-29 15:16:27 +02:00
Daniel Marjamäki
f04210ad9f
updated comment. removed a inconclusive condition, I don't think it's needed.
2011-10-29 12:52:46 +02:00
Daniel Marjamäki
6c02de151f
strncmp sizeof: tweaked the check.
2011-10-29 12:27:19 +02:00
Daniel Marjamäki
8416768e03
Merge pull request #50 from richq/strncmp
...
Improved strncmp checks
* strings are always the same
* inconclusive: using sizeof(char *) as size parameter
2011-10-29 03:13:21 -07:00
Richard Quirk
45d0709ed5
Only run sizeof(char*) check if inconclusive is set
2011-10-29 11:59:24 +02:00
Richard Quirk
c2d7824130
Move string comparison out of the report function
2011-10-29 11:52:19 +02:00
Edoardo Prezioso
dd719b41bf
Definitely check correctly 'sizeof %num%' when '%num%' has '-' sign.
2011-10-29 00:11:38 +02:00
Richard Quirk
665cdfabdc
Warn when sizeof is used in strncmp ticket #2095
...
This checks for the case where the user thought sizeof(buf) gave the
size in bytes of 'buf' in code like the following:
const char *buf = "Hello World";
strncmp(buf, other, sizeof(buf));
2011-10-28 22:14:55 +02:00
Richard Quirk
90c7db15a0
Add check for comparison of identical string variables
2011-10-28 22:12:51 +02:00
Richard Quirk
4ba6ac7332
Add strncmp to the list of static string comparison functions
2011-10-28 22:12:51 +02:00
Thomas Jarosch
434fb933a8
Implement Token::findsimplematch und use it for simple patterns
2011-10-27 15:59:22 +02:00
Thomas Jarosch
54adb910ec
Use Token::simpleMatch instead of Token::Match for simple patterns
2011-10-27 15:59:22 +02:00
seb777
de71c41379
Fixed Ticket 2144 (false negatives: Old Style Pointer Cast apply only on .cpp files)
2011-10-26 21:17:27 +02:00
Reijo Tomperi
3568b5a841
Improved memset with 0 bytes check. TODO done (unit test).
...
Patch from: PKEuS <philipp.kloke@web.de>
2011-10-22 23:34:10 +03:00
Edoardo Prezioso
91c6608175
Improve fix of #934 (be careful of macros code).
2011-10-22 20:43:42 +02:00
PKEuS
20179673ce
Fixed #934 (new check: missuse of std::cout)
2011-10-22 17:12:52 +02:00
PKEuS
ccf087d2ea
checkMathFunctions: Refactoring the check
2011-10-22 12:31:47 +02:00
PKEuS
ea02bd905a
Fixed #3225 (Boolean comparison with string literals)
2011-10-18 21:37:03 +02:00
Thomas Jarosch
a52b73f9f9
Fix #3208 (Simplify pointer to standard type, C only)
...
The symbol database is unavailable during token simplification
and &data[0] might return something completely different for C++.
Moved code_is_c() from checkOther to Tokenizer.
2011-10-16 08:09:57 +02:00
Daniel Marjamäki
6f8e42a5af
changed the astyle formatting flags
2011-10-13 20:53:06 +02:00
Zachary Blair
82366918ff
Fixed #2627 (switch case fall through: redundant strcpy)
2011-10-13 01:27:22 -07:00
Robert Reif
af6a6f9c2d
run astyle
2011-10-12 09:08:54 -04:00
Thomas Jarosch
849bee8437
[PATCH] Detect suspicious use of semicolon after 'if/for/while'
...
statements if they are followed by a {..} block.
Examples are:
for (int i = 0; i < 10; ++i);
{
printf("i)";
}
or
if (i == 100);
{
die("Wrong argument");
}
This new check is active if you enable inconclusive checks.
2011-10-11 08:41:39 +02:00
Zachary Blair
fcf360825a
Fixed #2955 (New check: Using && instead of &)
2011-10-10 10:11:17 -07:00
PKEuS
5f9b916dcc
Fixed #2115 (new check: endless loop (unsigned comparison that is always true))
2011-10-09 20:35:46 +02:00
Daniel Marjamäki
73fb6725e6
Readded CheckOther::bitwiseOnBoolean as inconclusive check
2011-10-06 22:01:48 +02:00
Daniel Marjamäki
09109f19f8
Removed CheckOther::bitwiseOnBoolean check. The reasons can be seen in my comments in ticket #3062 .
2011-10-05 20:46:07 +02:00
PKEuS
494d3af3d1
Fixed #1877 (Be more strict about int vs. bool, part II)
2011-10-05 20:30:36 +02:00
Kimmo Varis
3cfe7ca1a7
Move "information" errors to "style" errors.
...
"information" severity is documented in lib/errorlogger.h as:
Checking information.
Information message about the checking (process) itself. These
messages inform about header files not found etc issues that are
not errors in the code but something user needs to know.
It IS NOT for errors in the code. All the current "information"-
severity errors fit nicely into description of the "style"-
severity.
We definitely need to separate processing information and actual
errors in the code. It is highly confusing for users to mix these
two different things. Hence all current "information" code error
messages are moved to "style" category.
Ticket: #3165 (Stop misusing the 'information' error severity!)
2011-10-05 20:44:00 +03:00
Robert Reif
2d717d77cd
reduce false negatives for checking for CheckOther::checkSignOfUnsignedVariable()
2011-09-26 21:24:34 -04:00
Robert Reif
735ff11469
fix #3110 (false positve: style) Boolean result is used in bitwise operation. Clarify expression with parentheses)
2011-09-12 07:32:55 -04:00
Daniel Marjamäki
55230baf78
Fixed #3086 (false positive: Boolean result is used in bitwise operation.)
2011-09-11 09:46:01 +02:00
Philipp Kloke
2f62d180fe
Fixed #1740 (Undefined Behavior: Divide by zero)
2011-09-10 16:12:53 +02:00
seb777
074ad10a30
fix #195 Unusual shift operation - check this kind of code
...
return x >> ! y ? 8 : 2;
2011-09-06 22:37:19 +02:00
Robert Reif
b27bbea44a
really fix #3079 (Spelling error in unsigned variable check 'never alwayw')
2011-09-05 09:48:59 -04:00
Robert Reif
2250a2dfc3
fix #3079 (Spelling error in unsigned variable check 'never alwayw')
2011-09-05 09:04:27 -04:00
seb777
5c7ed46e0c
Following the discussion XX, replace the keyword C99 '_Bool' with the 'bool' keyword in the process of tokenization\nSee f29b7f9f08
2011-09-03 23:15:33 +02:00
Daniel Marjamäki
d23c58d387
enable: break out 'performance' and 'portability' from the 'style' id. Ticket: #3074
2011-09-03 15:30:30 +02:00
Robert Reif
f29b7f9f08
fix #3062 (false negative: Boolean variable is used in bitwise operation)
2011-09-02 17:19:06 -04:00
Robert Reif
2dd93dff75
move unused variable checks from checkother to checkunusedvar
2011-08-19 14:35:25 -04:00
Robert Reif
9fbef3ca7b
fix #3011 (new check: when first comparison is true, the 2nd comparison is always true)
2011-08-19 13:28:37 -04:00
Daniel Marjamäki
a735790e77
using boolean result in bitwise operation. fix false positive for '.. != (char *) &x'
2011-08-19 18:55:20 +02:00
Daniel Marjamäki
2dd1e290eb
fixed false positives for the 'bitwise operator / comparison operator' check
2011-08-19 18:06:28 +02:00
Robert Reif
eda9ff6fc5
refactor checkother to move error messages to follow check and rename some error functions to end in Error
2011-08-19 11:53:43 -04:00
Daniel Marjamäki
314d5f1e79
fixed false positive for 'using bitwise operation on boolean result'
2011-08-19 17:07:26 +02:00
Daniel Marjamäki
c107fdd2d4
Fixed #3018 (false positive: (style) Suspicious condition (assignment+comparison), it can be clarified with parentheses)
2011-08-19 13:54:06 +02:00
Daniel Marjamäki
40b493e621
Improve check: Clarify condition (using boolean result in bitwise operation)
2011-08-19 13:40:54 +02:00
Daniel Marjamäki
0d7c80ef21
improved comment of previous commit
2011-08-19 07:28:15 +02:00
Daniel Marjamäki
4606251ce8
Fixed #3001 (False Positive: Redundant assignment to itself)
2011-08-19 07:23:11 +02:00
Daniel Marjamäki
e5ff920ea9
Suspicious condition: Better handling when rhs is non-numeric
2011-08-19 00:56:15 +02:00
Daniel Marjamäki
a7728fef48
New check: warn about such suspicious conditions: '(a & b == c)'
2011-08-19 00:15:20 +02:00
Daniel Marjamäki
4f962acf16
Fixed #3009 (Using numeric constants in kernel space code)
2011-08-16 20:16:33 +02:00
Robert Reif
ad45ba718c
convert CheckOther::checkCharVariable() to use symbol database
2011-08-14 10:39:45 -04:00
Robert Reif
cd2c0fd9c8
convert CheckOther::checkSizeofForNumericParameter() to use the symbol database
2011-08-14 10:21:07 -04:00
Robert Reif
741eabba16
convert CheckOther::checkIncrementBoolean() to use the symbol database
2011-08-14 10:16:39 -04:00
Daniel Marjamäki
003956e42e
Fixed #2982 (false positive: using char type as array index (using string as key))
2011-08-09 17:03:22 +02:00
Daniel Marjamäki
8a6a999f09
Fixed #2979 (Improve message: using char as array index)
2011-08-08 19:35:11 +02:00
Kimmo Varis
cfcfa3f000
Use "enabled" list for the style checking.
...
Settings-class currently enables style checking via dedicated
boolean attribute. All other CLI's enable-options are handled
through the enable-list. This commit moves style-check enabling
to use the enable-list.
Main advantage is the consistency how options are handled/stored
in the Settings class. Which also unifies using them for the other
code. You need to enable certain type of checks? Use the
addEnabled()-method. You want to check if certain type of checks
are enabled? Use the isEnabled()-method.
2011-08-07 10:28:52 +03:00
Robert Reif
85b2bd21dc
fix #2968 (new check: testing if unsigned variable is less than 0)
2011-08-06 19:23:09 -04:00
Moritz Lipp
8d68981119
Fixed #2793 (SIGABRT on filenames without file extension)
2011-07-31 18:35:28 +02:00
Robert Reif
2f4aee2923
fix missing else in patch that added support for unused const local variables
2011-07-30 07:16:59 -04:00
Robert Reif
cb4282d69a
use simpleMatch where possible in checkother.cpp
2011-07-29 22:37:05 -04:00
Daniel Marjamäki
dc629b4c39
Fixed 'possible null pointer dereference' warning messages
2011-07-28 08:12:21 +02:00
Daniel Marjamäki
d2c0e5e7e6
Fixed #2821 (New Check : bool pointer null truth assignment)
2011-07-28 07:28:24 +02:00
Robert Reif
9a4447c835
add support for unused const local variables
2011-07-24 12:09:59 -04:00
Simon Martin
539c2e5acb
Fixed #2932 (segmentation fault of cppcheck ( i / i ))
2011-07-24 09:06:38 +02:00
Robert Reif
c3c3eb74e8
fix #2929 (Additional Unused variable check)
2011-07-21 18:37:37 -04:00
Robert Reif
ed30edf9d3
simplify CheckOther::checkIncorrectLogicOperator() by using more pattern matching
2011-07-18 07:34:49 -04:00
Robert Reif
76d0872c0d
made #2827 fix more generic by adding more ops and using pattern matching rather than string matching
2011-07-17 16:28:00 -04:00
Robert Reif
4149617978
fix #2827 to use numeric comparisons
2011-07-16 23:05:35 -04:00
Robert Reif
430d22032d
fix #2827 condition always false or true)
2011-07-16 22:06:23 -04:00
Zachary Blair
997a3652d2
Fixed #2822 (New check: Duplicate break statements in switch)
2011-07-14 17:12:56 -07:00
Robert Reif
270b2b1772
fix #2904 (Memory leak not detected when creating a new class instance)
2011-07-14 19:15:59 -04:00
Daniel Marjamäki
0007351ef4
spell check of error message. contant => constant
2011-07-05 19:59:58 +02:00
Daniel Marjamäki
8cd2c3115e
Fixed #2866 (Detect sign extension bugs)
2011-07-05 18:41:27 +02:00
Greg Hewgill
657b003dc8
Fix spelling error in warning identifier
2011-07-05 19:54:23 +12:00
Robert Reif
b32b2c6d87
add support for checking unused std::string local variables
2011-07-02 19:25:10 -04:00
Robert Reif
301e59cea0
fix false positive for unused local class/struct variable
2011-07-01 08:45:29 -04:00
Robert Reif
18e6509c5d
add support in CheckOther::functionVariableUsage() for checking structures that are declared with struct keyword
2011-07-01 07:42:20 -04:00
Robert Reif
3225c9dd9b
cleanup isStatic in CheckOther::functionVariableUsage()
2011-07-01 07:15:59 -04:00
Robert Reif
7826b5e22d
add support for detecting unused function variables of type class or struct
2011-06-30 21:58:11 -04:00
Daniel Marjamäki
97d47fa20e
Fixed #2805 (false positive: [NotAssigned1.cpp:5]: (style) Variable 'y' is not assigned a value)
2011-06-08 19:54:01 +02:00
seb777
e06b2419a4
fix #2786 (new check: Using sizeof with numeric constant)
...
Add unit test and improve check with negative constant because in cppcheck %num%
means 'integer'
2011-05-28 16:40:01 +08:00
seb777
287840e6bc
fix #2786
2011-05-25 01:45:58 +08:00
Daniel Marjamäki
144d811e54
Fixed #2780 (false positive: variable p is not assigned a value 'int p[2]; *p = 0;')
2011-05-11 18:58:25 +02:00
Robert Reif
2db67863a7
#2700 (common logic or cut and paste errors) make duplicate branches inclnclusive
2011-05-08 13:22:42 -04:00
Daniel Marjamäki
3629f953f0
Fixed #2770 (False positives (scope can be reduced / variable is assigned value that is never used))
2011-05-06 21:16:01 +02:00
Zachary Blair
46645ab327
Fixed #2722 (new check: statement that is always true (strcmp))
2011-04-25 22:45:27 -07:00
Daniel Marjamäki
46afc54c10
astyle formatting
2011-04-20 06:41:26 +02:00
Daniel Marjamäki
8417c4eb28
const parameter: Added comment to reduce false negatives for various classes in the std namespace
2011-04-20 05:40:06 +02:00
Daniel Marjamäki
68e7003bb1
Fixed #2734 (False positive: reports 'should be passed by reference' for std::streamoff)
2011-04-19 20:07:54 +02:00
Robert Reif
c238b1bba6
fix #2730 (The same expression on both sides of != is OK when checking for NaN)
2011-04-18 19:20:27 -04:00
Robert Reif
56212370d1
add check for same expression on both sides of an operator (part of #2700 )
2011-04-10 10:25:02 -04:00
Robert Reif
434783530a
Merge branch 'master' of github.com:danmar/cppcheck
2011-04-10 09:57:34 -04:00
Robert Reif
4a50aca7b2
fix a bug in checkDuplicateBranch where removed type info like signed/unsigned was not checked for difference
2011-04-10 09:57:09 -04:00
Daniel Marjamäki
e5d43d4ed2
Renamed Settings::stupid to Settings::experimental
2011-04-10 15:55:08 +02:00
Daniel Marjamäki
30ee9ba6e4
Added Settings::stupid flag that can be used to hide checking that generates false positives.
2011-04-10 13:23:45 +02:00
Daniel Marjamäki
f284c3a11f
CheckOther: Code cleanup. Use %oror%
2011-04-10 11:52:12 +02:00
Daniel Marjamäki
ec5ddb16b4
CheckOther: Use %op% in CheckUnsignedDivision
2011-04-10 11:31:04 +02:00
Robert Reif
66de41b313
partial fix for #2700 (common logic or cut and paste errors)
2011-04-09 17:05:27 -04:00
Robert Reif
d22fcb8184
fix bug in previous commit: fix #311 (add detection of duplicated if else-cases)
2011-04-09 16:34:16 -04:00
Robert Reif
7e403ae210
fix #311 (add detection of duplicated if else-cases)
2011-04-09 15:14:01 -04:00
Daniel Marjamäki
7d93bfb42e
Refactoring: Use Token::isArithmeticalOp instead of hardcoded conditions
2011-04-09 18:50:05 +02:00
Daniel Marjamäki
8e711b7925
Refactoring: there was almost duplicate functions 'isOp'. Created a new Token::isOp function instead.
2011-04-08 19:40:22 +02:00
Daniel Marjamäki
4ac3c7fe3b
clarify calculation: fixed false negative for 'int x = a - b ? 2 : 3'
2011-04-04 21:33:16 +02:00
Daniel Marjamäki
63acd9bb3e
Clarify calculation: Added warnings for << and >>
2011-04-03 22:12:22 +02:00
Daniel Marjamäki
29422b8552
clarify precedence: made the short message shorter
2011-04-02 17:27:36 +02:00
Daniel Marjamäki
855b01cd5a
Clarify precedence 'a*b?c:d' : warn for addition, subtraction and division also. tried to clarify the message more
2011-04-02 11:43:20 +02:00
Daniel Marjamäki
b8cda19ca6
Fixed #2655 (false positive: (warning) Redundant code: Found a statement that begins with numeric constant)
2011-03-30 21:57:01 +02:00
Stefan Weil
0e4cf7a2d6
Spell checks
2011-03-30 16:44:16 +02:00
Daniel Marjamäki
27506b4231
Fixed #2661 (False positive: object destroyed immediately)
2011-03-20 09:55:26 +01:00
Daniel Marjamäki
3e1df1b463
Clarify condition: re-enabled check
2011-03-13 12:16:55 +01:00
Daniel Marjamäki
ed11a9e3cb
Fixed #2639 (False positive: confusion between struct and function)
2011-03-13 08:38:40 +01:00
Daniel Marjamäki
29ab409af5
Merge branch '2390b' of https://github.com/elfring/cppcheck into elfring-2390b
2011-03-12 11:58:24 +01:00
Greg Hewgill
2716b856f4
throwing an exception is a valid immediate exit from switch
2011-03-12 07:27:31 +13:00
Robert Reif
79f0fe7d1c
refactor symbol database and checks to use list of Scope rather than list of Scope pointers
2011-03-10 19:43:29 -05:00
Daniel Marjamäki
db48158b28
Suspicious condition: Added new check for conditions that contains assignment+comparison
2011-03-09 22:20:14 +01:00
Daniel Marjamäki
06abaf95a5
Incorrect string compare: reduce noise when using strncmp on string literal
2011-03-07 21:37:13 +01:00
Greg Hewgill
b9df7735c5
switchCaseFallThrough is now an inconclusive check
2011-03-06 13:06:30 +13:00
Greg Hewgill
8c245cfd2f
switchCaseFallThrough is now a coding style check (ticket #2623 )
2011-03-06 09:43:27 +13:00
Greg Hewgill
70fcbe94f4
avoid warning on first case (in case there are declarations before first case)
2011-03-05 00:45:58 +13:00
Greg Hewgill
8c1d7ef316
avoid crash when else condition doesn't have braces to link
2011-03-05 00:45:58 +13:00
Greg Hewgill
ad45737805
more gracefully handle unexpected blocks inside switch
2011-03-05 00:45:57 +13:00
Greg Hewgill
a532a9690e
full implementation of switch case fall through
2011-03-05 00:45:57 +13:00
Greg Hewgill
93ea774484
initial simplistic implementation of switchCaseFallThrough
2011-03-05 00:45:57 +13:00
Zachary Blair
e1b2569b81
Fixed #432 (New check: wrong usage of ! operator in conditions)
2011-02-27 12:30:22 -08:00
Daniel Marjamäki
85b1ea21cf
Fixed #2590 (segmentation fault of cppcheck ( {}int ))
2011-02-19 09:56:17 +01:00
Daniel Marjamäki
dfba4b7332
Fixed #2585 (segmentation fault of cppcheck (CheckOther::clarifyCalculation))
2011-02-17 21:30:59 +01:00
Daniel Marjamäki
2657d36d03
Fixed #2502 (False positive: redundant assingment of object to itself)
2011-02-12 14:27:07 +01:00
Sébastien Debrard
f5ed52b84b
fix #2569 check postfix increment on boolean
2011-02-11 23:38:23 +01:00
Daniel Marjamäki
5175e4ff3f
Fixed #2535 (false positive: (style) Variable 'A' is not assigned a value)
2011-02-09 19:20:44 +01:00
Erik Lax
aeae5a867d
Fixed #2550 (Bad substr/strncmp comparison)
2011-02-08 19:49:29 +01:00
Daniel Marjamäki
5640845a17
Fixed #2498 (False positive: redundant assignment)
2011-02-04 21:08:42 +01:00
Kimmo Varis
7d73b523be
Clarify few verbose messages.
...
Dan pointed out to me earlier that he wants both short- and
verbose messages to be independently understandable. So modifying
some verbose messages to be easier to understand without the short
message.
2011-02-04 11:10:24 +02:00
Raphael Geissert
f8e2d50e6f
Use Token::simpleMatch where no special patterns are needed
2011-02-02 13:27:02 -06:00
Raphael Geissert
8d5863133c
Use Token::simpleMatch where no patterns are used
2011-02-02 13:27:01 -06:00
Raphael Geissert
cf2b6f7bc1
Remove useless spacing at the end of *Match strings
2011-02-02 13:27:01 -06:00
Raphael Geissert
d592250284
Fix sizeof sizeof check to handle sizeof(sizeof type)
2011-02-02 11:49:32 -06:00
Daniel Marjamäki
defeded4b5
Fixed #2529 (False positive: array 'req[3]' index 4 out of bounds)
2011-02-01 21:46:07 +01:00
Sébastien Debrard
078c36921d
runastyle
2011-01-26 20:10:56 +01:00
Sébastien Debrard
3e7f29d6f9
fix #2510 Improve check 'sizeof for array given as function argument'
2011-01-26 20:08:06 +01:00
Sébastien Debrard
5d661d25a8
typo: message
2011-01-26 09:35:11 +01:00
Sébastien Debrard
e82c190429
Merge branch 'master' of https://github.com/danmar/cppcheck
...
Conflicts:
test/testother.cpp
2011-01-25 10:05:03 +01:00
Sébastien Debrard
4cf56dac2b
Fix 2495 incorrect sizeof error message
2011-01-25 09:57:58 +01:00
Daniel Marjamäki
a596a7a8fe
Fixed #2494 (New check: clarify calculation when using ?: operator)
2011-01-24 21:40:49 +01:00
Sébastien Debrard
c7b8bd543f
fix ticket 155 - char array
2011-01-24 19:04:56 +01:00
Debrard Sébastien
27dce075e0
Fixed #155 (check size of a variable whose type is a sized array)
2011-01-22 19:21:56 +01:00
Robert Reif
d73709a620
Symbol database: rename variables. ticket: #2468
2011-01-21 07:42:41 +01:00
Daniel Marjamäki
ecac93ebed
Fixed #2462 (false positive: (warning) Redundant code: Found a statement that begins with numeric constant)
2011-01-19 18:37:33 +01:00
Daniel Marjamäki
965c1a94fd
Fixed #2475 (False positive in structure initialisation: The scope of the variable bits can be reduced)
2011-01-17 20:51:15 +01:00
Robert Reif
959e10cee5
Symbol database: renamed classes. ticket: #2468
2011-01-17 18:29:19 +01:00
Robert Reif
bf9528558e
Symbol database: pulled out classes into global scope. ticket: #2468
2011-01-17 07:21:59 +01:00
Zachary Blair
481907ef14
Fixed #2457 (CheckOther::checkIncorrectLogicOperator: hang if variable id is 0)
2011-01-16 13:57:29 -08:00
Daniel Marjamäki
93d1313186
Refactoring: Check if type is class/struct through symbol database
2011-01-16 19:57:29 +01:00
Daniel Marjamäki
e6a1efa13b
Fixed #2302 (Duplicate id 'unusedVariable')
2011-01-16 18:45:05 +01:00
Robert Reif
d341b42b0c
Symbol database: increased constness. ticket: #2468
2011-01-16 18:13:54 +01:00
Daniel Marjamäki
bb2862bc97
fixed unit test
2011-01-15 21:04:20 +01:00
Daniel Marjamäki
94ebb24d3d
Optimising: about 5% improvement with Visual Studio executable
2011-01-15 20:55:51 +01:00
Daniel Marjamäki
36c1807228
Fixed #2458 (false positive: (warning) Redundant code: Found a statement that begins with numeric constant)
2011-01-13 20:12:57 +01:00
Reijo Tomperi
226b605774
Change year 2010 -> 2011 in license texts.
2011-01-09 21:33:36 +02:00
Daniel Marjamäki
d758929490
Fixed #2433 (strtol: false positive when strtol isn't used in function call)
2011-01-08 09:23:51 +01:00
Daniel Marjamäki
37b1f7c296
memsetZeroBytes: improved error message. ticket: #2421
2011-01-06 16:27:22 +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
033e759c39
command line: added 'information' id to enable
2011-01-05 21:20:21 +01:00
Markus Elfring
3fc0317997
Bug #2390 : Enclose the output of a variable name with quotes in "CheckOther::variableScopeError"
...
The variable name output was enclosed by quotation marks in the member
function "CheckOther::variableScopeError" and corresponding test functions.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
2011-01-03 05:15:20 +01:00
Zachary Blair
68700b3561
Fixed #2382 (Catching exceptions by value instead of reference)
2010-12-31 12:48:24 -08:00
Zachary Blair
d11b5163b7
Fixed #2382 (Catching exceptions by value instead of reference)
2010-12-31 03:01:38 -08:00
Daniel Marjamäki
fd27be2440
Fixed #2372 (internal error in logicaloperator check (varid=0))
2010-12-29 10:07:28 +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
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
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
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
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
02892499d2
Fixed #2286 (Variable 'ownKilled' is assigned a value that is never used)
2010-12-19 18:27:31 +01:00
Robert Reif
a2aa601899
CheckOther: Use SymbolDatabase. Ticket: #2318
2010-12-18 20:35:40 +01:00
Robert Reif
f2d69acbfd
Symbol database: reuse in CheckOther. Ticket: #2318
2010-12-16 19:04:47 +01:00
vBm
46a11183a5
Fixed some spelling mistakes
2010-12-15 18:45:53 +01:00
Daniel Marjamäki
b25e6ff24c
Fixed #2279 ((style) struct of union member is never used)
2010-12-05 18:33:53 +01:00
Daniel Marjamäki
93ebdca313
Fixed #2264 (False positive: variable assigned value that is never used)
2010-12-03 18:45:49 +01:00
Daniel Marjamäki
8118e4755a
Fixed #2263 (False positive: variable assigned value that is never used)
2010-12-02 20:08:05 +01:00
Kimmo Varis
8d8945ac57
Improve "Assert statement 'varname' -message.
...
Modifying the message so that we have short message and verbose
message. As discussed in dev-forum:
https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192
2010-11-29 20:12:21 +02:00
Kimmo Varis
564d896715
Run astyle.
2010-11-28 23:29:06 +02:00
Kimmo Varis
85735e382f
Improve the 'suspicious code sizeof sizeof' -message.
...
As discussed at dev-forum:
https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192
2010-11-28 14:20:46 +02:00
Kimmo Varis
2c3f9a9dce
Small fix to error message.
...
Start with capital letter and no space in beginning.
2010-11-27 20:41:08 +02:00
Kimmo Varis
837605b05b
Ticket #2239 (Too long "short" message about function parameter passing)
...
Have a proper short message for the parameter passing warning and
improve the message.
2010-11-27 10:46:34 +02:00
Zachary Blair
215cb5ac8d
Fixed #2162 (false positive: Mutual exclusion over ||)
2010-11-21 00:06:43 -08:00
Daniel Marjamäki
d021cd9074
VS: fixed compiler warning. Ticket: #2200
2010-11-20 11:28:47 +01:00
Daniel Marjamäki
fd64a7e683
Mutual exclusion: Disable this check until #2162 is fixed.
2010-11-20 07:43:07 +01:00
Daniel Marjamäki
d250cb5aa2
Fixed #2206 (False positive: variable is assigned a value that is never used (array initializers))
2010-11-15 17:53:55 +01:00
Daniel Marjamäki
7b3e7f6467
Fixed #2205 (False positive: variable is assigned a value that is never used (assigning to dereferenced casted pointers))
2010-11-15 17:30:07 +01:00
Zachary Blair
36d80d6eaa
Fixed #2058 (Warn for unused variable when only doing malloc/free)
2010-11-14 17:37:36 -08:00
Daniel Marjamäki
ba7a3b376e
Fixed #2167 (Drop linefeeds from error messages)
2010-11-11 19:54:43 +01:00
Daniel Marjamäki
27b7638901
Visual Studio: Fixed compiler warnings about assignment in condition
2010-11-08 17:29:08 +01:00
Daniel Marjamäki
06ec4d9a84
GCC: Fixed compiler warnings about sign-conversion
2010-11-04 20:52:20 +01:00
Zachary Blair
10a4dde105
Fixed #2137 (Invalid mutual exclusion report)
2010-11-04 00:10:25 -07:00
Daniel Marjamäki
14803643ca
empty string test: Removed this check
2010-11-03 17:56:14 +01:00
Daniel Marjamäki
19f809c9b4
Unused variables: better handling of '= %var% ++'. Ticket: #2160
2010-11-02 20:01:12 +01:00
Daniel Marjamäki
1e866c3235
Visual Studio: Fixed compiler error
2010-10-31 11:42:45 +01:00
Daniel Marjamäki
bc283d8b99
Uninitialized variables: Broke out the checking into separate file
2010-10-31 12:31:11 +01:00
Daniel Marjamäki
df8a93bf97
Null pointers: Broke out the checking into separate file
2010-10-31 11:51:25 +01:00
Daniel Marjamäki
558899dc74
Variable usage: Fixed false negative that I introduced when simplifying compound assignments
2010-10-31 09:34:25 +01:00
Daniel Marjamäki
9435fde551
Tokenizer: Added function for checking if code is Java/C#
2010-10-28 18:51:55 +02:00
Daniel Marjamäki
995e39200b
Fixed #2130 (Invalid possible NULL pointer dereference, etc.)
2010-10-27 20:20:10 +02:00
Daniel Marjamäki
fc98bcdcb2
Fixed #2141 (false positive: possible null pointer dereference)
2010-10-27 19:42:47 +02:00
Daniel Marjamäki
fd153eac02
Fixed #2142 (false positive: null pointer dereference (throw))
2010-10-27 19:38:42 +02:00
Daniel Marjamäki
9370f552ac
Fixed #2134 (sizeof(*list) complains of null pointer dereference)
2010-10-26 18:26:02 +02:00
Daniel Marjamäki
893f7fa347
Fixed #2130 (Invalid possible NULL pointer dereference, etc.)
2010-10-26 17:40:30 +02:00
Daniel Marjamäki
bdd6d6d53d
null pointer: use simplified token list in the 'check and deref' checking
2010-10-25 21:05:43 +02:00
Daniel Marjamäki
132aa8d0c4
uninitialized variables: fixed fp when analysing loops
2010-10-25 20:56:15 +02:00
Daniel Marjamäki
026514db1a
Fixed #2127 (null pointer dereference after condition (SRD nr 522))
2010-10-25 19:43:54 +02:00
Zachary Blair
26afb04dc5
Fixed #2105 (Incorrect operator: mutual exclusion over ||)
2010-10-24 18:14:21 -07:00
Daniel Marjamäki
8f707e5e46
Null pointers: Better handling of loops
2010-10-24 18:51:14 +02:00
Daniel Marjamäki
40aeb17738
uninitialized variables: handling loop bodies. end upon '}'
2010-10-24 18:28:25 +02:00
Daniel Marjamäki
6601de7681
uninitialized variables: refactoring handling of loop bodies
2010-10-24 18:26:59 +02:00
Daniel Marjamäki
b66d3c8858
Fixed #2125 (uninitialized variable: better handling of for loops)
2010-10-24 18:12:48 +02:00
Daniel Marjamäki
13b8544436
Visual Studio: Fixed compiler warning. Ticket: #2123
2010-10-24 11:52:28 +02:00
Daniel Marjamäki
f8c02718a5
Activated checking of .java and .cs files
2010-10-19 21:54:15 +02:00
Daniel Marjamäki
92a1e9e76e
Severities: Added 'warning' and 'performance' severities. No changes to the command line options nor to the XML format. Ticket: #2106
2010-10-17 14:41:00 +02:00
Debrard Sebastien
fb928b6778
Fixed #2018 (Postfix Operators)
2010-10-14 19:17:40 +02:00
Pete Johns
afe52fa9f2
Fixed MSVC++ compiler warning (pointers are not bools)
2010-10-13 21:19:18 +11:00
Pete Johns
52e16454fa
Removed redundant code.
...
localClassDefinition is no longer required due to improved isIdentifierObjectType() in commit fbd3d92
.
2010-10-13 20:48:37 +11:00
Pete Johns
fbd3d92aa9
Fixed #2084 (False positive: object destroyed immediately (struct and function with same name))
...
Tightened up class definition matching so as not to match C-style struct tags.
2010-10-13 20:37:53 +11:00
Debrard Sebastien
1a4e3dcc44
increment check
2010-10-12 19:54:39 +02:00
Daniel Marjamäki
3dfcbfc0e0
assignment in assert: modified the error message to better explain the reason why the warning is given.
2010-10-11 17:59:08 +02:00
Zachary Blair
d9967d4fd2
Fixed #2079 (detect side effects in assert)
2010-10-10 13:05:06 -07:00
Daniel Marjamäki
5cc7c9dcf7
Parameter passed by value: updated error message so it mentions the reason.
2010-10-10 14:12:11 +02:00
Daniel Marjamäki
a3367874d9
Fixed #1778 (false negative: nullpointer dereference (std::string pointer))
2010-10-09 07:57:34 +02:00
Pete Johns
4bf9ff26ea
Fixed 2071 (false positive: object destroyed immediately (when using '= { ... }'))
...
Simplified check within CheckOther::checkMisusedScopedObject() as a result.
2010-10-04 08:16:11 +11:00
Daniel Marjamäki
cd8ef1cded
Revert "temporarily disable the 'object destroyed immediately' message"
...
This reverts commit fa94312c9a
.
2010-10-03 18:05:08 +02:00
Daniel Marjamäki
fa94312c9a
temporarily disable the 'object destroyed immediately' message
2010-10-03 16:59:13 +02:00
Pete Johns
78795dc3ac
Fix false positive: Misused Scope Object does not pick constructors of local class declarations.
...
It does pick up if there is an unused construction within the function, though.
2010-10-02 22:59:04 +10:00
Pete Johns
365b1bed1a
Fixed false positive: checkMisusedScopedObject no longer errors on calls to function objects.
2010-10-02 21:25:16 +10:00
Pete Johns
b72b699b76
Fixed false-positive: Object is referenced on construction
...
struct Foo {
void bar() {
}
};
void fn() {
Foo().bar(); // This caused a false-positive
}
2010-10-02 20:26:29 +10:00
Pete Johns
3f72d3a877
Check misused scope object does not pick local class method.
...
Also fixed mistyped withinFuntion ->withinFunction.
2010-10-02 20:12:52 +10:00
Pete Johns
0017655f55
Added test for functor false-positive [passing]
...
Also removed typedef's following danmar's review and renamed isClassresults -> isClassResults to make more clear.
2010-10-02 18:45:24 +10:00
Pete Johns
6e0ef3eda2
Fixed #1132 (Detection of misused scope objects in functions)
...
Emits error in the form:
[useless_lock.cpp:18]: (error) instance of "Lock" object destroyed immediately
...if an instance of a class or struct is unnamed and therefore destroyed
straight after creation.
Only checks for misused scope objects within functions.
Optimised isIdentifierObjectType() by memoizing.
2010-10-02 14:22:26 +10:00
Pete Johns
50c2fa9ab0
Revert "Fixed #1132 (Detection of misused scope objects)"
...
This reverts commit c6acdccfa0
.
2010-10-01 20:52:16 +10:00
Pete Johns
c6acdccfa0
Fixed #1132 (Detection of misused scope objects)
...
Emits error in the form:
[useless_lock.cpp:18]: (error) instance of "Lock" object destroyed immediately
...if an instance of a class or struct is unnamed and therefore destroyed
straight after creation.
Removed "internal error" from token.cpp, since in this case varid would be NULL.
2010-10-01 20:30:21 +10:00
Daniel Marjamäki
415cbc63c3
Fixed #2066 (false positive: uninitialized variable when initializing through function pointer)
2010-09-27 19:26:09 +02:00
Daniel Marjamäki
4c98a7e67b
Optimisation: Removed unused and slow code. The code was added to fix #1225 but it is now redundant.
2010-09-24 20:56:21 +02:00
Daniel Marjamäki
8950beac37
Optimisation to make the CheckUninitVar::parse slightly faster
2010-09-23 21:40:08 +02:00
Daniel Marjamäki
f843678a07
Redundant conditions: some refactorings
...
* removed the 'redundant null pointer' check. sometimes it's unsafe to delete NULL pointer. and this check doesn't point out errors anyway.
* moved the 'redundant condition' check for set::remove. Moved it to CheckStl.
2010-09-16 18:49:23 +02:00
Daniel Marjamäki
cfbc06c8b6
removed 'empty catch block' check. to avoid false positives we'll need to check if it is bad with an empty catch block (dead pointer/undefined behaviour/etc)
2010-09-05 13:27:58 +02:00
Daniel Marjamäki
a2b4e5641f
Fixed #2010 (missing continue in switch check ?)
2010-09-04 14:24:45 +02:00
Daniel Marjamäki
9415423352
Fixed #2017 (false positive::struct or union member 'Base::m_ui' is never used)
2010-09-04 11:21:34 +02:00
Daniel Marjamäki
190a0040b7
Null pointer: Fixed false positive
2010-09-02 21:08:58 +02:00
Daniel Marjamäki
8ff1e71b22
Fixed #2004 (False positive in 'variable assigned a value but is never used' check)
2010-08-31 20:58:37 +02:00
Daniel Marjamäki
1d78b5072d
Fixed #1996 (False positive for 'Variable foo is assigned a value that is never used')
2010-08-31 20:33:28 +02:00
Daniel Marjamäki
df87ce9e04
Fixed #1945 (False positives when a for loop header is in a macro)
2010-08-26 21:57:48 +02:00
Daniel Marjamäki
72916caee6
Reverted 7398453cb0
2010-08-15 21:25:14 +02:00
Sbastien Debrard
7398453cb0
Refactoring of obsolete functions checks. Ticket: #1940
2010-08-15 21:22:33 +02:00
Zachary Blair
c8087d3389
Fixed #162 (Initialisation of a variable by itself)
2010-08-14 21:34:04 -07:00
Daniel Marjamäki
2e249670b3
dangerous scanf usage: Added verbose information
2010-08-14 18:35:48 +02:00
Daniel Marjamäki
5846630fa9
Added scanf check. Modified patch submitted by Eric Sesterhenn
2010-08-14 15:15:12 +02:00
Daniel Marjamäki
764ce99c6f
Performance: Refactoring CheckOther::nullPointerStructByDeRefAndChec to make it faster
2010-08-07 21:00:17 +02:00
Daniel Marjamäki
029613d4c4
Fixed #1923 (False positive: Possible null pointer derefence in else if)
2010-08-07 19:59:56 +02:00
Daniel Marjamäki
ed4f1164a1
Fixed #1894 (unreadVariable false positive with const references)
2010-08-07 15:53:51 +02:00
Daniel Marjamäki
c395e51389
New check: look for calculation inside sizeof
2010-08-06 22:57:10 +02:00
Daniel Marjamäki
12217461a2
gcc: fixed some more -Wsign-conversion warnings
2010-08-06 22:37:48 +02:00
Daniel Marjamäki
faa713e7b5
gcc: Fixed some compiler warnings when using -Wsign-conversion. Ticket: #1487
2010-08-06 19:40:54 +02:00
Daniel Marjamäki
65f7bcbfa5
null pointers: fixed TODO assertion - dereference pointer in function call and then checking that it is not NULL
2010-08-05 08:19:36 +02:00
Daniel Marjamäki
6f228033d2
null pointers: fixed todo test case
2010-08-05 08:06:19 +02:00
Daniel Marjamäki
239d264432
uninitialized variables: fixed false negatives when uninitialized pointer data is read
2010-08-04 21:13:40 +02:00
Daniel Marjamäki
a274cb1015
cleanup headers
2010-07-31 08:52:28 +02:00
Daniel Marjamäki
9c17114668
Fixed #1893 (false positive: dereferencing null pointer (try/catch))
2010-07-24 14:27:18 +02:00
Daniel Marjamäki
1b7796791b
Variable scope: Improved verbose information (see also 7ef0296
)
2010-07-23 12:29:21 +02:00
Daniel Marjamäki
7ef0296f97
--verbose: added more information for the variableScope error message.
2010-07-19 11:30:01 +02:00
Daniel Marjamäki
bbf2c6c6e6
Fixed #1880 (false positive: Uninitialized array (initialized in subfunction))
2010-07-19 10:03:54 +02:00
Robert Reif
e86e8449f8
Variable usage: better handling of pointer aliasing. Ticket: #1729
2010-07-12 09:50:18 +02:00
Robert Reif
566b4b4beb
Variable usage: fixed false positive reported in #1729
2010-07-08 08:42:34 +02:00
Robert Reif
2d6dfa57e1
Variable usage: Better aliasing support (Ticket #1729 )
2010-07-08 08:00:50 +02:00
Daniel Marjamäki
a1793edabe
Fixed #1825 (*log(0) error)
2010-07-07 09:03:40 +02:00
Daniel Marjamäki
4ebf4caf66
Variable usage: only warn about variables that have variable id > 0
2010-07-07 08:50:34 +02:00
Daniel Marjamäki
2bb07a55bd
Fixed #1803 (False positive: unused variable: this)
2010-07-07 08:39:18 +02:00
Daniel Marjamäki
a107cd1b59
Fixed #1729 (False positive: variable is assigned a value that is never used (pointer aliasing))
2010-07-07 08:26:24 +02:00
Daniel Marjamäki
c811acaa50
Fixed #1818 (False positive: Dangerous usage of strncpy (copying a constant string))
2010-07-05 12:45:39 +02:00
Zachary Blair
5ea28ccbba
Fixed #157 (Forgetting to put a break in a switch statement)
2010-06-30 00:10:30 -07:00
Daniel Marjamäki
c6888845a0
Fixed #1815 (False positive: uninitialized variable when using ? operator)
2010-06-30 08:28:34 +02:00
Robert Reif
4668359b51
Fixed #1808 (false positive: uninitialized variable with multiple assignment)
2010-06-29 08:38:24 +02:00
Daniel Marjamäki
ad0908cb3f
Fixed #1808 (false positive: uninitialized variable with multiple assignment)
2010-06-25 19:39:30 +02:00
Robert Reif
2a1edff77f
Fixed #1812 (false negative: functionVariableUsage doesn't support static variables)
2010-06-24 17:00:32 +02:00
Robert Reif
74e48d4bb1
Fixed #1732 (False positive: Variable not assigned a value (pointer to pointer))
2010-06-23 06:54:14 +02:00
Robert Reif
a5b45a7f83
Fixed #1807 (false positive: Variable is not assigned a value (casting function parameters))
2010-06-22 17:04:11 +02:00
Robert Reif
bdd28b47aa
Fixed #1799 (false positive: Variable is assigned a value that is never used)
2010-06-21 18:12:01 +02:00
Daniel Marjamäki
4cd3e8fdc0
Refactoring: Reduced copy/pasted code
2010-06-20 19:03:59 +02:00
Nicolás Alvarez
df3d98a7c2
Fix typos in sizeofsizeof error message.
2010-06-19 17:16:14 -03:00
Daniel Marjamäki
82b63dd736
Fixed #1633 (tokenizer: simplifyKnownVariable: improved handling of arithmetic)
2010-06-19 14:00:45 +02:00
Robert Reif
7dba21858a
simplify the alias handling in the checking of variable usage. Ticket: #1729
2010-06-16 18:00:21 +02:00
Zachary Blair
ae2a02ad93
Applied review suggestions for Ticket #920
2010-06-15 22:03:38 -07:00
Zachary Blair
efefceabae
Fixed #920 (new style check: find empty catch blocks)
2010-06-14 23:45:46 -07:00
Robert Reif
98ae660260
Fixed #1792 (false positive: Variable 'test' is assigned a value that is never used)
2010-06-14 15:46:57 +02:00
Daniel Marjamäki
cb7e9fbec1
Fixed #1776 (False Negative: Unitialized array)
2010-06-14 08:36:34 +02:00
Robert Reif
3d2c28a524
Fixed #1784 (false positive: Variable is not assigned a value)
2010-06-10 07:21:47 +02:00
Robert Reif
00dcec47ac
Variable usage: read variable when using syntax '..=*(p);'
2010-06-08 18:26:14 +02:00
Daniel Marjamäki
472bd9dabe
Fixed #1726 (False negative: null pointer dereference in switch block)
2010-06-06 12:15:31 +02:00
Robert Reif
4c4844b722
Fixed #1723 (Variable assigned value which is never used but is thrown)
2010-06-03 07:05:57 +02:00
Daniel Marjamäki
cb43168d81
Fixed #1720 (segmentation fault of cppcheck)
2010-06-02 18:10:32 +02:00
Daniel Marjamäki
8ead23fc91
CheckOther::nullConstantDereference: Fixed cppcheck warning message - tok may become null
2010-06-02 18:06:37 +02:00
Daniel Marjamäki
28ad69e4b3
Refactoring of CheckOther::nullConstantDereference
2010-06-02 17:53:45 +02:00
Daniel Marjamäki
37ae4692bb
Uninitialized variables: fixed false negative when using uninitialized variable inside malloc call
2010-05-30 10:30:51 +02:00
Daniel Marjamäki
1ec49430e3
Uninitialized variables: better handling when uninitialized variables are used in function calls
2010-05-30 09:31:10 +02:00
Daniel Marjamäki
d3ed1c8960
Refactoring uninitialized variables (checking variable declarations)
2010-05-30 08:02:39 +02:00
Daniel Marjamäki
406cbda563
Uninitialized variables: better handling of struct variables
2010-05-30 07:55:11 +02:00
Robert Reif
176b41caa5
Fixed #1709 (char buffer that is only accessed with pointers is marker not assigned)
2010-05-26 19:22:35 +02:00
Daniel Marjamäki
88e9a4ade6
Fixed #1704 (false negative: null pointer dereference)
2010-05-26 19:16:42 +02:00
Robert Reif
048733a15e
false positive: Variable is assigned a value that is never used
2010-05-23 10:41:05 +02:00
Daniel Marjamäki
75c9355e9a
Added some multipass checking for the uninitialized variables. It is still experimental. You can activate it with the '--test-2-pass' switch. Some more refactorings are needed to make it truly usable, the main thing is to make it thread safe.
2010-05-21 19:35:18 +02:00
firewave
2bced1d90c
Avoid some Visual Studio warnings
2010-05-18 19:19:15 +02:00
Daniel Marjamäki
6edb2e77b4
Refactoring: Removed Severity::possibleStyle
2010-05-16 14:43:42 +02:00
Daniel Marjamki
972046c4bd
Added test CheckOther::sizeofsizeof. Inspired by #1682
2010-05-15 14:06:45 +02:00
Daniel Marjamäki
7c52c8683d
Fixed #1662 (false positive: Data is allocated but not initialized, when using sprintf)
2010-05-09 07:48:52 +02:00
Robert Reif
be35b72c7e
Fixed #1660 (false positive: Variable is assigned a value that is never used, when using cast)
2010-05-09 07:15:40 +02:00
Daniel Marjamäki
2901434773
Fixed #1658 (false negative: uninitialized pointer usage)
2010-05-08 19:23:46 +02:00
Daniel Marjamäki
bd22a18dc1
Refactoring: Changed 'possible style' to 'style'
2010-05-08 09:49:01 +02:00
Zachary Blair
21b7eb61f5
Fixed #959 : (new check: wrong usage of fflush()) Simplified and set severity to error
2010-05-06 23:08:10 -07:00
Robert Reif
4c95264d29
Fixed #1647 (False positive: buffer is not assigned value (assigned through alias))
2010-05-05 17:31:07 +02:00
Daniel Marjamäki
612be2557b
Fixed #1646 (False positive: array access after return cannot have default loop value)
2010-05-04 20:02:47 +02:00
Robert Reif
7ce70777a4
Fixed #1643 (Variable usage (pointer is assigned but never used))
2010-05-04 17:28:03 +02:00
Robert Reif
eb276346c5
Fixed #1639 (False positive: unused variable value (pointer aliasing))
2010-05-04 17:26:09 +02:00
Zachary Blair
707d27f3d8
Fixed #959 (new check: wrong usage of fflush())
2010-05-03 23:14:45 -07:00
Robert Reif
6eb16e0f16
Fixed #1640 (False negative: Unused value (variable is assigned but never read))
2010-05-01 21:15:14 +02:00
Robert Reif
4014bd234f
Unit testing: Improved test coverage for variable usage checking
2010-05-01 09:26:47 +02:00
Robert Reif
1fa1ff8d14
Fixed #1636 (Fix false positive with strncpy termination check)
2010-04-30 21:36:48 +02:00
Robert Reif
5738f34872
Fixed #1622 (False positive: buf is not assigned a value (pointer aliasing))
2010-04-30 18:11:51 +02:00
Robert Reif
70d475f8c2
Fixed #1622 (False positive: buf is not assigned a value (pointer aliasing))
2010-04-29 07:10:50 +02:00
Daniel Marjamäki
cccccff96f
Fixed #1629 (False negative: null pointer derefence not detected 'c[0] = 0')
2010-04-28 22:07:39 +02:00
Robert Reif
f0018100e1
Variable usage: Use variable id instead of variable name to identify variable
2010-04-27 05:05:32 +02:00
Daniel Marjamäki
cda6fdb73d
astyle formatting
2010-04-25 14:56:04 +02:00
firewave
52b84963e6
Fixed Access Violation with --enable=style when no tokens exist
2010-04-25 12:35:09 +02:00
Daniel Marjamäki
eb82a89758
ExecutionPath: Better handling of if
2010-04-25 11:55:57 +02:00
Daniel Marjamäki
a15e25f9fe
Fixed #1571 ('C-style pointer casting' should not be reported for C files)
2010-04-24 16:46:09 +02:00
Daniel Marjamäki
f3bea249ac
Removed the check for unreachable code. The g++ warning -Wunreachable-code is recommended instead. This closes #1603 (break after a return or goto should not be an error in a switch statement).
2010-04-24 14:30:45 +02:00
Robert Reif
2bdcf3b5b2
variable usage: refactoring the checking
2010-04-24 09:45:03 +02:00
Zachary Blair
680a470741
Fixed #1564 (CppCheck does not recognise redundant IF)
2010-04-22 01:21:54 -07:00
Zachary Blair
c26e619b23
Fixed #855 (Refactoring: move conditions into checks)
2010-04-20 23:38:25 -07:00
Robert Reif
d851b4a3d4
Fixed #1607 (false positive: variable is assigned a value that is never used)
2010-04-17 14:23:29 +02:00
Daniel Marjamäki
b19113426f
Unused struct member: Fixed false positives
2010-04-17 11:16:05 +02:00
Robert Reif
61b5a21ac9
Fixed #1605 (false positive: uninitialized variable)
2010-04-16 16:25:57 +02:00
Robert Reif
45573ad101
Fixed #1607 (false positive: variable is assigned a value that is never used)
2010-04-16 15:57:09 +02:00
Daniel Marjamäki
c718a7c595
astyle: Update to astyle 1.24
2010-04-15 20:08:51 +02:00
Robert Reif
01aa414f32
Fixed #1253 (improve check: uninitialized variable not found when using reference)
2010-04-15 18:44:52 +02:00
Reijo Tomperi
35d2a27b9c
Update copyright year in all source files
2010-04-13 22:23:17 +03:00
Daniel Marjamäki
8373a6d4cb
astyle formatting
2010-04-13 19:30:51 +02:00
Zachary Blair
bd7dc9946e
Fixed #1530 (possible new check: strlen return value versus zero.)
2010-04-13 19:30:25 +02:00
Daniel Marjamäki
e9b4ea44a2
Refactoring: Disable inconclusive checks. They can still be activated for debugging/testing purposes
2010-04-10 14:05:33 +02:00
Daniel Marjamäki
f77dbbb14b
Fixed some false positives for unused struct members
2010-04-09 19:55:41 +02:00
Daniel Marjamäki
38a28e28ec
Fixed #1581 (False positives 'The scope of the variable x can be reduced')
2010-04-09 16:53:27 +02:00
Reijo Tomperi
5aa88ee5a2
Fix vs warnings. Apply patch from kidkat.
2010-04-06 21:35:21 +03:00
Martin Ettl
4bc325f077
#ticket 1513: added sqrt() support
2010-04-05 20:20:20 +02:00
Reijo Tomperi
93d195aa0f
astyle fix
2010-04-05 21:12:43 +03:00
Martin Ettl
f895ab9a0d
Merge branch 'master' of git@github.com:danmar/cppcheck
2010-04-05 20:08:21 +02:00
Martin Ettl
fe7c6aed9f
#ticket 1513: added pow() support
2010-04-05 20:07:53 +02:00
Reijo Tomperi
04b38e5428
astyle fix
2010-04-05 20:57:54 +03:00
Martin Ettl
218c18496d
#ticket 1513 added fmod() support
2010-04-05 19:45:33 +02:00
Martin Ettl
d4923e2a92
added atan2() check to ticket #1513
2010-04-05 19:35:56 +02:00
Daniel Marjamäki
61e1c4183f
Uninitialized variables: better handling of 'a[b[..]]' when b is not initialized
2010-04-05 09:04:30 +02:00
Daniel Marjamäki
d26a2cfc16
Uninitialized variables: Detect reading uninitialized data through array/pointer variable
2010-04-05 08:38:26 +02:00
Daniel Marjamäki
abceff497b
Refactoring: some refactoring of ExecutionPath. The foundError was removed. No automatic bailout of all checks are made when errors are found.
2010-04-04 11:24:52 +02:00
Daniel Marjamäki
78852b08ab
Fixed #1566 (false negative: uninitialized variable)
2010-04-04 09:17:53 +02:00
Reijo Tomperi
be598757a1
Fix segmentation fault when calling with --errorlist and add a testcase for it.
2010-04-03 22:53:06 +03:00
Daniel Marjamäki
5f9e14e242
Borland C++: Fixed compiler error
2010-04-03 07:51:40 +02:00
Reijo Tomperi
93d4851040
astyle fix
2010-04-02 22:17:09 +03:00
Martin Ettl
0c2f4831d8
#ticket #1513 added asin() support
2010-04-02 20:59:39 +02:00
Martin Ettl
c391a03db6
added acos() check to ticket #1513 ; added testcases for MathLib::toDoubleNumber(), now double conversion of zeros is handled correctly; changed assertEquals() function of testsuite parameters from unsigned int to double. This is needed to avoid overflow of unsigned int by comparing negative floating point values.
2010-04-02 20:23:37 +02:00
Martin Ettl
9788333ee9
added log10() check, for checking about parameters passed to mathfunctions that do not make sense
2010-04-02 19:17:41 +02:00
Daniel Marjamäki
8b5aae9adb
astyle formatting
2010-04-02 07:32:03 +02:00
Daniel Marjamäki
0cad22314e
Reverted 'astyle fix'. Those changes are not in sync with my astyle configuration/setup.
2010-04-02 07:30:58 +02:00
Martin Ettl
193aa7d1d3
astyle fix
2010-04-02 02:21:53 +02:00
Martin Ettl
b5fb01c202
ticket #1513 new check: Detecting obviously wrong math call arguments passed to math functions)
2010-04-02 02:19:38 +02:00
Daniel Marjamäki
a68d8dbc77
Fixed #1549 (false positive: uninitialized variable)
2010-03-31 20:20:51 +02:00
Daniel Marjamäki
c3edc5fd89
Fixed #1148 (improve check: usage of uninitialized variables)
2010-03-28 21:27:06 +02:00
Robert Reif
62d2845014
Fixed #1492 (false negatives: array index out of bounds)
2010-03-28 15:56:13 +02:00
Raphael Geissert
c0e09c4cb3
Fixed #1511 (false negative null pointer deref when dereferencing pointers to constants)
2010-03-26 16:44:46 +01:00
Daniel Marjamäki
e911d1f1df
doxygen updates
2010-03-17 22:16:18 +01:00
Daniel Marjamäki
235404077f
Fixed #1501 (false positive: Variable 'n' is assigned a value that is never used)
2010-03-16 19:25:10 +01:00
Daniel Marjamäki
15d67a2369
Fixed #1503 (False positive for uninitialized variable)
2010-03-16 19:09:37 +01:00
Daniel Marjamäki
30d3418b11
doxygen: added more comments for CheckNullPointer and CheckUninitVar
2010-03-13 21:42:59 +01:00
Daniel Marjamäki
7f42ed3ad0
Fixed #1472 (false positive: Data is allocated but not initialized: service)
2010-03-07 09:08:52 +01:00
Daniel Marjamäki
6ca4b008d0
null pointer: Fixed better error message for 'possible null pointer' + removed redundant check in our Tokenizer.
2010-02-28 07:26:50 +01:00
Daniel Marjamäki
0b2ad2164f
Fixed #1442 (false positive: getting offset instead of dereferencing a null pointer)
2010-02-22 21:30:21 +01:00
Daniel Marjamäki
e4a685c6e9
Fixed #1430 (void foo(int nb))
2010-02-21 08:02:44 +01:00
Daniel Marjamäki
a25cdd63b6
Refactored the CheckOther::functionVariableUsage
2010-02-21 07:05:44 +01:00
Daniel Marjamäki
375d2b1fcd
astyle formatting
2010-02-18 19:55:47 +01:00
Daniel Marjamäki
b59d79c303
readded checks for unused variables and unreachable code that were removed in 42c608b6f0
2010-02-18 18:45:13 +01:00
Daniel Marjamäki
9394816fcf
Refactoring: Use std::string instead of const char *
2010-02-14 19:58:17 +01:00
Reijo Tomperi
b52fa9451f
Fix #1385 (False positive: unsigned division)
...
http://sourceforge.net/apps/trac/cppcheck/ticket/1385
This also fixes a bug in setVarId(). "unsigned int a" didn't get varid,
untill later when unsigned was simplified away.
2010-02-12 22:24:06 +02:00
Monika Lukow
2d5d060514
Fixed #1094 (Improve check: unusual pointer arithmetic: 'ch+str')
2010-02-07 21:44:11 +01:00
Daniel Marjamäki
0d18050b55
Fixed #984 (improve output if strncpy is followed by strncat)
2010-02-05 17:35:18 +01:00
Daniel Marjamäki
1b9afc82a4
Reverted 4f30468c80
. There was false positives such as #1335 so please fix them and then re-commit.
2010-02-01 19:46:51 +01:00
Monika Lukow
4f30468c80
Fixed #1094 (Improve check: unusual pointer arithmetic: 'ch+str')
2010-01-31 11:42:02 +01:00
Daniel Marjamäki
48f3921c36
Null pointer dereference: sending to output stream
2010-01-30 14:40:33 +01:00
Daniel Marjamäki
43c8fe895c
Fixed #1301 (False positive: Data is allocated but not initialized)
2010-01-23 21:25:17 +01:00
Daniel Marjamäki
037ecffc34
detect when function pointer that is null is used
2010-01-23 09:15:30 +01:00
Daniel Marjamäki
7b986c831d
Report when using uninitialized function pointer
2010-01-23 07:57:57 +01:00
Daniel Marjamäki
2e707974d0
Fixed #1273 (scope of variable limited not detected in latest versions)
2010-01-21 18:50:56 +01:00
Daniel Marjamäki
fbf428550a
Fixed #1262 (cppcheck false positives: 'Possible null pointer dereference', 'Uninitialized variable')
2010-01-17 19:08:45 +01:00
Daniel Marjamäki
a7bddc8fd3
Fixed #1268 (Null pointer dereference false positive)
2010-01-14 20:02:38 +01:00
Daniel Marjamäki
1aac8f3e52
Uninitialized variables: disable subfunction analysis if multiple threads are used
2010-01-12 22:33:47 +01:00
Daniel Marjamäki
374def4a53
Fixed #1070 (Improve scope error message)
2010-01-12 19:34:33 +01:00
Daniel Marjamäki
d3b7f5931f
Fixed #1174 (improve check: Unintialized variable not detected in subfunction)
2010-01-11 22:28:07 +01:00
Daniel Marjamäki
b8b6b0ec32
Uninitialized variables: fixed false positives when using pointer aliasing
2010-01-11 19:25:01 +01:00
Daniel Marjamäki
c5966bba59
Fixed #1225 (false negative :: uninitialized variable not detected when using enums)
2010-01-10 20:36:15 +01:00
Daniel Marjamäki
b82cb2e41e
Fixed #1218 (Improve check: incrementing uninitialized variable i++)
2010-01-10 09:09:37 +01:00
Daniel Marjamäki
4c641ed80c
Fixed #1189 (false negative: using uninitialized variable i 'a[i] = 0;')
2010-01-09 22:26:05 +01:00
Daniel Marjamäki
e248f7d3e5
Fixed #1023 (improve check: Unintialized variable not detected when using +=)
2010-01-03 18:49:13 +01:00
Daniel Marjamäki
fa535ff3ae
Fixed #440 (NULL referencing not detected)
2010-01-03 13:30:20 +01:00
Daniel Marjamäki
1032eb2449
Fixed #1214 (false positive: uninitialized variable 'bool fixed = std::ios_base::fixed;')
2010-01-03 08:03:28 +01:00
Daniel Marjamäki
d82079e86f
Fixed #1209 (False positive: uninitialized variable c when it is initialized with 'ab(sizeof(xyz), &c)')
2010-01-02 18:16:44 +01:00
Daniel Marjamäki
b0d7623dcf
refactoring the fix for #1191
2010-01-01 19:49:33 +01:00
Daniel Marjamäki
f8bd59f5b5
Fixed #1191 (false positive: uninitialized variable)
2010-01-01 19:43:02 +01:00
Daniel Marjamäki
7ecd333ffa
Fixed #1188 (false negative: dereferencing p, which is a null pointer 'int y = 5 + *p')
2009-12-31 20:00:20 +01:00
Daniel Marjamäki
0159287437
Fixed #1183 (False positive: uninitialized variable p 'd = bar(sizeof(*p));')
2009-12-31 09:10:20 +01:00
Daniel Marjamäki
0ee3d7e46a
Fixed #1182 (False positive: uninitialized variable 'int *pa = &a;')
2009-12-30 21:42:15 +01:00
Daniel Marjamäki
71a83647c6
cleanup
2009-12-30 20:38:16 +01:00
Daniel Marjamäki
ae3ff7d376
Fixed #1087 (uninitialized data not detected 'char z = *str')
2009-12-30 20:37:11 +01:00
Daniel Marjamäki
461d826eff
Fixed #1105 (improve check: uninitialized variable not detected for 'a = a')
2009-12-30 20:15:44 +01:00
Daniel Marjamäki
d83131ca92
Fixed #1041 (passing a nullpointer to a reference)
2009-12-30 17:42:41 +01:00
Daniel Marjamäki
06ee643c6a
Fixed #1177 (False positive: pointer is not dereferenced 'sizeof(*p)')
2009-12-30 11:32:46 +01:00
Daniel Marjamäki
2a28ca72cc
Fixed #1166 (improve check: using uninitialized pointer to create reference 'int &r(*p);')
2009-12-29 20:36:20 +01:00
Daniel Marjamäki
4cbae159b2
ExecutionPath: Refactoring. Removed the bailOut variable
2009-12-29 09:30:02 +01:00
Daniel Marjamäki
9aca2e7680
Fixed #1156 ([False positive] Uninitialized variable - class member in constructor)
2009-12-28 12:51:28 +01:00
Daniel Marjamäki
b1e963fe2c
Fixed another issue with #1154 (false positive: Data is allocated but not initialized)
2009-12-27 18:00:43 +01:00
Daniel Marjamäki
1c0f3ee179
Fixed #1154 (false positive: Data is allocated but not initialized)
2009-12-27 17:35:18 +01:00
Daniel Marjamäki
738987a686
Fixed #1138 (improve check: dereferencing uninitialized pointer)
2009-12-27 17:20:34 +01:00
Daniel Marjamäki
dccba65502
Uninitialized variables: Refactoring and commenting a little
2009-12-27 10:48:44 +01:00
Daniel Marjamäki
fbfe5a4bd1
Fixed #1153 (False positive: uninitialized data for reinterpret_cast)
2009-12-27 09:27:05 +01:00
Daniel Marjamäki
ab7ffd2391
Uninitialized variables: Fixed false positive for 'if (ptr)'
2009-12-26 16:22:14 +01:00
Daniel Marjamäki
a82a085d10
Fixed #1151 (false positive: Data is allocated but not initialized)
2009-12-26 09:30:02 +01:00
Daniel Marjamäki
9819b75e17
ExecutionPath: Refactoring if-handling
2009-12-25 20:50:23 +01:00
Daniel Marjamäki
7bf0622ae0
ExecutionPath: Refactoring the interface
2009-12-25 20:12:06 +01:00
Daniel Marjamäki
b5291825ce
Fixed #683 (wrong usage of strcmp)
2009-12-25 19:45:21 +01:00
Daniel Marjamäki
9b05850e97
fixed unit testing
2009-12-23 20:00:12 +01:00
Daniel Marjamäki
ea51c3e098
Refactoring the uninitialized variable / null pointer checks so they use a common function to inspect function calls
2009-12-23 19:51:32 +01:00
Daniel Marjamäki
a7d48f2eb4
Fixed #1147 (Improve check: return uninitialized variable)
2009-12-23 17:55:03 +01:00
Daniel Marjamäki
b6c320de8a
Fixed false positives about uninitialized variables
2009-12-23 15:01:23 +01:00
Daniel Marjamäki
ef21ba7425
Fixed #1137 (false positive: uninitialized variable when using a class object)
2009-12-23 13:57:01 +01:00
Daniel Marjamäki
5a89cc3259
Robert Reif: Fixed #1139 (false negative: CheckOther::postIncrement() only finds at most one problem)
2009-12-23 13:38:54 +01:00
Daniel Marjamäki
2bd60ab6c8
Fixed #1133 (Uninitialized array: strchr, strrchr, etc)
2009-12-22 21:08:29 +01:00
Daniel Marjamäki
566cfce8da
Fixed #1128 (false positive: Data is allocated but not initialized)
2009-12-22 21:00:52 +01:00
Daniel Marjamäki
11da89784f
Eric Sesterhenn: Fixed #1130 (False positive uninitialized variable)
2009-12-22 19:16:34 +01:00
Daniel Marjamäki
2e0566bf7a
Fixed #1096 (Non-obvious error message: Overlapping data buffer)
2009-12-21 21:05:55 +01:00
Daniel Marjamäki
b3b07321ca
ericsesterhenn: Fixed #1091 (improve check: nullpointer dereference not detected)
2009-12-21 19:09:13 +01:00
Daniel Marjamäki
763e3d9eb5
Execution Path: Refactoring
2009-12-21 18:17:35 +01:00
Daniel Marjamäki
11c7b8a839
Execution Path: some refactorings of the checking
2009-12-20 19:44:32 +01:00
Daniel Marjamäki
e03ff727d4
Fixed #1103 (false positive: uninitialized variable when using references)
2009-12-15 19:50:48 +01:00
Daniel Marjamäki
0c13f9ba5c
Added TestLocalLeaks
2009-12-14 20:30:31 +01:00
Daniel Marjamäki
9646f62ec1
Fixed #1075 (False positive: uninitialized variable 'return bar(s);')
2009-12-11 19:58:29 +01:00
Daniel Marjamäki
91114c50d2
Fixed #1061 (false positve: uninitialized variable)
2009-12-09 20:05:06 +01:00
Reijo Tomperi
e57d9609a7
small fix to previous commit
2009-12-06 22:32:38 +02:00
Reijo Tomperi
fc40808a8a
Minor refactoring for checkother.cpp
2009-12-06 22:28:38 +02:00
Daniel Marjamäki
8db35189e0
STL: fix iterator bug
2009-12-06 21:21:27 +01:00
Daniel Marjamäki
3100bb3ccc
Visual C++: Suppress compiler warnings
2009-12-06 20:34:02 +01:00
Daniel Marjamäki
bbc63b6b5b
twistedwave: Fixed #1055 (Support for inline suppressions)
2009-12-06 19:38:53 +01:00
Daniel Marjamäki
2d180ab918
newcheck: added the 'newcheck' functionality. It's still in early state so it needs refactoring
2009-12-06 18:41:28 +01:00
Daniel Marjamäki
ded2e68c2e
Fix #1022 (False positive: uninitialized variable when using local struct)
2009-11-29 19:23:31 +01:00
Daniel Marjamäki
d866c174cf
Fixed
2009-11-15 20:26:07 +01:00
Daniel Marjamäki
469a8e4032
Fixed #925 (uninitialized deletion not detected)
2009-11-15 20:01:57 +01:00
Daniel Marjamäki
822f64ec9a
Fixed #953 (false positive: 'uninitialized variable' with function pointer)
2009-11-15 12:42:04 +01:00
Daniel Marjamäki
ebf907cbc0
Fixed #936 (false positive: uninitialized variable '.. else return; .. ')
2009-11-14 20:37:54 +01:00
Daniel Marjamäki
ec6d66ff45
Fixed #913 (false positive: uninitialized variable)
2009-11-14 08:00:17 +01:00
Daniel Marjamäki
e0b1303b50
Fixed #929 (Uninitialized variable false positive)
2009-11-10 18:05:55 +01:00
Daniel Marjamäki
41e59d8348
Fixed #832 (Exception Safety: deallocating member pointer and then throwing exception)
2009-11-08 09:54:08 +01:00
Daniel Marjamäki
4b04ed9ad9
Fixed #910 (false positive: uninitialized variable for array)
2009-11-08 07:31:01 +01:00
Daniel Marjamäki
d88c236efe
uninitialized data: minor fix to handle 'new char [' better
2009-11-07 14:54:12 +01:00
Reijo Tomperi
45406f5367
astyle fix
2009-11-07 14:19:25 +02:00
Daniel Marjamäki
60caefe069
uninitialized data: added more checking for allocated data
2009-11-07 09:10:15 +01:00
Daniel Marjamäki
c561a36cc7
uninitialized variables: better checking of strncpy
2009-11-06 19:06:45 +01:00
Daniel Marjamäki
7397bfc765
Fixed #904 (false positive: uninitialized variable)
2009-11-06 16:50:02 +01:00
Daniel Marjamäki
53f7b12b4f
Fixed #902 (false positive: uninitialized variable when variable is initialized in macro)
2009-11-06 16:02:13 +01:00
Daniel Marjamäki
442584151b
Fixed #897 (false positive: uninitialized variable when assigning pointer to array to struct member)
2009-11-05 21:07:04 +01:00
Daniel Marjamäki
3c82fbb73a
use Token::link instead of findmatch to find ']'
2009-11-03 22:48:41 +01:00
Daniel Marjamäki
c3dff9a6d3
Fixed #893 (False Positive: Uninitialized variable b in a[0] = b[0] = '\0';)
2009-11-03 21:02:16 +01:00
Daniel Marjamäki
797e9aeaf5
Fixed #890 (false positive: Uninitialized variable when pointer takes the address to array)
2009-11-03 17:03:53 +01:00
Daniel Marjamäki
8d57cef7f9
Fixed #764 (usage of unitialized variable not detected)
2009-11-02 19:58:49 +01:00
Daniel Marjamäki
4abbe9ffd4
Fixed #889 (false positive: uninitialized variable)
2009-11-02 16:28:15 +01:00
Reijo Tomperi
eebbc1b906
Fix #884 (False positive: Possible null pointer reference about a non-pointer)
...
http://sourceforge.net/apps/trac/cppcheck/ticket/884
2009-11-01 13:08:37 +02:00
Daniel Marjamäki
c83d9cd786
Fixed #843 (new check: Passing uninitialized array to strlen/strdup/strcpy/strcat/etc)
2009-10-31 16:36:56 +01:00
Daniel Marjamäki
266291baf4
Fixed #876 (false positive: uninitialized variable)
2009-10-31 10:30:32 +01:00
Daniel Marjamäki
45df223bfb
Fixed #875 (Uninitialized variable: initialization in subfunction)
2009-10-30 18:28:01 +01:00
Daniel Marjamäki
6ac2b6ab14
uninitialized variables: return|goto are not used in variable declarations
2009-10-30 15:23:27 +01:00
Daniel Marjamäki
7dbf22aa3f
null pointer: fixed false positive when condition checks if pointer is ok
2009-10-30 15:14:24 +01:00
Daniel Marjamäki
2cf849a9b8
uninitialized variables: fixed false positive when switch is used
2009-10-30 14:52:20 +01:00
Daniel Marjamäki
765c824c6f
Uninitialized pointers: It's allowed to dereference uninitialized non-pointer variables
2009-10-30 14:31:37 +01:00
Daniel Marjamäki
44a9c9b458
Fixed #874 (false positive: uninitialized variable)
2009-10-30 14:06:40 +01:00
Daniel Marjamäki
768225bb1b
uninitialized variables: fixed false positives for member variables
2009-10-30 13:43:00 +01:00
Daniel Marjamäki
c6d7fad84f
uninitialized variables: added check
2009-10-29 21:34:43 +01:00
Daniel Marjamäki
09859c1019
refactoring the folder structure
2009-10-25 12:49:06 +01:00