Commit Graph

2568 Commits

Author SHA1 Message Date
Daniel Marjamäki a6740200cf Null pointer: Added check for 'if (fred); return fred->a;' 2011-07-25 21:58:00 +02:00
Daniel Marjamäki 6e14da7eba Fixed #2812 (false negative: null pointer dereference when returning struct member) 2011-07-25 21:40:32 +02:00
Daniel Marjamäki 63a0c6ad4a Fixed #2796 (uninitialized and leaving scope) 2011-07-25 16:35:30 +02:00
Daniel Marjamäki 2c6e4c423a Fixed #2681 (False negative: Possible null pointer dereference) 2011-07-25 15:45:00 +02:00
Daniel Marjamäki c1138cf7f9 Fixed #2941 (False positive: unused function (individual checking of files)) 2011-07-25 13:25:09 +02:00
Daniel Marjamäki 9a3f95613a Uninitialized variables: Fixed false positive if there is assignment in return statement 2011-07-24 22:41:40 +02:00
Daniel Marjamäki 1bb7a1c23c Fixed #2938 (Uninitialized variable not detected when part of expression) 2011-07-24 22:26:11 +02:00
Simon Martin 7346d07871 Fix GCC warning about float comparison. Ticket: #2936 2011-07-24 21:35:21 +02:00
Robert Reif 9a4447c835 add support for unused const local variables 2011-07-24 12:09:59 -04:00
Daniel Marjamäki 4e6800c474 Fixed #2921 (False positive: Memory leak with static pointer) 2011-07-24 16:08:29 +02:00
Daniel Marjamäki 1ce261e44d astyle formatting 2011-07-24 14:54:13 +02:00
Daniel Marjamäki 158fa25623 Fixed #2817 (valgrind errors in simplifyTemplate when running tests) 2011-07-24 13:32:54 +02:00
Simon Martin 539c2e5acb Fixed #2932 (segmentation fault of cppcheck ( i / i )) 2011-07-24 09:06:38 +02:00
Simon Martin fc0f75fe6a Preprocessor: Fix #if0 #elif todo test case. Ticket: #2619 2011-07-24 08:54:24 +02:00
Robert Reif aa65eed02b convert CheckPostfixOperator::postfixOperator() to use the symbol database 2011-07-23 15:14:15 -04:00
Robert Reif 5e1fd81ea7 add support for local variables with constructors to the symbol database 2011-07-23 15:12:30 -04:00
Robert Reif e332f0c186 Merge branch 'master' of github.com:danmar/cppcheck 2011-07-22 08:32:08 -04:00
Robert Reif 527c1aae33 fix #2931 (another false negative in auto variables checking when function parameter is a struct) 2011-07-22 08:31:31 -04:00
Daniel Marjamäki 0dd5472642 Tokenizer::simplifyFunctionPointer: don't simplify function call. Ticket: #2873 2011-07-22 07:58:53 +02:00
Robert Reif 84ca1902a5 fix #1514 (Improve CheckAutoVariables: assign autovariable address to effective parameter) 2011-07-21 22:37:36 -04:00
Robert Reif 4e64d35462 fix #2926 (false negative in auto variables checking when function parameter is a struct) 2011-07-21 22:26:42 -04:00
Robert Reif c3c3eb74e8 fix #2929 (Additional Unused variable check) 2011-07-21 18:37:37 -04:00
Robert Reif cc1ecccd01 fix #2928 (False positive (static variable misinterpreted as auto variable)) 2011-07-21 18:20:19 -04:00
Daniel Marjamäki fb3870071a Fixed #2885 (crash of cppcheck while checking gcc-testsuite) 2011-07-21 16:13:35 +02:00
Daniel Marjamäki 31e3844f3f Fixed #2856 (--errorlist not printing all auto-variable errors) 2011-07-21 14:50:38 +02:00
Daniel Marjamäki d34a778848 Fixed #2848 (False positive: Memory leak when assigning and freeing from another struct) 2011-07-21 13:33:20 +02:00
Daniel Marjamäki 9f22d2fc6b Fixed #2897 (out of bounds false positive, using reinterpret_cast) 2011-07-21 09:32:24 +02:00
Robert Reif 32f94a47cc fix #2925 (False negative: auto variables - assigning address of array to function parameter) 2011-07-20 19:02:54 -04:00
Daniel Marjamäki 7e7f6eecf5 Fixed #2794 (Improper hanling of preprocessor directives #if defined) 2011-07-20 23:50:57 +02:00
Daniel Marjamäki f0a7cc5961 Merge pull request #28 from bwy/master
Fix "auto_ptr assignment" false positive
2011-07-20 10:45:49 -07:00
Benjamin Wolsey e6d8f3fb73 Fix tested auto_ptr false positive. 2011-07-20 19:17:59 +02:00
Daniel Marjamäki 5ea79677a3 Fixed #2924 (Unable to turn on unused function detection from command line) 2011-07-20 11:12:08 +02:00
Daniel Marjamäki 6ce5107e49 Tokenizer: Better handling of constants. Related with #2920 2011-07-20 09:07:47 +02:00
Daniel Marjamäki 3cfef6285c Fixed #2920 (False positive: Array 'arr[0]' index 0 out of bounds (array size and index are unknown)) 2011-07-20 07:57:42 +02:00
Daniel Marjamäki b66e6e73db Fixed #2917 (Problem with || in #if) 2011-07-18 21:44:23 +02: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
Daniel Marjamäki 7dcb68f5a4 CheckBufferOverrun: Detect overflows when buffer is allocated with alloca 2011-07-17 09:35:51 +02: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
Daniel Marjamäki 35938e74ad Tokenizer: better handling of 'struct AB ab; sizeof(ab)' 2011-07-16 22:07:30 +02:00
Daniel Marjamäki cf3ab649fb Fixed #2873 (segmentation fault of cppcheck while scanning rose-compiler suite) 2011-07-16 19:26:11 +02:00
Daniel Marjamäki 597733bec4 Tokenizer: minor update to handle C# code better 2011-07-16 18:12:55 +02:00
Daniel Marjamäki 35178cc161 Fixed #2912 (false positive: (portability) Assigning an integer (int/long/etc) to a pointer is not portable) 2011-07-16 17:08:03 +02:00
Daniel Marjamäki c55b0ff651 Fixed #2871 (Define in source not set when -D is used) 2011-07-16 16:59:06 +02:00
Daniel Marjamäki c299d02dba astyle formatting 2011-07-16 09:32:35 +02:00
Daniel Marjamäki 07a1222ac6 Preprocessor: fix handling of (1&&2) condition 2011-07-16 09:24:27 +02:00
Daniel Marjamäki 274fd2b985 Tokenizer: Fix minor problem with 'X&&Y' 2011-07-15 19:37:39 +02:00
Daniel Marjamäki d78d8660ab astyle formatting 2011-07-15 19:02:16 +02:00
John Smits 7f2d62cbde Fixed #2882 (One-character token can be mistaken for a multiCompare) 2011-07-15 19:01:36 +02:00
Robert Reif af1e51f648 fix some more false negatives for #2904 (Memory leak not detected when creating a new class instance) 2011-07-14 20:45:27 -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 66d145ba1c Fixed #2892 (false positive: (portability) Assigning an address value to the integer (int/long/etc) type is not portable) 2011-07-07 15:14:33 +02:00
Daniel Marjamäki 4055b0ec5f 64-bit portability: fixed two of the TODO test cases. Ticket: #2791 2011-07-06 17:57:39 +02:00
Daniel Marjamäki 827fb01ec1 updated error message about assigning address to integer. Thanks Kimmo for the suggestion. 2011-07-06 12:57:45 +02:00
Daniel Marjamäki 8f0f184058 64-bit checking: Added simple check for assigning pointer address to int/long. Ticket: #2791 2011-07-06 08:55:17 +02: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
Daniel Marjamäki 982b645ff4 Fixed #2775 (Uninitialized variable: Not detected when uninitialized struct pointer is dereferenced in sub function) 2011-07-04 21:04:32 +02:00
Robert Reif b143b283e9 fix #2886 (crash of cppcheck ( typedef struct x { } )) 2011-07-03 10:50:15 -04:00
Robert Reif 8ec1dfacbf fix missing pop in Tokenizer::simplifyStructDecl() when anonymous struct/union removed 2011-07-03 08:14:51 -04:00
Robert Reif b32b2c6d87 add support for checking unused std::string local variables 2011-07-02 19:25:10 -04:00
Robert Reif 3f4cc5fa3a add class A {} a; -> class A {}; A a; conversion capability to Tokenizer::simplifyStructDecl() 2011-07-02 09:21:30 -04:00
Robert Reif d447e61b09 fix #2884 (Integer overflow warning in 64-bit build) 2011-07-01 16:59:17 -04:00
Daniel Marjamäki db4a28d60b Tokenizer::simplifyGoto: Only simplify the last label in the function. If there are many labels in the same function and all labels are simplified, this function becomes very slow. 2011-07-01 18:07:41 +02: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
Reijo Tomperi 6d4799e0b8 Minor cleanup related to previous fix.
This code should not be needed anymore as tokenizer should simplify question mark away.
2011-06-30 22:10:17 +03:00
Reijo Tomperi 89fd5bacf9 Fix #2849, False positive: memory leak (using question mark operator)
http://sourceforge.net/apps/trac/cppcheck/ticket/2849
Simplify: *d = b ? b : a; into if-else
Simplify { ; { ; } } into { ; }
Removed one memleak test which should be redundant now as question marks
should not get into memleak check.
2011-06-30 22:04:26 +03:00
Daniel Marjamäki 6375e1d3dc Fixed #2849 (False positive: memory leak (using question mark operator)) 2011-06-30 17:31:22 +02:00
Robert Reif 77859b9a0f fix #2878 (derived global class not tokenized properly (class A : ::B { };)) 2011-06-30 07:25:36 -04:00
Robert Reif 586fdd24f2 fix #2825 (missing varid on class variables when multiple inheritance is used) 2011-06-29 20:04:04 -04:00
Robert Reif c99a15516d fix symbol database derived template class support 2011-06-29 19:52:07 -04:00
Robert Reif 18369ea6ac add global namespace derived class support 2011-06-29 19:43:39 -04:00
Robert Reif 443dd4c392 partial fix for #2867 handle derived class 2011-06-29 19:39:19 -04:00
Kimmo Varis 7af920a70b Document that Path::simplifyPath() needs / as separators. 2011-06-29 21:44:53 +03:00
Daniel Marjamäki d76861270a Fixed #2797 (Inline suppressions do not handle filenames correctly) 2011-06-29 20:23:39 +02:00
Daniel Marjamäki cacca00080 Fixed #2855 (False positive: resource leak when reusing fd) 2011-06-29 20:00:21 +02:00
Daniel Marjamäki e597ad72e7 Fixed #2841 (False positive: Array index out of bounds, can't compare ints to chars) 2011-06-29 18:44:05 +02:00
Robert Reif 6eecab5d73 fix #2807 (Wrong handling of function references when prefixed with &) 2011-06-29 07:19:34 -04:00
Robert Reif 1286898fa0 fix #2864 (--errorlist missing errors: variableHidingTypedef and Extra qualification) 2011-06-28 21:46:54 -04:00
Robert Reif f403de7bad partial fix for #2867 Tokenizer::removeRedundantAssignment didn't understand function local class and removed class variable 2011-06-28 19:48:28 -04:00
Robert Reif 70a32fc245 fix #2875 (segmentation fault of cppcheck ( 0; (a) < (a) )) 2011-06-28 18:47:18 -04:00
Robert Reif 272eb445fb fix #2865 (segmentation fault of cppcheck ( char a[1] )) 2011-06-27 07:31:10 -04:00
Robert Reif 1713eeb532 fix #2859 (Extra qualification not detected) 2011-06-26 21:13:29 -04:00
Reijo Tomperi 918b4d859f Fixed #2860, False positive: Returning value of strncat() reported as memory leak
http://sourceforge.net/apps/trac/cppcheck/ticket/2860
2011-06-26 23:53:16 +03:00
Reijo Tomperi 382520ee9f Fix #2840, False positive: Null pointer dereference
http://sourceforge.net/apps/trac/cppcheck/ticket/2840
2011-06-26 22:46:33 +03:00
Robert Reif 93495613dd replace some pattern matching with variable lookup in checkGlobalAndLocalVariable 2011-06-24 08:02:41 -04:00
Robert Reif 4656eba34c set symbol database array variable dimensions specified by a variable to the maximum size that variable can hold 2011-06-23 22:35:15 -04:00
Robert Reif 65ecbfd4ff fix an off by 1 error introduced in 48e6ea271a that prevented checking all variables 2011-06-23 22:31:16 -04:00
Daniel Marjamäki 40a14736b7 Added TODO test case for the simplifyKnownVariables to better simplify local variables 2011-06-23 17:03:14 +02:00
Daniel Marjamäki 2d1b7285d2 Fixed #2815 (FP: Null pointer dereference error about a member) 2011-06-23 16:58:01 +02:00
Robert Reif a87fb388e3 use symbol database to lookup variable type for buffer overrun checks 2011-06-22 23:11:17 -04:00
Robert Reif 48e6ea271a start using symbol database array info for buffer overrun checks 2011-06-22 22:44:11 -04:00
Robert Reif 0c46f44e3d add array information to symbol database 2011-06-22 22:41:11 -04:00
Robert Reif dac826d0ac use a more conventional technique for accessing ArrayInfo private variables 2011-06-22 20:35:58 -04:00
Reijo Tomperi 5a72bed064 Fix #2847, cppcheck hangs with 100% cpu load
http://sourceforge.net/apps/trac/cppcheck/ticket/2847
2011-06-22 14:09:42 +03:00
Daniel Marjamäki e4f6d4c987 Fixed #2808 (False positive 'Possible null pointer dereference') 2011-06-21 18:45:30 +02:00
Robert Reif db39f4364e fix #2845 (segmentation fault of cppcheck) 2011-06-21 07:31:55 -04:00
seb777 172903cde4 fix 2846 (false positive for auto_ptr check with container element) 2011-06-20 23:02:05 +02:00
Daniel Marjamäki 47a15b6486 Fixed #2830 (false positive: resource leak when using fdopen) 2011-06-20 18:42:13 +02:00
Robert Reif d80a55267c fix #2844 fix to generate correct output 2011-06-19 20:19:16 -04:00
Robert Reif 0bd26a73c4 fix #2844 (typedef causes 'syntax error') 2011-06-19 17:57:01 -04:00
seb777 20de3f90ef fix 2838 (Token::Match called with varid 0 on auto_ptr check) cleanup code and better check varid 2011-06-17 21:09:27 +02:00
seb777 5b940c0c7f fix #747 and #748 (incorrect use of auto_ptr - new check) 2011-06-16 20:26:00 +02:00
Robert Reif eaf836b323 fix extra qualification check for same class name in different namespaces 2011-06-14 15:31:52 -04:00
Lauri Nurmi be57aa5ad5 Fixed #2836 ([PATCH] FP: Dereferenced iterator has been erased) 2011-06-14 07:26:59 +02:00
Daniel Marjamäki a8cb7b445f 1.49: updated version 2011-06-12 18:24:31 +02:00
Robert Reif e584b08066 fix #2835 (crash of cppcheck ( ><,f<i, )) 2011-06-12 12:09:52 -04:00
Robert Reif 729ee72a5a fix #2831 (crash of cppcheck ( z<y<x> )) 2011-06-12 08:38:15 -04:00
Robert Reif d1b260699a fix #2834 (crash of cppcheck (std::vector<int>::iterator)) 2011-06-12 08:24:49 -04:00
Robert Reif 5e3263235b fix #2739 (segmentation fault of cppcheck ( if()x )) 2011-06-11 15:51:12 -04:00
Robert Reif 3d4eb0d77e fix #2682 (segmentation fault of cppcheck ( x a[0] = )) 2011-06-10 15:11:45 -04:00
Robert Reif a9e2e15e40 improve #2828 fix by adding switch 2011-06-09 07:32:43 -04:00
Robert Reif 6635ed4630 fix #2828 (false positive: Function parameter 'STYLE' hides enumerator with same name) 2011-06-08 20:14:52 -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
Robert Reif 0f6da27b9f fix #2795 (hash operator[] is not 'const') (original patch by Sebastien Debrard) (modified to use the symbol database) 2011-06-03 22:00:27 -04:00
Robert Reif a7fe9a3b50 fix 2 use after frees in simplifyEnum found by visual studio and verified by valgrind 2011-06-03 21:50:08 -04:00
Daniel Marjamäki 1b4b4ee43e Fixed #2806 (False positive with g_strstrip()) 2011-05-29 17:44:10 +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
Robert Reif a99aded1a4 add support for null pointer checking struct pointers 2011-05-27 23:30:19 -04:00
Robert Reif 311651cc66 fix #2804 (Underlying type of enumerator produces a syntax error) 2011-05-27 11:17:39 -04:00
Robert Reif 42316f3e0b fix #2792 (false positive: Member variable 'class::m_val' is not assigned a value in 'class::operator=') 2011-05-24 20:25:34 -04:00
seb777 287840e6bc fix #2786 2011-05-25 01:45:58 +08:00
Daniel Marjamäki 1c841535ee Fixed #2798 (False positive: Invalid iterator check doesn't respect code paths) 2011-05-22 17:17:24 +02:00
Daniel Marjamäki 52499ca8f8 Fixed #2790 (Incorrect allocation mismatch error) 2011-05-19 19:41:18 +02:00
Stefan Weil 21a2a91b3c executionpath: fix memory leak 2011-05-19 19:31:51 +02:00
Daniel Marjamäki c971fa0d4b cmake: cleanup unmaintained cmake files 2011-05-19 17:16:04 +02:00
Daniel Marjamäki ab1b293f23 Fixed #2737 ((error) Analysis failed. If the code is valid then please report this failure.) 2011-05-19 17:04:36 +02:00
WenChung Chiu 1ea52cfa02 Fixed #2784 (Pointer issue: *&f=open()) 2011-05-18 07:25:30 +02:00
Daniel Marjamäki b6dcdd7b79 Preprocessor: Don't report that there are missing system includes unless --debug-warnings has been given. 2011-05-15 09:38:13 +02:00
Daniel Marjamäki be9e66efff Fixed #2782 (Segfault with #asm) 2011-05-11 19:27:19 +02: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
Daniel Marjamäki 1c992fe25a Fixed #2783 (Improve check: struct member leaks when analysing c file) 2011-05-11 18:19:14 +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 03cd57260a added comment about how bad typedef behaviour can be reproduced 2011-05-07 14:40:47 +02:00
Daniel Marjamäki 8e5c63104c Fixed #2743 (segmentation fault of cppcheck 'std::vector<void(*)()> v1 = a, v2 = b;') 2011-05-07 14:23:14 +02:00
Daniel Marjamäki af7c97f972 Fixed #1684 (false positive: buffer access out of bounds when using extern variable declaration) 2011-05-07 11:34:48 +02:00
Robert Reif bb5dfa58a1 fix #2765 (Non local address detected as address of local auto-variable) 2011-05-06 19:26:04 -04:00
Robert Reif ccb831d375 fix regression #1819 (False positive: auto variable assignment (unseen typedef)) 2011-05-06 18:18:48 -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
Daniel Marjamäki b9ee867344 Fixed #2764 (False positive: Uninitialized variable '&(x[0])') 2011-05-05 21:26:18 +02:00
Daniel Marjamäki 9e97da8a57 Reverted fix for string::size. Ticket: #2756 2011-05-05 20:57:17 +02:00
Robert Reif 51baca0359 fix #1982 (simplifyTypedef: scope info is lost) 2011-05-02 22:42:52 -04:00
Daniel Marjamäki d998477c69 renamed --check-includes to --check-config 2011-05-02 21:28:33 +02:00
Daniel Marjamäki 8603919b2d Missing includes - normally just report that there are missing includes. The --check-includes can then be used to check what missing includes there are. Ticket: #2719 2011-05-02 14:58:16 +02:00