Commit Graph

60 Commits

Author SHA1 Message Date
Daniel Marjamäki c4caee6b18 Updated copyright year 2018-01-14 15:37:52 +01:00
Dmitry-Me e4de220a2d Only check pointer that can be null at that point 2017-10-14 19:09:42 +03:00
Dmitry-Me 288ee96cc7 Avoid recomputing loop range end 2017-10-14 18:57:27 +03:00
Ayaz Salikhov b8cd7dbb5c Use nullptr instead of 0 or NULL (#936) 2017-08-09 20:00:26 +02:00
Ayaz Salikhov 28aa939d69 iwyu - include what you use 2017-05-27 04:33:47 +02:00
PKEuS b1f4bd7504 Refactorization: Reimplemented Settings::_enabled as a bitfeld instead of std::set (#7995) 2017-04-11 11:49:26 +02:00
PKEuS cfac3b457d Several small refactorizations 2016-12-06 22:12:02 +01:00
Roberto Martelloni 28f1222dc2 CWE mapping of useAutoPointerMalloc, uselessCallsCompare, uselessCallsSwap, uselessCallsSubstr, uselessCallsEmpty, uselessCallsRemove, derefInvalidIterator, reademptycontainer, multiplySizeof, divideSizeof, stringLiteralWrite, incorrectStringCompare, literalWithCharPtrCompare, charLiteralWithCharPtrCompare, incorrectStringBooleanError, staticStringCompare, stringCompare, signConversion, truncLongCastAssignment, truncLongCastReturn, unusedFunction, unusedVariable, unusedAllocatedMemory, unreadVariable, unassignedVariable, unusedStructMember, postfixOperator, va_start_wrongParameter (#824)
Add an optional extended description…
2016-09-03 00:31:35 +02:00
Daniel Marjamäki 0162f33d3f CheckSizeof: allow division with sizeof(char) when byte count is expected. 2016-07-17 19:19:15 +02:00
Daniel Marjamäki 91e38f3eb9 Fixed #7582 (false positive: Division by result of sizeof(). strncpy() expects a size in bytes) 2016-07-17 15:22:14 +02:00
PKEuS a808549af0 Support lambdas in simplifyCompoundAssignment (#7571) 2016-07-08 20:10:33 +02:00
Roberto Martelloni 87372ccd58 CWE mapping of sizeofForArrayParameter, sizeofForPointer, sizeofDivisionMemfunc, sizeofwithnumericparameter, sizeofsizeof, sizeofCalculation, sizeofVoid, sizeofDereferencedVoidPointer, arithOperationsOnVoidPointer (#810) 2016-07-08 09:06:55 +02:00
PKEuS 53e2cabdbb Properly support "break" in CheckVaarg::va_list_usage() (#7533)
Ran AStyle
2016-06-07 19:28:32 +02:00
Roberto Martelloni f1c39dbda7 CWE mapping of stlIfStrFind, stlcstrReturn, stlcstrParam, stlSize, (#801)
StlMissingComparison, redundantIfRemove.
2016-06-05 18:24:06 +02:00
PKEuS 00e4f70fe3 Fixed false positives in CheckSizeof::checkSizeofForPointerSize() (#7518) 2016-05-26 21:25:29 +02:00
PKEuS 4bb99a7887 Improved CheckSizeof::checkSizeofForPointerSize():
- Support cast in front of malloc() call
- Support sizeof(type) pattern (#4428)
2016-05-22 22:29:52 +02:00
Daniel Marjamäki 5e10e680da CWE: refactoring. use constants instead of magic numbers. 2016-01-25 20:01:48 +01:00
Lauri Nurmi 996c9244d8 Update copyright year to 2007-2016. 2016-01-01 15:34:45 +02:00
Daniel Marjamäki 7f1b43e79c Use simpleMatch to fix travis build 2015-12-30 12:28:55 +01:00
Daniel Marjamäki c0e8654649 Refactor void* checking. Use ValueType. 2015-12-30 11:48:20 +01:00
Daniel Marjamäki 0f9d90d2be Changed Copyrights. Removed my name. 2015-11-18 20:04:50 +01:00
PKEuS 9a879fc828 Fixed false positives with pointerSize being shown even if no sizeof() is used (#7100). 2015-11-07 13:19:06 +01:00
PKEuS 49f6231756 Fixed two issues in CheckSizeof::checkSizeofForPointerSize() 2015-11-07 09:35:30 +01:00
PKEuS 0ac89c8af2 Fixed internal warning 2015-11-06 22:21:39 +01:00
PKEuS 61b16909bd Fixed false negative pointerSize with member variables.
Fixed wrong comment in testcppcheck.cpp
2015-11-06 21:48:56 +01:00
Thomas Otto 7ba69cfd0a sizeofCalculation: skip if void-casted inside a macro (#6888) 2015-09-28 14:33:29 +02:00
PKEuS fbbdfa85ca Revert "Fixed false negative #5815"
This reverts commit dc6c278d83.
2015-09-09 14:46:47 +02:00
PKEuS dc6c278d83 Fixed false negative #5815 2015-08-31 14:12:19 +02:00
Alexander Mai 1c5e9e47c5 #6671 false positive: incorrect sizeofwithsilentarraypointer with reference to array. 2015-05-06 07:38:26 +02:00
Daniel Marjamäki 88f59ad7e8 Partial fix for #6656 (Allow that CWE is mapped for error message) 2015-04-25 17:48:11 +02:00
Matthias Krüger 42f0955e3f Move more setting checks out of loops and use const bools instead. Reorder a few related checks.
Follow up to eedcb6abcb .
2015-04-10 14:31:19 +02:00
PKEuS b2835051df Refactorization: Renamed Token::Match pattern %var% to %name%, implement new pattern %var% which is true if varId > 0. 2015-01-31 12:32:04 +01:00
Daniel Marjamäki 88e7b55a2d CheckSizeof: only report warnings when --enable=warning has been used 2015-01-06 15:20:42 +01:00
Daniel Marjamäki ff11ba9847 Updated copyright year to 2015 2015-01-03 12:14:58 +01:00
Thomas Jarosch dca65ce3da Fix FP if sizeof is used without parentheses on struct members
Right now we only support checking basic pointer types.
Pointers inside structs are not supported yet.

Consider the tokens "foo@1 . bar@2",
Token::Match( "sizeof ( %varid% )" ) won't match it.
Token::Match( "sizeof %varid%" ) did match it -> FP.
2014-12-22 09:44:08 +01:00
Alexander Mai 66d767b4b5 #6050 arithmetic on void** - fix false positive 2014-08-17 19:14:55 +02:00
PKEuS 5ddee75b5d Removed newline from divideBySizeofError message 2014-08-08 09:59:55 +02:00
PKEuS 5c238692e6 New check: Division by sizeof() as parameter to memset/memcpy/memmove/etc. as they expect a size in bytes (#5698)
Refactorizations in sizeof checking:
- Changed severity of sizeofwithsilentarraypointer to warning
- Made pointerSize message conclusive - there seems to be no reason for inconclusive
2014-08-08 09:49:09 +02:00
Alexander Mai ad1662a201 #5875 fix 'lib/checksizeof.cpp:142:26: runtime error: member call on null pointer of type 'Token'. Improve error handling in CheckSizeof::checkSizeofForPointerSize() 2014-06-01 22:18:17 +02:00
PKEuS 1fc1ff1993 Moved implementation of two functions to new file check.cpp -> Don't include <iostream> everywhere 2014-05-24 12:50:04 +02:00
PKEuS 8f79dc3ff8 Cleaned up includes and forward declarations in checkers:
- Removed definitely unnecessary forward declarations (e.g. "class Token"; token.h is already included by check.h, so a definition is unnecessary)
 - Removed unused includes
2014-05-24 12:50:03 +02:00
PKEuS 5c566e838c Fixed false positive "multiplySizeof" in TortoiseSVN 2014-05-19 20:57:13 +02:00
PKEuS 09e03fa6ef Fixed some complaints of PVS Studio 2014-05-19 14:37:54 +02:00
PKEuS 5fbd58d98d Fixed messages of CheckInternal, fixed a false positive. 2014-05-18 20:39:52 +02:00
PKEuS ecec4b0b46 Fixed false positive #5187: arithOperationsOnVoidPointerError when referencing void* 2014-04-27 12:18:33 +02:00
Thomas Jarosch 93341f4449 Use simple match where possible
Fixes these warnings found by "--enable=internal":

[lib/checkclass.cpp:972]: (warning) Found simple pattern inside Token::Match() call: "* *"
[lib/checkbufferoverrun.cpp:635]: (warning) Found simple pattern inside Token::Match() call: "."
[lib/checkbufferoverrun.cpp:1397]: (warning) Found simple pattern inside Token::Match() call: ";"
[lib/checksizeof.cpp:299]: (warning) Found simple pattern inside Token::Match() call: "."
[lib/checksizeof.cpp:301]: (warning) Found simple pattern inside Token::Match() call: ")"
[lib/checksizeof.cpp:303]: (warning) Found simple pattern inside Token::Match() call: "]"
[lib/checksizeof.cpp:318]: (warning) Found simple pattern inside Token::Match() call: ")"
[lib/checknullpointer.cpp:413]: (warning) Found simple pattern inside Token::Match() call: "delete"
[lib/checkio.cpp:1336]: (warning) Found simple pattern inside Token::Match() call: "> ("
[lib/checkstl.cpp:1509]: (warning) Found simple pattern inside Token::findmatch() call: ";"
[lib/checkstl.cpp:1512]: (warning) Found simple pattern inside Token::findmatch() call: ";"
[lib/checkstl.cpp:1594]: (warning) Found simple pattern inside Token::Match() call: "="
[lib/checkstl.cpp:1598]: (warning) Found simple pattern inside Token::Match() call: "] ="
[lib/checkunusedvar.cpp:755]: (warning) Found simple pattern inside Token::Match() call: "goto"
[lib/checkunusedvar.cpp:793]: (warning) Found simple pattern inside Token::Match() call: "="
[lib/checkuninitvar.cpp:376]: (warning) Found simple pattern inside Token::Match() call: "> ("
[lib/checkother.cpp:86]: (warning) Found simple pattern inside Token::Match() call: "> ("
[lib/checkother.cpp:2181]: (warning) Found simple pattern inside Token::Match() call: "> {"
[lib/valueflow.cpp:54]: (warning) Found simple pattern inside Token::Match() call: "&"
[lib/valueflow.cpp:409]: (warning) Found simple pattern inside Token::Match() call: "do"
[lib/valueflow.cpp:425]: (warning) Found simple pattern inside Token::Match() call: ") {"
[lib/valueflow.cpp:487]: (warning) Found simple pattern inside Token::Match() call: ") {"
[lib/valueflow.cpp:511]: (warning) Found simple pattern inside Token::Match() call: "} else {"
[lib/valueflow.cpp:615]: (warning) Found simple pattern inside Token::Match() call: "for ("
[lib/symboldatabase.cpp:80]: (warning) Found simple pattern inside Token::Match() call: "= {"
[lib/symboldatabase.cpp:1069]: (warning) Found simple pattern inside Token::Match() call: "std ::"
[lib/tokenize.cpp:2207]: (warning) Found simple pattern inside Token::Match() call: "< >"
[lib/tokenize.cpp:2730]: (warning) Found simple pattern inside Token::Match() call: ";"
[lib/tokenize.cpp:4234]: (warning) Found simple pattern inside Token::Match() call: "try {"
[lib/tokenize.cpp:4235]: (warning) Found simple pattern inside Token::Match() call: "} catch ("
[lib/tokenize.cpp:5500]: (warning) Found simple pattern inside Token::Match() call: "INT8"
[lib/tokenize.cpp:5752]: (warning) Found simple pattern inside Token::Match() call: "}"
[lib/tokenize.cpp:5752]: (warning) Found simple pattern inside Token::Match() call: "do"
2014-03-14 16:27:47 +01:00
Lauri Nurmi 70a67eaf85 Change some more 0 literals into nullptr. 2014-02-16 13:38:50 +02:00
Daniel Marjamäki fd3a8a2a18 Update copyright 2014-02-15 07:45:39 +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 742a6935ea Calculation in sizeof: Fixed FP for sizeof(Fred**) 2013-12-26 13:52:58 +01:00