Commit Graph

472 Commits

Author SHA1 Message Date
Thomas Jarosch a52b73f9f9 Fix #3208 (Simplify pointer to standard type, C only)
The symbol database is unavailable during token simplification
and &data[0] might return something completely different for C++.

Moved code_is_c() from checkOther to Tokenizer.
2011-10-16 08:09:57 +02:00
Daniel Marjamäki 6f8e42a5af changed the astyle formatting flags 2011-10-13 20:53:06 +02:00
Zachary Blair 82366918ff Fixed #2627 (switch case fall through: redundant strcpy) 2011-10-13 01:27:22 -07:00
Robert Reif af6a6f9c2d run astyle 2011-10-12 09:08:54 -04:00
Thomas Jarosch 849bee8437 [PATCH] Detect suspicious use of semicolon after 'if/for/while'
statements if they are followed by a {..} block.

Examples are:

for (int i = 0; i < 10; ++i);
{
   printf("i)";
}

or

if (i == 100);
{
   die("Wrong argument");
}

This new check is active if you enable inconclusive checks.
2011-10-11 08:41:39 +02:00
Zachary Blair fcf360825a Fixed #2955 (New check: Using && instead of &) 2011-10-10 10:11:17 -07:00
PKEuS 5f9b916dcc Fixed #2115 (new check: endless loop (unsigned comparison that is always true)) 2011-10-09 20:35:46 +02:00
Daniel Marjamäki 73fb6725e6 Readded CheckOther::bitwiseOnBoolean as inconclusive check 2011-10-06 22:01:48 +02:00
Daniel Marjamäki 09109f19f8 Removed CheckOther::bitwiseOnBoolean check. The reasons can be seen in my comments in ticket #3062. 2011-10-05 20:46:07 +02:00
PKEuS 494d3af3d1 Fixed #1877 (Be more strict about int vs. bool, part II) 2011-10-05 20:30:36 +02:00
Kimmo Varis 3cfe7ca1a7 Move "information" errors to "style" errors.
"information" severity is documented in lib/errorlogger.h as:

  Checking information.
  Information message about the checking (process) itself. These
  messages inform about header files not found etc issues that are
  not errors in the code but something user needs to know.

It IS NOT for errors in the code. All the current "information"-
severity errors fit nicely into description of the "style"-
severity.

We definitely need to separate processing information and actual
errors in the code. It is highly confusing for users to mix these
two different things. Hence all current "information" code error
messages are moved to "style" category.

Ticket: #3165 (Stop misusing the 'information' error severity!)
2011-10-05 20:44:00 +03:00
Robert Reif 2d717d77cd reduce false negatives for checking for CheckOther::checkSignOfUnsignedVariable() 2011-09-26 21:24:34 -04:00
Robert Reif 735ff11469 fix #3110 (false positve: style) Boolean result is used in bitwise operation. Clarify expression with parentheses) 2011-09-12 07:32:55 -04:00
Daniel Marjamäki 55230baf78 Fixed #3086 (false positive: Boolean result is used in bitwise operation.) 2011-09-11 09:46:01 +02:00
Philipp Kloke 2f62d180fe Fixed #1740 (Undefined Behavior: Divide by zero) 2011-09-10 16:12:53 +02:00
seb777 074ad10a30 fix #195 Unusual shift operation - check this kind of code
return x >> ! y ? 8 : 2;
2011-09-06 22:37:19 +02:00
Robert Reif b27bbea44a really fix #3079 (Spelling error in unsigned variable check 'never alwayw') 2011-09-05 09:48:59 -04:00
Robert Reif 2250a2dfc3 fix #3079 (Spelling error in unsigned variable check 'never alwayw') 2011-09-05 09:04:27 -04:00
seb777 5c7ed46e0c Following the discussion XX, replace the keyword C99 '_Bool' with the 'bool' keyword in the process of tokenization\nSee f29b7f9f08 2011-09-03 23:15:33 +02:00
Daniel Marjamäki d23c58d387 enable: break out 'performance' and 'portability' from the 'style' id. Ticket: #3074 2011-09-03 15:30:30 +02:00
Robert Reif f29b7f9f08 fix #3062 (false negative: Boolean variable is used in bitwise operation) 2011-09-02 17:19:06 -04:00
Robert Reif 2dd93dff75 move unused variable checks from checkother to checkunusedvar 2011-08-19 14:35:25 -04:00
Robert Reif 9fbef3ca7b fix #3011 (new check: when first comparison is true, the 2nd comparison is always true) 2011-08-19 13:28:37 -04:00
Daniel Marjamäki a735790e77 using boolean result in bitwise operation. fix false positive for '.. != (char *) &x' 2011-08-19 18:55:20 +02:00
Daniel Marjamäki 2dd1e290eb fixed false positives for the 'bitwise operator / comparison operator' check 2011-08-19 18:06:28 +02:00
Robert Reif eda9ff6fc5 refactor checkother to move error messages to follow check and rename some error functions to end in Error 2011-08-19 11:53:43 -04:00
Daniel Marjamäki 314d5f1e79 fixed false positive for 'using bitwise operation on boolean result' 2011-08-19 17:07:26 +02:00
Daniel Marjamäki c107fdd2d4 Fixed #3018 (false positive: (style) Suspicious condition (assignment+comparison), it can be clarified with parentheses) 2011-08-19 13:54:06 +02:00
Daniel Marjamäki 40b493e621 Improve check: Clarify condition (using boolean result in bitwise operation) 2011-08-19 13:40:54 +02:00
Daniel Marjamäki 0d7c80ef21 improved comment of previous commit 2011-08-19 07:28:15 +02:00
Daniel Marjamäki 4606251ce8 Fixed #3001 (False Positive: Redundant assignment to itself) 2011-08-19 07:23:11 +02:00
Daniel Marjamäki e5ff920ea9 Suspicious condition: Better handling when rhs is non-numeric 2011-08-19 00:56:15 +02:00
Daniel Marjamäki a7728fef48 New check: warn about such suspicious conditions: '(a & b == c)' 2011-08-19 00:15:20 +02:00
Daniel Marjamäki 4f962acf16 Fixed #3009 (Using numeric constants in kernel space code) 2011-08-16 20:16:33 +02:00
Robert Reif ad45ba718c convert CheckOther::checkCharVariable() to use symbol database 2011-08-14 10:39:45 -04:00
Robert Reif cd2c0fd9c8 convert CheckOther::checkSizeofForNumericParameter() to use the symbol database 2011-08-14 10:21:07 -04:00
Robert Reif 741eabba16 convert CheckOther::checkIncrementBoolean() to use the symbol database 2011-08-14 10:16:39 -04:00
Daniel Marjamäki 003956e42e Fixed #2982 (false positive: using char type as array index (using string as key)) 2011-08-09 17:03:22 +02:00
Daniel Marjamäki 8a6a999f09 Fixed #2979 (Improve message: using char as array index) 2011-08-08 19:35:11 +02:00
Kimmo Varis cfcfa3f000 Use "enabled" list for the style checking.
Settings-class currently enables style checking via dedicated
boolean attribute. All other CLI's enable-options are handled
through the enable-list. This commit moves style-check enabling
to use the enable-list.

Main advantage is the consistency how options are handled/stored
in the Settings class. Which also unifies using them for the other
code. You need to enable certain type of checks? Use the
addEnabled()-method. You want to check if certain type of checks
are enabled? Use the isEnabled()-method.
2011-08-07 10:28:52 +03:00
Robert Reif 85b2bd21dc fix #2968 (new check: testing if unsigned variable is less than 0) 2011-08-06 19:23:09 -04:00
Moritz Lipp 8d68981119 Fixed #2793 (SIGABRT on filenames without file extension) 2011-07-31 18:35:28 +02:00
Robert Reif 2f4aee2923 fix missing else in patch that added support for unused const local variables 2011-07-30 07:16:59 -04:00
Robert Reif cb4282d69a use simpleMatch where possible in checkother.cpp 2011-07-29 22:37:05 -04:00
Daniel Marjamäki dc629b4c39 Fixed 'possible null pointer dereference' warning messages 2011-07-28 08:12:21 +02:00
Daniel Marjamäki d2c0e5e7e6 Fixed #2821 (New Check : bool pointer null truth assignment) 2011-07-28 07:28:24 +02:00
Robert Reif 9a4447c835 add support for unused const local variables 2011-07-24 12:09:59 -04:00
Simon Martin 539c2e5acb Fixed #2932 (segmentation fault of cppcheck ( i / i )) 2011-07-24 09:06:38 +02:00
Robert Reif c3c3eb74e8 fix #2929 (Additional Unused variable check) 2011-07-21 18:37:37 -04:00
Robert Reif ed30edf9d3 simplify CheckOther::checkIncorrectLogicOperator() by using more pattern matching 2011-07-18 07:34:49 -04:00