Commit Graph

2863 Commits

Author SHA1 Message Date
Edoardo Prezioso 8afc1b6f2d Changed the name of the removal of dead code after flow control statements for consistency (simplifyDeadCode is too generalized as name) 2011-10-15 12:45:48 +02:00
Edoardo Prezioso 57ead6988e Fixed ticket #3138 (Tokenizer: remove unreachable code below goto inside a namespace|class|struct block) 2011-10-15 11:35:45 +02:00
Edoardo Prezioso f95b692a69 Fixed ticket #3113 (complete simplification of dead code after control flow statements) 2011-10-15 01:34:07 +02:00
Thomas Jarosch 7824e5c0f5 Fixed #3210 (STL check: Add support for reverse iterator) 2011-10-14 19:54:20 +02:00
Thomas Jarosch 7ae39f13cc Fixed #3198 (Add check for readlink()) 2011-10-14 19:45:51 +02:00
Jonathan Neuschäfer 4fb7865f49 fix typos using codespell
Codespell is available at http://git.profusion.mobi/cgit.cgi/lucas/codespell/.
2011-10-13 22:04:41 +02:00
Daniel Marjamäki 6f8e42a5af changed the astyle formatting flags 2011-10-13 20:53:06 +02:00
Edoardo Prezioso b792efb761 Fix ticket 3140 and 3137 (Improve Tokenizer: Remove dead for loop - simplify while(0) better.
Note: it doesn't remove dead code if there's a label inside. Will be improved in another ticket.
2011-10-13 13:01:24 +02:00
Edoardo Prezioso 16506f0a8c Remove redundant simplifyDeadCode call inside the Tokenizer::tokenize and move the relative tests in the file 'testsimplifytokens.cpp'. 2011-10-13 12:26:27 +02:00
Zachary Blair 82366918ff Fixed #2627 (switch case fall through: redundant strcpy) 2011-10-13 01:27:22 -07:00
PKEuS 91d7621994 Fixed #3180 (New check: Detect nullpointers given to printf via variable argument list) 2011-10-12 22:11:27 +02:00
Daniel Marjamäki 74c0468a18 astyle formatting 2011-10-12 22:06:19 +02:00
Daniel Marjamäki b73896bcc5 Fixed #3163 (Out of bounds pointer arithmetic not reset) 2011-10-12 20:54:39 +02:00
Daniel Marjamäki 371871b0b7 Tokenizer::removeMacrosInGlobalScope: Don't remove C/C++ keywords namespace/struct/etc. Ticket: #3193 2011-10-12 19:23:39 +02:00
Daniel Marjamäki cf39ece8da Fixed #3150 (Invalid warning when pointer difference is not adjacent) 2011-10-12 19:01:44 +02:00
Robert Reif ee04c1bfb7 fix #3194 (Parsing glitch causes false 'can be const' error for an 'if' statement) 2011-10-12 09:10:34 -04:00
Robert Reif af6a6f9c2d run astyle 2011-10-12 09:08:54 -04:00
Marek Zmysłowski 07d8cd0a12 improved realloc checking '*p = realloc(*p,..'. Ticket: #1791 2011-10-11 22:07:14 +02: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
Edoardo Prezioso 742858b67c Fixed some simple errors in some old commits. 2011-10-10 17:18:47 +02:00
Edoardo Prezioso af23a9dcbb Fixed ticket #3140 (Improve Tokenizer: Remove dead for loop 'for (int i = 0; i < 0; ++i)') 2011-10-10 15:15:45 +02: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 96beb94b21 Fixed #3183 (False positive: (error) syntax error) 2011-10-09 18:42:36 +02:00
Daniel Marjamäki 175503ef94 Null pointer: improved inconclusive checking in CheckNullPointer::nullPointerAfterLoop 2011-10-09 15:09:02 +02:00
seb777 1d9a99012b Fixed 3133 (Improve Check: Found obsolete function)
- add check for std::gets
- improve check when multiple obsolete functions are used
- remove false positive (declared functions)
2011-10-09 10:31:21 +02:00
Edoardo Prezioso 9270b84d64 More fixes to the label simplifier (related to ticket 3176):
1)Simplify the labels if there are combinations of the symbols '*','&','{' and '(' after a '%var% :' and before another '%var%';
2)but do not simplify the label if it's inside an unpreprocessed macro code.
2011-10-08 21:13:53 +02:00
Daniel Marjamäki 0b09732881 Null pointers: fixed false negatives when there are '(p && ..' 2011-10-08 12:58:10 +02:00
Stefan Weil bf25340fd3 Settings: add missing initialisation for member variable c99 (reported by Valgrind) 2011-10-08 10:29:11 +02:00
Daniel Marjamäki 5c08979920 1.51: Updated versions 2011-10-08 07:45:39 +02:00
Daniel Marjamäki 37d4a01dcb Added todo comments to fix false negatives caused by my fix for #3128 2011-10-08 07:39:20 +02:00
Daniel Marjamäki e2ec5a127f Fixed #3128 (False positive: null pointer dereference check does not handle complex boolean logic properly) 2011-10-07 21:08:21 +02:00
Robert Reif a1a839fadc fix tokenizer and symbol database to not mistake goto statement for variable declaration 2011-10-07 08:11:48 -04:00
Robert Reif 7dd001c9a9 run astyle 2011-10-06 21:10:20 -04:00
Edoardo Prezioso 80df7ea839 Fixed ticket #3176 (cppcheck reports wrong unused variable)
Label simplification didn't take count of the '(' parenthesis or the '&' and '*' operators inside or outside the parenthesis after the colon.
2011-10-07 00:54:44 +02:00
Edoardo Prezioso fe4ce594ce Renamed the function 'removeRedundantCodeAfterReturn' with 'simplifyDeadCode'.
This is a preparation in order to add new features to this function (see the @todo in the tokenize header file, ticket #3113 and #3175 for details).
2011-10-06 22:40:39 +02:00
Daniel Marjamäki 73fb6725e6 Readded CheckOther::bitwiseOnBoolean as inconclusive check 2011-10-06 22:01:48 +02:00
Marek Zmysłowski 307dd00efb Fixed #3072 (improve check: deprecated function alloca) 2011-10-06 08:10:51 +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
Thomas Jarosch abd2525339 Fixed #3161 (Show buffers size info for snprintf() buffer overruns) 2011-10-05 20:17:57 +02:00
Edoardo Prezioso d741f64256 Merge branch 'master' of github.com:danmar/cppcheck 2011-10-05 19:52:49 +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
Edoardo Prezioso 8e90ad106c Fixed ticket #3148 (Analysis failed on "Modules/mathmodule.c")
Fix: Do not handle code when 'return' is inside a macro. This is valid also for 'switch' code inside a macro.
2011-10-05 19:33:46 +02:00
Edoardo Prezioso 3c370dcfdf Fixed #3146 "Analysis failed" error on softmagic.c:
-Fixed: the code didn't check the rightness of the switch syntax if it was inside another switch;
-Tweaked: removed the two bool variables, so now the conditions take count of indentation unsigned variables.
2011-10-04 12:16:39 +02:00
Edoardo Prezioso bc74213036 Fixed #3132 (Analysis failed. If the code is valid then please report this failure.) 2011-10-03 19:38:37 +02:00
Daniel Marjamäki 417dc1ff2a Fixed #3159 (Uninitialized variable false positive) 2011-10-02 20:38:58 +02:00
Daniel Marjamäki 480c403511 Fixed #3125 (FP: Possible null pointer dereference in conditional operator) 2011-10-02 19:27:18 +02:00
Daniel Marjamäki b2d0e48a31 Fixed #3126 (false positive: Null pointer dereference) 2011-10-02 18:24:45 +02:00
Robert Reif 65b0fb4519 fix #3153 (false positive buffer access out-of-bounds) 2011-09-30 17:28:59 -04:00
Robert Reif 272783347b another variation of false negative from #3149 2011-09-30 16:26:08 -04:00
Stefan Weil 2193572c9e test _WIN64 before _WIN32 (64-bit compiler defines both macros) 2011-09-30 14:12:44 -04:00
Robert Reif 1dcb8b2382 really fix #3149 (false negative: Technically the member function 'A::f' can be const.) 2011-09-30 11:16:34 -04:00
Robert Reif 556d523e4f fix #3149 (false negative: Technically the member function 'A::f' can be const.) 2011-09-29 20:16:52 -04:00
Robert Reif ac942c6684 fix #3151 (missing portability warning for extra qualifier on destructor) 2011-09-29 19:25:14 -04:00
Robert Reif 092ba0b1de fix symbol database bug where function variable type of a nested class was not found 2011-09-28 22:05:26 -04:00
Reijo Tomperi 236d0eb178 Fix #2813 (False negative: Uninitialized variable not found for realloc)
http://sourceforge.net/apps/trac/cppcheck/ticket/2813
Patch provided by: marekzmyslowski
2011-09-28 21:46:09 +03:00
Robert Reif 9994218aa2 refactor last commit to move unknown type output to seperate function 2011-09-28 07:36:48 -04:00
Robert Reif 989235b509 show unknown variable types when debug-messages flag is set 2011-09-27 21:45:06 -04:00
Robert Reif 540207533b fix #3008 (New check: Order of initialisation list) 2011-09-27 21:07:37 -04:00
Robert Reif 44a926aa4d add a few more Microsoft TCHAR function conversions 2011-09-27 07:29:36 -04:00
Robert Reif ec377d24eb add support for Microsoft TCHAR character constants 2011-09-26 22:08:24 -04:00
Robert Reif 2d717d77cd reduce false negatives for checking for CheckOther::checkSignOfUnsignedVariable() 2011-09-26 21:24:34 -04:00
Robert Reif 6e8bf43dc0 add some Windows TCHAR scanf and printf conversions 2011-09-25 10:02:27 -04:00
Robert Reif 545aa9e55b start adding Windows wide character support 2011-09-24 16:02:56 -04:00
Robert Reif f97424b242 start adding Windows ASCII TCHAR conversion support 2011-09-24 14:51:03 -04:00
seb777 424f349b88 fix #3121 ([False Positive] Incorrect obsoleted functions) 2011-09-24 10:54:58 +02:00
Robert Reif a685f1f5b7 add operator support to ertra qualification check 2011-09-23 19:45:19 -04:00
Robert Reif ac070b90f2 fix for loop false positives when zero length arrays present 2011-09-22 21:23:40 -04:00
Robert Reif 97d4277854 add Microsoft memory function conversions to standard cstring functions 2011-09-22 19:59:56 -04:00
Robert Reif 1dc7c0edf9 fix #3127 ([False positive] _tmain function i VS 2010 project) 2011-09-21 20:16:20 -04:00
Robert Reif 4d1dda10fa add some more windows type conversions 2011-09-20 20:17:02 -04:00
Daniel Marjamäki 1a7511ed48 Fixed #3106 (False positive: Uninitialized variable check has inconsistent behavior with ternary operator) 2011-09-20 21:00:05 +02:00
Johan Samuelson 889c407f58 Fixed #3118 (Tokenizer: str*cmp() in hot spot code) 2011-09-20 19:03:19 +02:00
Robert Reif af5272dfb0 only simplify Microsoft MFC code when Windows platform is selected 2011-09-20 07:20:37 -04:00
Robert Reif e234e8cc5b add some common windows pointer type conversions to standard types 2011-09-19 23:14:58 -04:00
Robert Reif b349d36c50 fix #3124 (FP: Buffer access out-of-bounds when memset two dimension array (a[5][6])) 2011-09-19 20:32:50 -04:00
Robert Reif 2fe182b833 set windows platform type to type executable was compiled on 2011-09-18 13:19:00 -04:00
Robert Reif be660003ec start adding conversions from common Windows types to standard types 2011-09-18 13:06:54 -04:00
Robert Reif 958a53eaa8 run astyle 2011-09-18 12:58:28 -04:00
Daniel Marjamäki 96a04eee9c Merge pull request #35 from simartin/ticket_3059
Ticket 3059: Report the correct line number in unused functions warnings
2011-09-18 08:15:28 -07:00
Robert Reif 66eb37c135 convert size_t to standard type 2011-09-18 10:31:31 -04:00
Robert Reif 3e35ea0972 fix sizeof long double for unix64 for #2888 (Allow defining sizes of base types) 2011-09-18 08:40:08 -04:00
Simon Martin b493e4bf7b Ticket 3059: Report the correct line number in unused functions warnings 2011-09-18 07:13:39 +02:00
Robert Reif b5d22fda0d fix #2888 (Allow defining sizes of base types) 2011-09-17 19:40:52 -04:00
Robert Reif 1717bda382 fix wrong information about constness of function 2011-09-16 18:07:25 -04:00
Robert Reif cce4303f28 fix a problem with Qt slots immediately followed by signals 2011-09-16 16:59:43 -04:00
Robert Reif 2670525b4f better fix for #3114 (infinite recursion when operator= is overloaded) 2011-09-14 19:58:11 -04:00
Robert Reif 2bc7da2c64 quick fix for #3114 (infinite recursion when operator= is overloaded) 2011-09-14 19:04:06 -04:00
Edoardo Prezioso 1ff7410f4f Fixed #3075 (False positive => Improve tokenizer: remove redundant code after a 'return' state) 2011-09-13 07:55:47 +02: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
Robert Reif 3f517b5f23 partial fix for #2960 (false negative: buffer access out of bounds) 2011-09-11 21:51:05 -04:00
Robert Reif 40009d091d add multi-dimension array support to second checkScope and use it for member arrays 2011-09-11 20:42:57 -04:00
Robert Reif 0d6592dd2e use correct checkScope function in CheckBufferOverrun for single dimension member arrays 2011-09-11 19:21:13 -04:00
Robert Reif 19928e26d1 refactor to unify functionally identical code in CheckBufferOverrun::checkScope() 2011-09-11 14:00:53 -04:00
Robert Reif e18fe56d56 refactor CheckBufferOverrun to only use multi-dimension array error messages and remove single dimension array message 2011-09-11 09:54:26 -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
Daniel Marjamäki 9a97fbe022 Fixed #3104 (unread despite modified and used in IF statement) 2011-09-11 08:19:35 +02:00
Daniel Marjamäki d93354a974 unused var: use 'else if' instead of 'if' 2011-09-11 08:18:32 +02:00
seb777 8ed0e3a239 Revert "The case statement requires constant-expression (C, C++, C# and Java."
This reverts commit 5879fe419d.
2011-09-11 00:44:40 +02:00
seb777 5879fe419d The case statement requires constant-expression (C, C++, C# and Java.
Needless to simplify the calculation of a piece of code that can not compile.
2011-09-10 17:28:32 +02:00
Robert Reif a9b4e21f60 refactor CheckBufferOverrun::checkScope to take an ArrayInfo parameter 2011-09-10 11:21:52 -04:00
Robert Reif 794fdd056b Merge branch 'master' of github.com:danmar/cppcheck 2011-09-10 10:14:49 -04:00
Robert Reif 547a79d4fe calculate array size for variable length structures with array at end in CheckBufferOverrun::checkStructVariable() when possible 2011-09-10 10:14:32 -04:00
Philipp Kloke 2f62d180fe Fixed #1740 (Undefined Behavior: Divide by zero) 2011-09-10 16:12:53 +02:00
seb777 08efad13b2 fix #3093 (Simplify code (math expression) with keywords 'return' and 'case') 2011-09-10 13:28:54 +02:00
Robert Reif b0eab2587d better detection of variable sized structure in CheckBufferOverrun::checkStructVariable() 2011-09-09 08:37:24 -04:00
Robert Reif 27bfa2a346 fix some CheckBufferOverrun::checkStructVariable() flase negatives for possible variable length structs 2011-09-09 07:46:06 -04:00
Robert Reif 4a71693e0c Merge branch 'master' of github.com:danmar/cppcheck 2011-09-09 07:16:55 -04:00
Robert Reif 16924c7c7a fix #3094 (Buffer access out-of-bounds in struct variable) 2011-09-09 07:16:39 -04:00
Daniel Marjamäki 84f190abf7 Fixed #3096 (false negative: memory leak not found when passing string to strtok) 2011-09-09 07:25:47 +02:00
Robert Reif 812a17f294 fix one of the TODO testcases added for #3094 (Buffer access out-of-bounds in struct variable) 2011-09-08 22:44:25 -04:00
Daniel Marjamäki d10822ea11 fixed a few doxygen warnings 2011-09-08 18:28:05 +02:00
Daniel Marjamäki 184e0550b8 updated comments 2011-09-08 18:23:25 +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 cbbdd55177 fix some -Wconversion -Wsign-conversion warnings in checkbufferoverrun.cpp 2011-09-05 19:02:26 -04:00
Robert Reif 7451c5cece warn when buffer is not zero terminated after memmove 2011-09-05 15:59:41 -04:00
Robert Reif f5d71d1ac5 warn when buffer is not zero terminated after memcpy 2011-09-05 15:41:37 -04:00
Robert Reif 3c8988e7a5 warn when buffer is not zero terminated after strncpy 2011-09-05 15:19:38 -04:00
Daniel Marjamäki 2601733ff7 Uninitialized vars: handle printf a little better. Ticket: #3050 2011-09-05 20:18:58 +02:00
Daniel Marjamäki c7d0beefa8 uninitstring: fix false negatives when non-zero memset is used. Ticket: #3050 2011-09-05 19:42:48 +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
Robert Reif fe85b8779e fix #2528 (false negative: buffer access out of bounds) 2011-09-04 21:39:52 -04:00
Robert Reif 50688b28fd fix #2889 (false negative: buffer access out of bounds on local struct member) 2011-09-04 19:54:57 -04:00
Daniel Marjamäki 8240422a09 Fixed #3078 (vector::at using int causes false positive) 2011-09-04 20:48:05 +02:00
Daniel Marjamäki c34b77cebf Fixed #3073 (False positive: Assigning an integer (int/long/etc) to a pointer is not portable) 2011-09-04 13:03:29 +02:00
Daniel Marjamäki 85d83d86ac Fixed #3060 (False positive: Uninitialized variable: fresh) 2011-09-04 12:53:53 +02:00
Robert Reif e782d98241 final fix for #3063 (false negative: multi dimensional arrays not well supported) 2011-09-03 21:51:00 -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 46b5d5bd00 Fixed #3069 (False positive: Memory leak: data) 2011-09-03 20:45:48 +02:00
Daniel Marjamäki d098ed6031 Fixed #3065 (False positive: possible null pointer dereference: vi) 2011-09-03 19:43:27 +02:00
Daniel Marjamäki c7886ca1c4 Fixed #3058 (False positive: Uninitialized variable: data) 2011-09-03 18:53:14 +02:00
Robert Reif 7cb5c97e7d move member variable lookup code from a check to the symbol database so it can be reused by other checks 2011-09-03 12:22:13 -04: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 d749e28dc0 another partial fix for #3063 (false negative: multi dimensional arrays not well supported) 2011-09-02 21:07:29 -04:00
Robert Reif d85410de8c partial fix for #3063 (false negative: multi dimensional arrays not well supported) 2011-09-02 19:35:09 -04: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 e19cbf0cdd fix false positive introduced by previous false negative fix commit 2011-09-02 10:39:04 -04:00
Robert Reif 833865e736 fix #3066 (False positive: Inconclusive: Assigning address of local auto-variable to a function parameter.) 2011-09-01 22:22:33 -04:00
Robert Reif 5bad978833 fix line number in messagex for CheckAutoVariables::autoVariables 2011-09-01 20:34:31 -04:00
Robert Reif f4e07c3179 fix #3070 (Other: failed to parse a typedef string. Check continues anyway.) 2011-09-01 19:10:58 -04:00
Robert Reif 2667e34a07 fix again #3064 (false negative: returning address of stack variable) 2011-09-01 18:30:49 -04:00
Robert Reif ff690abf80 better error message for #3064 (false negative: returning address of stack variable) 2011-09-01 07:10:11 -04:00
Robert Reif e7dc765ece fix #3064 (false negative: returning address of stack variable) 2011-08-31 21:36:31 -04:00
Daniel Marjamäki a96028b43b Fixed #3058 (False positive: Uninitialized variable: data) 2011-08-31 19:45:20 +02:00
Robert Reif 477d1e92c9 add new (nothrow) support to CheckUnusedVar::checkFunctionVariableUsage 2011-08-31 06:39:39 -04:00
Robert Reif acebc635b5 add support for deallocating memory with realloc 2011-08-30 23:42:11 -04:00
Daniel Marjamäki 0529654e37 Fixed #3058 (False positive: Uninitialized variable: data) 2011-08-30 19:13:04 +02:00
Daniel Marjamäki ef30da51bf Fixed #3034 (Cppcheck crash on specific file (truecrypt).) 2011-08-29 19:16:52 +02:00