Commit Graph

1022 Commits

Author SHA1 Message Date
PKEuS b7996bd0b0 Handle overloads and custom implementations of functions checkReturnIgnoredReturnValue() to avoid false positives 2014-10-30 21:26:32 +01:00
Frank Zingsheim 3923618b8d Fixed #6222 (Missing varid for multiple braced initialized variables)
-> Fixed broken code in unit tests
2014-10-16 20:46:57 +02:00
PKEuS 49a14d72e7 Fixed C&P-error in unit test that was added in previous commit 2014-09-29 19:57:27 +02:00
PKEuS 374ea8f039 Fixed false positive ignoredReturnValue on unknown member function log() (#6197) 2014-09-29 19:55:32 +02:00
PKEuS 1495a411eb Fixed false positive ignoredReturnValue for variables initialized with constructor syntax (#6194) 2014-09-29 10:15:29 +02:00
PKEuS 210294443e New check: Check for unused return values (#653) 2014-09-27 21:31:04 +02:00
PKEuS cafddcb109 Fixed wrong function log10 being recommended instead of log1p 2014-09-14 13:36:12 +02:00
Dmitry-Me 1e298a31cf Refactoring tests. Use utility function to warn about unsimplified code in tests. 2014-09-13 12:59:32 +02:00
Simon Martin bf3a8686ec Ticket #6164: Added test case that now works (failed in 1.66). 2014-09-12 21:56:13 +02:00
PKEuS 6f92557478 Use information about pure/leak-ignore from library to improve accuracy of several bailouts 2014-09-11 20:27:07 +02:00
PKEuS fb0d145b34 Don't show inconclusive message redundantCopyLocalConst if --inconclusive is not set.
Ran AStyle
2014-09-11 19:45:52 +02:00
Daniel Marjamäki 7847263451 Fixed #6158 (New check: dangerous sign conversion) 2014-09-11 18:10:19 +02:00
PKEuS 865fc9aa67 Fixed #6154: Don't suggest to reduce scope if inner scope is a lambda. 2014-09-10 20:56:34 +02:00
Daniel Marjamäki 974c8688c3 Fixed #1751 (Undefined Behavior: Signed integer overflow) 2014-09-10 17:02:18 +02:00
Daniel Marjamäki f111a89639 Fixed #1757 (Undefined Behavior: Shift too many bits) 2014-09-09 07:24:59 +02:00
PKEuS ff4fc6a234 New check: Recommend expm1, log1p, erfc (#5392) 2014-09-07 11:38:49 +02:00
Alexander Mai efab840b50 #5230 Explicit reinterpret_cast should not give a warning. Lower all invalidPointerCast messages to 'portability' 2014-09-06 13:09:02 +02:00
Alexander Mai 29b46cb505 #6132 crash: daca: kvirc CheckOther::checkRedundantAssignment() 2014-09-05 20:03:34 +02:00
Dmitry-Me 7d9342d16a More test cases for pointer sign detection 2014-09-04 15:51:18 +04:00
PKEuS ddc19febb5 Merge pull request #413 from Dmitry-Me/improveCStyleCastsDetection
Improve C style casts detection
2014-09-02 08:07:53 +02:00
PKEuS 00044aabb0 Handle ternary operator in redundantAssignment check (#5964) 2014-09-01 23:16:52 +02:00
Alexander Mai a4ff30301a #5805 'Passing value -1.0 to sqrt() leads to undefined result' is incorrect. Degrade wrongmathcall from error to warning, since it deals with implementation-defined behaviour 2014-09-01 19:31:32 +02:00
Dmitry-Me f937dde1e0 Improve C style casts detection 2014-09-01 16:40:28 +04:00
PKEuS c92230dfee Fixed crash on garbage code introduced by recent commit. 2014-09-01 12:41:30 +02:00
PKEuS 20a066bb14 Run unreachableCode checking only on executable scopes (#5789) 2014-09-01 11:29:39 +02:00
PKEuS b5e064e737 Fixed unreachableCode message if a lambda is returned (#6008). 2014-09-01 11:10:42 +02:00
PKEuS 353a9e9a64 Bailout for duplicateBranch check if branches are empty (#5354) 2014-09-01 10:19:14 +02:00
PKEuS e35329aba3 Fixed reporting of unmatched suppressions for unusedFunction (#4946) 2014-09-01 10:13:03 +02:00
PKEuS 6f222e4d1f Added unit test for #5534. 2014-08-31 19:58:03 +02:00
PKEuS 06a92e8981 Moved several condition checks from checkOther to checkCondition (former checkAssignIf) 2014-08-29 17:06:46 +02:00
PKEuS eba8c6f6c5 Refactorization:
- Added missing separating comments between checks in checkother.cpp
- Moved checks related to strings into own file
2014-08-27 09:42:09 +02:00
PKEuS 7f2be2f57c Fixed template bracket linkage in while loop simplification
Ran AStyle
2014-08-23 12:28:54 +02:00
amai2012 976966fe81 #5639 String literal compared with char buffer in a struct. 2014-08-23 09:41:40 +02:00
Daniel Marjamäki f7f44f24c7 Fixed #5132 (False negative: incorrectLogicOperator in simple if-clause) 2014-08-17 14:04:40 +02:00
Daniel Marjamäki 364c975701 Fixed #5557 (astIsFloat: better handling of '.') 2014-08-15 16:48:53 +02:00
PKEuS 6545bf7938 Added back accidentially removed unit test 2014-08-06 12:08:18 +02:00
PKEuS d3a567bf96 Fixed false positive #5824: Variables that might be used for va_start() must not be passed by reference. 2014-08-06 12:06:36 +02:00
PKEuS 4a3d719386 Fixed recently introduced FP when C-Style casting nullpointers 2014-08-04 11:42:14 +02:00
PKEuS 4c80ca4e8e Improved cstyleCast check:
- Detect casting of literals
- Check initializer lists (#3630)
2014-08-04 11:21:25 +02:00
Daniel Marjamäki fdfea717c6 Suspicious string comparison: Refactoring using AST. Fixed FP in Lac. 2014-07-28 14:27:35 +02:00
Daniel Marjamäki 76020d2ad0 astIsFloat: expression 'floatvar ? 0x40 : 0' is not float 2014-07-26 09:09:58 +02:00
Daniel Marjamäki 2cc31acabb Fixed #5922 (FP: passedByValue for std::string::value_type) 2014-07-18 15:51:59 +02:00
Daniel Marjamäki 41baffdda1 Fixed #5850 (Wrong Message on self assignment) 2014-06-28 15:26:22 +02:00
Daniel Marjamäki 42c3b3c89d Library: Change range operator in validation pattern to ':' 2014-06-08 18:12:11 +02:00
Alexander Mai 4d5b463613 Fix clang compiler warning in mathlib.cpp and repair test case for #5895 2014-06-07 13:16:02 +02:00
orbitcowboy 6d0f490138 #5895 - Fixed potential signed integer overflow in Checkother:getvalue. Added regression test. 2014-06-05 16:41:10 +02:00
orbitcowboy e9144d1a78 Fixed #5890 - crash: wesnoth desktop_util.cpp / unicode.hpp. 2014-05-29 02:58:18 +02:00
Daniel Marjamäki 66ad3c97b9 Fixed #5857 (strPlusChar: Crash on invalid code 'int+;') 2014-05-31 10:34:00 +02:00
Daniel Marjamäki 70b4c945de Fixed #5874 (False positive: 'opposite conditions in nested if' with arrays) 2014-05-30 19:19:24 +02:00
PKEuS bc0682d1e9 Enhancements related to duplicate expression checking:
- Fixed astIsFloat() for complex expressions
- Enhanced support for commutative operators (#5260)
2014-05-22 21:46:48 +02:00
PKEuS 4cad064c3c Fixed false positive on C code introduced by last commit 2014-05-21 20:36:19 +02:00
PKEuS d19eabde42 New Check: Compare pointer with '\0' (#4070) 2014-05-21 19:12:07 +02:00
PKEuS cdfed32500 Merged checkSelfAssignment() into checkDuplicateExpression():
- Fixed false negatives on self assignments of more complex expressions like "a.b"
- New false negative on self assignment in initialization
- Support this->... pattern in isSameExpression()
- Fixed #5819: Check type of operands
2014-05-21 18:19:42 +02:00
PKEuS 48c3d02fc3 Fixed false positives and false negatives in 'oppositeInnerCondition' (among others: #5808) 2014-05-21 14:38:41 +02:00
PKEuS c0fc47643f Fixed false positive #5772: Use AST to check if modulo operation is preceded by an arithmetical operation. 2014-05-09 21:58:28 +02:00
Daniel Marjamäki cb43bee10d Same expression: don't warn for same expressions when there is assignment 2014-05-09 06:16:27 +02:00
Daniel Marjamäki b354de6b23 Fixed #5750 (FP:Opposite conditions in nested 'if' blocks lead to a dead code block) 2014-05-06 16:15:12 +02:00
Alexander Mai d3e8bbdc51 #5618 False positive: (performance) Use const reference for 'temp' to avoid unnecessary data copying. - redundantCopyLocalConst/CheckOther::checkRedundantCopy() is prone to false positives. As a quick fix that check becomes inconclusive. 2014-05-02 20:09:38 +02:00
orbitcowboy a6af8f5dcf #5748: Fixed FP (wrongmathcall) do not warn if an object calls a function foo.log(0). 2014-04-23 01:23:38 +02:00
Daniel Marjamäki fc24d491cc Fixed #5560 (false positive: C-style pointer casting) 2014-04-29 06:21:30 +02:00
PKEuS 866ab1ce14 Fixed false positive #5689: Care about usage of return values of memory functions 2014-04-27 12:18:33 +02:00
Daniel Marjamäki bde6698bcd Fixed #5731 (False positive with opposite conditions) 2014-04-27 10:21:20 +02:00
Alexander Mai 17ec0af6a7 #5734 A FP literalWithCharPtrCompare was issued upon comparison with a char referenced within a string literal 2014-04-27 09:40:13 +02:00
Alexander Mai b5c580a59e Fix some clang warnings - most related to semantic doxygen errors 2014-04-26 16:17:26 +02:00
Frank Zingsheim 87354bf9d2 Fixed #5707 (false negative: unreachable code is not detected (code after return)) 2014-04-23 07:58:43 +02:00
Daniel Marjamäki 3c5cf299e3 Fixed #5708 (Improve oppositeInnerCondition) 2014-04-23 07:57:13 +02:00
Alexander Mai ccba934cb1 #5684 The scope of the variable 'p' can be reduced - But it can not. 2014-04-17 21:32:56 +02:00
Daniel Marjamäki 8d5a9893d5 Fixed #5682 (False positive: (style) Same expression on both sides of '&&') 2014-04-16 16:04:46 +02:00
PKEuS 7ffc313748 Save "->" in Token::originalName if simplified to "."; Fix false positive #4890. 2014-04-12 12:04:56 +02:00
PKEuS c33498fa0b Fixed false positive redundantAssignment when operator() is called (#5568) 2014-04-10 21:56:30 +02:00
Daniel Marjamäki 8dcb3bae47 Refactoring checks of overlapping conditions in if and else-if 2014-04-03 19:35:50 +02:00
Daniel Marjamäki bc9bb17025 Refactor CheckOther::oppositeInnerCondition() using AST and isSameExpression() 2014-04-02 16:54:01 +02:00
Daniel Marjamäki 407c9fdf9d Refactored checkNegativeBitwiseShift() so it uses ast and valueflow 2014-03-29 13:01:30 +01:00
PKEuS 50a94885ce Fixed oppositeInnerCondition check:
- Resolved false positives #4170 and #4186, as well as numerous other potential false positives
- Improved message to point to both locations
- Inner condition could also be a while loop; Outer if could also be 'else if'
- Made the check non-experimental again (#3645)
2014-03-28 14:55:17 +01:00
PKEuS b23aebf2f0 Show redundantCopyLocalConst for STL types (#4331) 2014-03-27 11:15:17 +01:00
PKEuS 9b4b90f6a0 Avoid loading libraries multiple times in test suite
-> Massive speedup for test suite (especially on slow systems)
2014-03-24 09:59:05 +01:00
PKEuS 8d5be8c4a4 Fixed related issues to #5601 2014-03-22 22:35:20 +01:00
PKEuS 58c2f372b9 Fixed false positive when noreturn function is defined (#5601, second attempt) 2014-03-22 19:55:13 +01:00
PKEuS 77c871035b Fixed false positive when noreturn function is defined (#5601) 2014-03-22 18:57:19 +01:00
Daniel Marjamäki 7d2357de8d Refactoring. Use astIsFloat() 2014-03-22 18:42:29 +01:00
Daniel Marjamäki 54e7f34f4a Fixed #5584 (FP: Division by zero when function not declared) 2014-03-20 16:12:58 +01:00
PKEuS 2568baa473 #5528: Raise duplicateExpressionError on operators /, % and -. 2014-03-17 18:35:36 +01:00
PKEuS fab6b56360 Improved check (#5553): Detect stricmp(var.c_str(), var.c_str()) 2014-03-17 17:41:45 +01:00
PKEuS ebd0b43c4f Fixed #5382: False positive "scope can be reduced" when initializing two-dimensional array. 2014-03-17 12:34:39 +01:00
PKEuS d325d14b11 Fixed false positive #5535: Reference named like its type. 2014-03-17 12:01:39 +01:00
Robert Reif 2ba3a36f2c Partial fix for #5555. Improved pure/const attributes handling 2014-03-14 19:06:05 +01:00
Daniel Marjamäki 8d8913a168 Partial fix for #5555. Add const,pure attributes to library. 2014-03-14 06:38:45 +01:00
Alexander Mai 50a184c3e9 Fixed #5166 (segmentation fault (invalid code) in lib/checkother.cpp:329 ( void * f { } void b ( ) { * f } )) 2014-02-27 18:24:51 +01:00
Daniel Marjamäki 8dd7f02e45 Fixed #5381 (Some false positives that came up when using --enable=performance file.c) 2014-02-23 11:02:39 +01:00
Daniel Marjamäki fdcb325d70 DuplicateBranch: Made warning inconclusive since it's in most cases noise 2014-02-16 11:04:27 +01:00
Daniel Marjamäki 23efc68dd7 use nullptr 2014-02-16 10:32:10 +01:00
Lucas Manuel Rodriguez 052840f8f5 Fixed #4818 (New check: Check memset() 2nd parameter) 2014-02-15 15:06:00 -03:00
Daniel Marjamäki fd3a8a2a18 Update copyright 2014-02-15 07:45:39 +01:00
Daniel Marjamäki 486a3192c0 Fixed #5246 (false positive: (warning) Logical conjunction always evaluates to false: t > 0 && t < 1.) 2014-02-04 06:50:29 +01:00
Tobias Weibel 9d55265e6b Replaced duplicated logf(2.0) with logf(2.0f) unittest 2014-01-23 16:19:30 +01:00
Daniel Marjamäki 30cae358d8 Removed the --value-flow flag. ValueFlow analysis will always be enabled from now on. 2014-01-17 18:07:05 +01:00
Daniel Marjamäki 3facc06cb7 CheckOther: Removed non-valueflow check for division by possible zero before condition 2014-01-17 17:42:54 +01:00
Daniel Marjamäki 0203a4a6f5 Tokenizer: Removed simplifyGoto as it's the cause of various FPs I see 2014-01-17 17:36:45 +01:00
Daniel Marjamäki 4eb746d7cc Tokenizer: Removed simplifyComparisonOrder 2014-01-17 17:25:56 +01:00
Daniel Marjamäki e3496080c8 Fixed #5334 (False positive: same expression on both sides of '||') 2014-01-12 07:40:56 +01:00
Daniel Marjamäki ceca6be22b Fixed #5334 (False positive: same expression on both sides of '||') 2014-01-11 15:15:01 +01:00
Daniel Marjamäki 9c50deda64 value flow: reverted TestOther, don't use value flow in test cases yet 2014-01-08 16:18:50 +01:00
Daniel Marjamäki 6d22c9deaa value flow: if unsigned variable is compared against 1 with either >= or <= then assume it can have the value 0 2014-01-08 06:53:17 +01:00
Daniel Marjamäki 372c29c24e Fixed #5284 (duplicateExpression falsely reported by members of a union in some circumstances) 2014-01-02 16:58:07 +01:00
PKEuS 6f76dfcb22 Forward declare tinyxml type used in library.h to avoid problems with dynamic linked configuration. 2013-12-31 12:30:17 +01:00
PKEuS 4f0121ee2f Splitted simplification out of tokenize() 2013-12-30 17:45:28 +01:00
Daniel Marjamäki 4b72f01e99 clarify calculation: Fixed FP for 'a = (*p ? 1 : 2)' 2013-12-28 11:02:39 +01:00
Daniel Marjamäki 4c44e62159 AST: Refactored CheckOther::clarifyCalculation 2013-12-24 10:07:20 +01:00
Daniel Marjamäki 042d3afb80 CheckOther::checkDuplicateExpression: Readded warnings when there is a expression between the duplicate expressions 'X || Y || X' 2013-12-24 07:21:46 +01:00
Daniel Marjamäki ac30a84c3a Refactoring: Replaced CheckOther::checkCCTypeFunctions with configuration 2013-12-23 19:58:33 +01:00
Daniel Marjamäki 76b907fe65 Fixed #5252 (Improve check: use Library to validate function arguments in invalidFunctionUsage) 2013-12-23 10:06:45 +01:00
Daniel Marjamäki fdcb6634df Fixed #5190 (FP Use const reference to avoid data copying) 2013-12-14 08:46:18 +01:00
Daniel Marjamäki 5ba02d2fdd AST: Always use AST 2013-12-09 18:06:19 +01:00
Daniel Marjamäki da540a3bb3 AST: Improved astIsFloat handling of expressions 2013-11-25 04:26:15 +01:00
Daniel Marjamäki abdf2bb9d4 AST: fixed isSameExpressions handling of ({..}) 2013-11-25 04:08:28 +01:00
Daniel Marjamäki 13cd0f41f6 AST: Fixed FP in isSameExpression when there are different casts 2013-11-24 15:17:08 +01:00
Daniel Marjamäki e8eeb90adb AST: Fixed 'same expression' false positives (git merge --squash s, <<, >>) 2013-11-20 16:18:09 +01:00
Daniel Marjamäki 27a40b10e1 AST/incorrectLogicOperator: Better handling of large doubles where x+1=>x 2013-11-20 06:33:34 +01:00
Daniel Marjamäki 033cb19656 Same expression: Don't write warnings for same expression on both sides of arithmetical operators 2013-11-17 17:21:39 +01:00
Daniel Marjamäki 5af2fe6e5b AST: improved 'incorrect logic' checking when there are nested expressions 2013-11-15 06:51:35 +01:00
Daniel Marjamäki d1721b9d1b AST: Improved 'same expression on both sides of operator' checking for nested operators 2013-11-15 06:35:46 +01:00
Daniel Marjamäki 203d3e916b Fixed #5173 (false positive Variable XX is reassigned a value before the old one has been used) 2013-11-14 16:10:00 +01:00
Daniel Marjamäki 1ecade2657 AST: don't warn about duplicate expressions around '+' operator. It might be more efficient than using for instance '*2' 2013-11-11 20:03:59 +01:00
Daniel Marjamäki 4027848761 incorrectLogicOperator: fixed FP when comparing char values. improved handling of float comparisons. 2013-11-10 18:06:51 +01:00
Daniel Marjamäki 807f62520c Fixed crash caused by endless recursion in redundant assignments check 2013-11-10 17:20:40 +01:00
Alexander Mai 687aeb4f5f Fixed #5158 (segmentation fault (valid code)) 2013-11-10 16:22:52 +01:00
Daniel Marjamäki cadb284a3d Refactored the AST checking of CheckOther::checkIncorrectLogicOperator() 2013-11-10 11:59:18 +01:00
Daniel Marjamäki b0ce42565e AST: Added experimental new implementations for CheckAssignIf::comparison, CheckOther::checkIncorrectLogicOperator and CheckOther::checkDuplicateExpression 2013-11-07 14:38:08 +01:00
Daniel Marjamäki fb04c8ff84 Fixed #5107 (redundantAssignment when pointer changes) 2013-11-04 23:46:07 +01:00
Daniel Marjamäki 06c5bd0daa Fixed #5128 (False positive zerodivcond 'a ? 1 / a : 0') 2013-10-30 16:51:00 +01:00
XhmikosR 32e2a5b879 test/testother.cpp: Fix a C4800 MSVC warning. 2013-10-25 18:14:16 +03:00
Daniel Marjamäki 364757e1e1 Fixed #5089 ('inconclusive' output printed although --inconclusive not specified) 2013-10-23 06:42:52 +02:00
Daniel Marjamäki d1b03d9c31 Fixed false positive for 'object is destroyed immediately' when there is no code after the object 2013-10-22 19:37:11 +02:00
Daniel Marjamäki a55056c770 Fixed #5105 (false positive: (warning) Either the condition 'b!=0' is useless or there is division by zero) 2013-10-22 16:18:42 +02:00
Daniel Marjamäki 5d7e0aebf4 Fixed #5084 (False positive: (style) Same expression on both sides of '&&') 2013-10-19 18:04:53 +02:00
Daniel Marjamäki 6aa03efa2f Fixed #5103 (Don't show 'The scope of the variable can be reduced' if there is no explicit block with { }) 2013-10-19 17:27:02 +02:00
Daniel Marjamäki 783bb6eb0b Test that there is no segfault in CheckOther::checkZeroDivisionOrUselessCondition when the SymbolDatabase is invalid. Ticket: #5045 2013-10-10 22:23:52 +02:00
orbitcowboy 6eaa2f2444 Tokenizer:simplifyMathFunctions: added support for acos[f|l] functions. 2013-10-09 07:59:32 -07:00
orbitcowboy 58c09f80b6 Testother: split up a large testfunction, no functional change. 2013-10-09 07:48:46 -07:00
Daniel Marjamäki 9ce7efc6e4 commaSeparatedReturn: made checking experimental for now because there are false positives (#5076) 2013-10-08 18:05:07 +02:00
Daniel Marjamäki 4cd0108b93 Fixed #4976 (False positive: (style) A pointer can not be negative (git/sha1_file.c)) 2013-10-06 16:52:27 +02:00
Daniel Marjamäki 973bdcc6d8 Fixed #4929 (false positive: Division by zero (standard function div())) 2013-09-29 11:13:49 +02:00
Martin Ettl 5aaaff46ee Fixed #5049: new check: (warning) Comparison of two identical variables with isgreater(result,result) evaluates always to false. 2013-09-26 07:07:48 +02:00
Daniel Marjamäki 17c0bb3cab revert 027e5cc8. the div() standard function should not be reimplemented. create a different fix. Ticket: #4929 2013-09-23 18:01:15 +02:00
Daniel Marjamäki 027e5cc860 Fixed #4929 (false positive: Division by zero (standard function div())) 2013-09-22 09:52:12 +02:00
Daniel Marjamäki 965d8f0ecc Fixed #5033 (segmentation fault (valid code) in CheckOther::checkZeroDivisionOrUselessCondition) 2013-09-21 17:44:25 +02:00
Daniel Marjamki 3de9431507 Fixed #5022 (Improve check: Division by zero or useless condition, function call) 2013-09-15 17:46:52 +02:00
Ettl Martin 5a671f8914 Fixed #5023 (Add support for asinf,acosf,asinl,acosl (...) functions) 2013-09-13 19:49:25 +02:00
Daniel Marjamäki 4b1254bc8d Merge pull request #168 from simartin/ticket_4994
Ticket #4994: Don't crash when checking variable scope for invalid input
2013-09-08 06:57:42 -07:00
Simon Martin 843833f907 Ticket #4994: Don't crash when checking variable scope for invalid input. 2013-09-07 21:16:25 +02:00
Daniel Marjamäki 6bb6506ce2 checkZeroDivisionOrUselessCondition: Fixed false positive when function is called and variable is passed to it 2013-09-07 16:18:11 +02:00
Daniel Marjamäki 83c460fc56 Fixed #5017 (New check: division by zero, otherwise condition is redundant) 2013-09-07 07:40:10 +02:00
Alexander Mai 7fc6b1344b Added testcases for #4801 (Cppcheck fails to parse Posix (crash in CheckOther::checkPipeParameterSize())) 2013-08-22 21:33:02 +02:00
Daniel Marjamäki 5d7f30b88f reassign var: better handling of struct members 2013-08-15 16:13:58 +02:00
PKEuS a9a5dc0354 Updated to AStyle 2.03, require this version 2013-08-07 16:27:37 +02:00
PKEuS dd82817752 Fixed #4943 and simplified CheckOther::checkCommaSeparatedReturn() 2013-08-06 11:27:09 -07:00
PKEuS 5e3ccda408 Added support for noreturn functions from library to CheckOther::checkUnreachableCode() 2013-08-06 02:11:59 -07:00
Alexander Mai 3e9f6daa00 Added test cases for #4801 (Cppcheck fails to parse Posix (crash in CheckOther::checkPipeParameterSize())) 2013-07-29 10:57:41 +02:00
Daniel Marjamäki 239a0819e3 astyle formatting 2013-07-28 13:17:46 +02:00
Simon Martin eb3bf571be Avoid divisions by zero when simplifying numeric calculations. 2013-07-28 12:32:18 +02:00
Alexander Mai 40fa474a5b Fixed #4927 (Segfault in CheckOther::checkCommaSeparatedReturn() on invalid code) 2013-07-28 10:39:58 +02:00
Daniel Marjamäki 178467a578 astyle formatting 2013-07-24 11:20:28 +02:00
Carlo Marcelo Arenas Belon aa0560fe3b Fixed #4925 (False positive: checkother style)
When using a variable that is assigned a function pointer checks for
pointers are triggered which would complain if used in arithmetic
comparisions (eventhough it will be valid code if the function returns
an int)
2013-07-24 08:22:24 +02:00
Lucas Manuel Rodriguez 7e556c215e Fixed #4861 (Improve check: object is destroyed immediately not detected when calling overloaded constructor) 2013-07-22 07:25:53 +02:00
Zachary Blair a381170886 Fixed #4874 (Minor spelling corrections) 2013-06-26 00:47:02 -07:00
Andreas Bießmann 9b3a8774c5 Test case for unreachableCode (#4756) 2013-06-18 06:40:43 +02:00
Daniel Marjamäki 2fb8133e90 Fixed #4862 (False positive: Comma is used in return statement (template)) 2013-06-18 00:13:45 +02:00
Abhishek Bharadwaj d85c8e6782 Fixed #4104 (New check: comma separated statements in return statement from a function) 2013-06-15 17:49:10 +02:00
PKEuS 4efccc2c5d Fixed #4420: Prefix increment is only suspicious, if its return value is not used. 2013-06-10 13:02:02 -07:00
Zachary Blair 28c0045f36 Fixed #4173: New check: arithmetical usage of inf/nan result 2013-06-09 23:13:08 -07:00
Frank Zingsheim d387e8b770 Fixed #4711: (false positive: Consecutive return...) 2013-05-11 17:50:59 +02:00
PKEuS fb480ebb0a Now really fixed #4604. 2013-05-09 15:39:33 +02:00
PKEuS 881b47e79d Revert "Improved handling of 0 initializations (#4604)"
This reverts commit 1201e417ec.
2013-05-09 15:32:02 +02:00
PKEuS 0a104c40b7 Fixed "Improved handling of 0 initializations (#4604)"
This fixes commit 1201e417ec.
2013-05-09 15:25:36 +02:00
PKEuS 982b9491d4 Improved handling of 0 initializations (#4604) 2013-05-09 06:23:25 -07:00
PKEuS c42b89fb88 Revert "Improved handling of 0 initializations (#4604)"
This reverts commit 1201e417ec.
2013-05-09 15:19:23 +02:00
PKEuS 1201e417ec Improved handling of 0 initializations (#4604) 2013-05-09 06:17:10 -07:00
Lena Herscheid e23038c4de Fixed #4775 (Check for assert() with side effects) 2013-05-07 21:35:16 +02:00
Daniel Marjamäki b2798e929d Improved fix for #4455, no false negatives if variable is used before first memset 2013-04-30 16:56:44 +02:00
Daniel Marjamäki 47ef8cf455 Fixed #4455 (redundantCopy when precleaning with memset) 2013-04-30 06:43:16 +02:00
Daniel Marjamki 9007345221 Simplified TestOther test cases 2013-04-13 20:17:53 +02:00
PKEuS 693c6e84cb Removed more duplicate unit tests 2013-04-13 01:49:17 -07:00
Ettl Martin e03a3946d0 avoid crash in checkother:wrongPipeParameterSize when a pointer with unknown size is provided. 2013-04-11 14:22:22 +02:00
PKEuS 994c429b7d Moved checks related to sizeof usage from checkother into new file 2013-04-10 09:49:38 -07:00
PKEuS 42fcb04d0c Moved checks related to boolean type (not condition checking!) from checkother into new file 2013-04-10 09:25:50 -07:00
PKEuS 4e6d105cbd Added support for complex patterns to CheckOther::checkIncorrectStringCompare() 2013-04-09 09:16:35 -07:00
XhmikosR 700512a53f use spaces in strings 2013-04-09 17:49:09 +02:00
Ettl Martin 08ac48199e #3103 added testcases. 2013-04-03 09:33:33 +02:00
XhmikosR a9955cce8e run astyle 2013-03-30 19:06:13 +01:00
PKEuS 37ac86dec9 Fixed #4666: Implemented proper variable scope checking for switch statements 2013-03-23 03:28:33 -07:00
Ettl Martin 1b9c1c03fa unittests: removed not needed '\n' at the end of testcases. 2013-03-20 15:36:16 +01:00
PKEuS d9f7042992 Fixed false negative #4663 2013-03-18 08:17:53 -07:00
PKEuS 1e66e0b931 Fixed false negative #4657 2013-03-15 05:00:51 -07:00
Daniel Marjamäki c0a34649c4 fixed 'duplicate expression' false positives for float-float. Ticket: #4639 2013-03-14 19:11:29 +01:00
Ettl Martin 3d1cdd0eec #4645 implemented correct range according manpage of usleep(). 2013-03-11 17:38:03 +01:00
Ettl Martin dde51f73ff removed wrong line of testcode (introduced by my last commit). 2013-03-11 17:20:41 +01:00
Ettl Martin bb115573f7 #4645 implemented new check: (POSIX) argument of function usleep() too big. 2013-03-11 17:04:30 +01:00
PKEuS 6eed6b3cf3 Partially reverted 657e5d7ea2 because of trigraph issue. 2013-03-05 01:21:59 -08:00
PKEuS 657e5d7ea2 Fixed some small formatting issues in test suite 2013-03-04 11:14:56 -08:00
Ettl Martin c9b519bcd1 improved check: checkCastIntToCharAndBack. The check now handles (cin.get() != EOF) patterns. 2013-03-04 14:25:35 +01:00
PKEuS 8a18f9ec3b Rewrote CheckOther::checkVariableScope() 2013-03-03 10:35:33 -08:00
PKEuS 5c1a05dcbe Refactorizations in CheckOther:
- Make CheckOther::checkCastIntToCharAndBack() work for multiple variables at once
- Improved messages of CheckOther::checkSuspiciousSemicolon() and CheckOther::checkPipeParameterSize()
2013-03-03 09:54:44 -08:00
PKEuS d78c06dc3f Replaced _settings->isEnabled("style") by _settings->isEnabled("warning") wherever warnings are issued 2013-03-03 02:41:59 -08:00
Ettl Martin 8d682233d0 Implemented new check (Ticket #160): Storing getc() retun value in char variable and comparing to EOF. 2013-02-27 21:02:12 +01:00
Daniel Marjamäki 1c584208b4 Fixed #4329 (False duplicateBranch when branches use conditionally defined macros) 2013-02-18 17:18:33 +01:00
Ettl Martin 73e2a8fdb5 Merge branch 'master' of github.com:danmar/cppcheck 2013-02-17 17:34:44 +01:00
Ettl Martin f451dd1137 #3521 implemented new check: wrong buffersize to pipe() function provided. 2013-02-17 17:33:32 +01:00
PKEuS 44887df04f Fixed false positive redundantAssignment when calling function in assignment (#4513) 2013-02-15 09:40:34 -08:00
PKEuS ccd95d1749 Make redundantAssignment message inconclusive when printed on global variables to avoid false warning on semaphores/mutexes (#4467) 2013-02-15 09:01:10 -08:00
PKEuS 017b4a8a7f Treat references like global variables in CheckOther::checkRedundantAssignment() as they might refer to such. (#4425) 2013-02-15 08:09:31 -08:00
Frank Zingsheim 213d31b360 Fixed #4547 (Improve check: Duplicate conditions in 'if' and related 'else { if'.)
Local fix in CheckOther::checkDuplicateIf()
2013-02-12 21:43:12 +01:00
Frank Zingsheim 75f69c11b7 Test for #4573 (False positive: variableScope within if/else if) 2013-02-12 21:16:57 +01:00
Daniel Marjamäki 1e550f9fdf Reverted fix for #4547: It causes fp. See #4573 2013-02-12 16:13:08 +01:00
Ettl Martin dade326a99 #4566 implemented new check: redundantGetAndSetUserId on posix systems 2013-02-11 20:26:27 +01:00
Andrew C. Martin bd0d9b9639 fix misspellings & gcc v3.4.6 warnings
1.  fix typos / misspellings
 - Fix misspelling within comments, variable/function names, stdout messages
 - changes the name of an error code: ```stlBoundries``` changed to ```stlBoundaries```.  Alias old name (```stlBoundries```) to the new one.

2.  fix gcc v3.4.6 32bit & 64bit warnings

 - fixes gcc v3.4.6 warnings, except for those in tinyxml and "-Wmissing-declarations" makefile warnings
 - in Preprocessor::handleIncludes(), replace a ```vector <bool>``` with ```stack<bool>``` (see ```vector<bool>``` warning below).
   - this is the only ```vector<bool>``` in the codebase
 - ```vector <bool>``` is actually a case of template specialization, and is not recommended, according to the following links:

http://stackoverflow.com/q/6461487
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2160.html
http://stackoverflow.com/q/670308

 - in the codebase before and after this change, testrunner SEGVs in a number of places on gcc v3.4.6, including ```Check::~Check()```, among others
   - fc42fc95 fixes this particular runtime issue for DJGPP & __sun
2013-02-09 23:43:09 -07:00
Frank Zingsheim b531195e08 Fixed #4547 (Improve check: Duplicate conditions in 'if' and related 'else { if'.)
Change tokenizer: "else if" -->> "else { if"
2013-02-04 21:12:12 +01:00
Daniel Marjamäki e2faed355b Fixed #4485 (False positive: Same expression of '-' when checking if float is inf) 2013-01-31 17:29:31 +01:00
Robert Reif 859793731d SymbolDatabase: Refactor findFunction handling. Ticket: #4494 2013-01-28 06:47:48 +01:00
Zachary Blair 8647e4c0d0 Fixed a false positive in #4109 (if (c == 1) c == 0; Isn't picked up) 2013-01-18 16:34:15 -08:00
Zachary Blair a1cbed3df8 Fixed #4109 (if (c == 1) c == 0; Isn't picked up) 2013-01-17 23:03:04 -08:00
rofl0r 623e30d677 fix unit test for varFuncNullUB 2013-01-15 20:45:53 +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 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
PKEuS 4737966caf Unit test cleanup: Removed some empty lines and whitespaces before \n. 2012-12-06 10:19:22 -08:00
Daniel Marjamäki bf91454136 Fixed #4224 (False positive: Comparison of a boolean with an integer (neglecting a cast)) 2012-12-02 08:34:30 +01:00
Edoardo Prezioso 47f1220367 Remove useless preprocessor pieces from some testcases. 2012-11-30 20:28:30 +01:00
Daniel Marjamäki 79cd601ae7 Fixed #4356 (False positive at variable initialization) 2012-11-15 07:48: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
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
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
Daniel Marjamäki 61183e7896 astyle formatting 2012-10-08 16:23:05 +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
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
Mohit Mate 9e297c95f2 Fixed #2617 (improve check: comparing boolean with '<') 2012-09-26 18:18:36 +02:00
XhmikosR 3c14e4b52a test: tabs to spaces, remove trailing spaces and extra empty lines at the end of files 2012-09-17 13:51:40 +02:00