Commit Graph

463 Commits

Author SHA1 Message Date
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