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
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
26a2379f9f
Fixed false positive #3941 .
2012-07-29 06:39:43 -07:00
PKEuS
9834888f19
Removed some duplicate tests and a redundant variable
2012-07-25 01:34:54 -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
43c060b630
Removed preprocessor directives from tests that aren't preprocessed before being tokenized.
2012-07-07 11:21:08 -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
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
Ettl Martin
c9cb492bc7
#3874 added missing testcase to avoid false positives
2012-06-10 18:36:19 +02:00
Ettl Martin
d7c1907601
added tests for duplicated branches. Inspired by http://www.viva64.com/en/b/0149/ ( Comparision between PVS-Studio and cppcheck): Errors detected in Quake 3: Arena by PVS-Studio: Fragement 2
2012-05-30 01:30:37 +02:00
Ettl Martin
474dccf8ad
added a testcase for detecting duplicate if else branches.
2012-05-29 09:22:42 +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
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
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
Daniel Marjamäki
f803a18d50
Fixed #3749 (false positive: same expression on both sides of operator)
2012-05-17 07:26:57 +02:00
Ettl Martin
8a7b141246
added testcase for ticket 3689
2012-05-14 09:57:30 +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
5ac7552e4e
New check: Comparision of modulo results that are always true/false.
2012-04-26 15:23:47 +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
Ettl Martin
7be01da8e9
fixed ticket 3693. Added modulus operator to Mathlib + unittests. Added a test to checkother to ensure the testcase of ticket 3693 does not trigger an error message.
2012-04-12 14:02:09 +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
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
4f1f6e1824
Improved simplification of calculations:
...
- Use more generic patterns
- Look on operator precedence more consequently
-> Made a TODO test case from a test case that worked previously, because the calculation is simplified so that the problem isn't detected any more.
Changed comment "Coding style checks" to "Checks", because it didn't fit
2012-03-27 21:29:50 +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
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
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
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
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
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
0e791929b5
Ticket #3598 - Added a missing ASSERT_EQUALS() statement to the end of checkDoubleFree()
2012-02-18 12:13:21 -08:00
PKEuS
8ea5df62c4
- Improved support for numbers in code:
...
-- Use MathLib::toLongNumber for conversion in tokenizer (Fix #3610 )
-- Handle octal numbers in tokenizer
- Refactorizations in MathLib::toLongNumber and Settings
2012-02-17 15:47:08 +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
69567515ce
Ticket #3581 - added missing newlines to the test code
2012-02-04 11:39:29 -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
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
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
PKEuS
461565c50a
Fixed #3517 and #3513
2012-01-15 12:32:02 +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
Daniel Marjamäki
94d220e370
Refactoring: Made Preprocessor::getcode nonstatic
2012-01-06 08:01:50 +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
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
0a588496a0
Fix astyle and test failures.
2011-12-28 22:05:10 +02: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
f8181df340
Fixed #3410 (Comparing bool against bool produces false positive)
2011-12-20 06:38:05 +01:00
PKEuS
0205582161
Fixed #3327 (printf with std::string as parameter)
2011-12-18 19:41:21 +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
9b685ba3c3
Code cleanup
2011-12-09 21:00:57 +01: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
1f438b0505
Fixed #3375 (Improve check: Detect unreachable code)
2011-12-03 11:43:23 +01:00
Daniel Marjamäki
9a84c5845a
Fixed #3373 (False posititive: incorrect %* handling in sscanf)
2011-12-02 17:09:32 +01:00
Richard Quirk
b2ea78543b
Fix false positive with non-const function calls
2011-12-01 19:57:04 +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
31b576de3b
Fixed #3334 (Test for same expression on both sides of '&' reports false positive)
2011-12-01 17:07:55 +01:00
PKEuS
ee3e10ea97
Fixed #3364 (Crash in printf parsing)
2011-11-30 20:23:29 +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
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
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
Marek Zmysłowski
994f08fdf0
Fixed #886 (new check: wrong value passed to isgraph function)
2011-11-17 16:31:16 +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
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
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
68cb7a2731
Fix all the test failures caused by my previous commit.
2011-10-30 11:27:27 +01:00
Edoardo Prezioso
44a234f9b0
Fixed lots of test failures caused by my previous commit.
...
There are still some which I don't know how to fix.
2011-10-30 11:21:46 +01:00
Daniel Marjamäki
b67cb077a3
fix unit test failure
2011-10-29 12:21:22 +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
9a1b195d79
Fixed #3187 (Remove code duplication in 'other' unit test)
2011-10-23 12:20:43 +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
Edoardo Prezioso
9e5beab4a8
Nitpicky fix of the missing ';' after the memset command inside the test case.
2011-10-20 21:46:34 +02:00
PKEuS
ea02bd905a
Fixed #3225 (Boolean comparison with string literals)
2011-10-18 21:37:03 +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
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
Thomas Jarosch
7d13d25638
Fixed #3181 (Add missing return statements)
2011-10-08 12:45:56 +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
302daeb9bd
add test for #3110 (false positve: style) Boolean result is used in bitwise operation. Clarify expression with parentheses)
2011-09-12 20:46:00 -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
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
6f3131da8c
fix a serious symbol database bug where parts of a function could be skipped
2011-08-23 20:12:29 -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
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
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
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
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
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
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
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
Kimmo Varis
c7d99fe9a7
Remove ErrorLogger::reportStatus() method.
...
The ErrorLogger::reportStatus() is not lib code interface. The CLI
code does the looping through file list and gives one file at a
time for the core code. Hence lib has no any idea about the
progress and it can't provide such information.
Also the recent commit (6d858b6
) caused a GUI build failure by
adding CLI code dependency to GUI. Which is big no-no.
This is admittedly a hack. But it allow us to build all modules
again.
2011-04-27 23:27:02 +03:00
Greg Hewgill
6d858b63a1
Report percentage complete based on file size
...
This patch makes the (reasonable) assumption that the total size of all checked
files fits in a 'long' type.
2011-04-26 22:26:23 +12: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
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
Daniel Marjamäki
739b6a93e2
Fixed #2713 (False positive (Redundant assignment))
2011-04-16 12:07:56 +02: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
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
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
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
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
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
c8394909c0
Relax detection of 'fall through' comment so it only adds a suppression if it immediately precedes 'case' or 'default'
2011-03-06 12:14:10 +13:00
Greg Hewgill
8c245cfd2f
switchCaseFallThrough is now a coding style check (ticket #2623 )
2011-03-06 09:43:27 +13:00
Greg Hewgill
e12ae654a8
Support a few more common styles of "fall through" comment
2011-03-05 18:02:38 +13:00
Greg Hewgill
c5f8a06a97
add TODO for case where simplifyGoto() does the wrong thing
2011-03-05 00:45:59 +13:00
Greg Hewgill
cc7e05a5b0
fix case where fall through comment precedes preprocessor line
2011-03-05 00:45:58 +13:00
Greg Hewgill
8e839a46e8
add TODO for pathological case
2011-03-05 00:45:58 +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
610d2efaea
recognise fall through in c style comments
2011-03-05 00:45:58 +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
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
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
Raphael Geissert
d592250284
Fix sizeof sizeof check to handle sizeof(sizeof type)
2011-02-02 11:49:32 -06:00
Pete Johns
2d1ccad44e
Turned failing ASSERT_EQUALS into TODO_ASSERT_EQUALS.
2011-02-01 19:55:39 +11:00
Greg Hewgill
dcc0f28f34
check that misused scope object does not pick nested class
2011-02-01 08:07:41 +13:00
Pete Johns
098f0bf3e6
Fixed #2526 (Make TODO_ASSERT_EQUALS take three arguments (value, to_be, as_is)?...
...
Removed replaced EXPECTED with...
WANTED (to-be): The future expected value.
CURRENT (as-is): Documenting how cppcheck behaves now.
This removes the need for an ASSERT_EQUALS but enforces the check for every TODO_ASSERT_EQUALS.
2011-01-30 23:20:11 +11: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
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
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
Reijo Tomperi
226b605774
Change year 2010 -> 2011 in license texts.
2011-01-09 21:33:36 +02:00
Daniel Marjamäki
37b1f7c296
memsetZeroBytes: improved error message. ticket: #2421
2011-01-06 16:27:22 +01:00
Daniel Marjamäki
ed71c57f1f
astyle formatting
2011-01-06 12:07:18 +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
d11b5163b7
Fixed #2382 (Catching exceptions by value instead of reference)
2010-12-31 03:01:38 -08:00
Kimmo Varis
e8b81f909d
Change 'Scope of variable'-message to information message.
2010-12-27 16:48:03 +02: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
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
Robert Reif
f12c0c7ada
Tokenizer: add assert(_settings) to Tokenizer to insure the tokenizer always has settings. Ticket: #2219
2010-12-01 18:00:55 +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
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
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
fd64a7e683
Mutual exclusion: Disable this check until #2162 is fixed.
2010-11-20 07:43:07 +01:00
Ettl Martin
88cc29ea0a
mathlib: added todo testcases for ticket #2200
2010-11-15 21:03:49 +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
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
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
24a2def3ad
Execution Path: Fixed FP in improved handling of loop bodies
2010-10-24 19:14:40 +02:00
Daniel Marjamäki
8f707e5e46
Null pointers: Better handling of loops
2010-10-24 18:51:14 +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
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