Commit Graph

252 Commits

Author SHA1 Message Date
Daniel Marjamäki bd7790fd8c Update copyright year 2019-02-09 07:24:06 +01:00
Sebastian a1a695dcda checkio: Add missing id "invalidScanfFormatWidth_smaller" to errorlist output (#1533) 2018-12-20 21:14:02 +01:00
Paul Fultz II 025881cf35 Fix issue 8829: Condition '...' is always true (int buf[42]; if(buf != NULL){})
This makes arrays non-null in valueflow, so it can catch comparisons against null that is always true:

```cpp
void f(void) {
   int buf[42];
   if( buf != 0) {;} // << always true
}
```
2018-12-17 06:07:34 +01:00
Daniel Marjamäki 7dda8e2a2d Refactoring: Use range for loops 2018-07-14 10:02:32 +02:00
Daniel Marjamäki 79ffe1d4fc Rename _tokenizer, _settings, _errorLogger 2018-06-16 16:10:28 +02:00
orbitcowboy 33777c5b72 Improved const correcntess of local variables. 2018-05-29 13:24:48 +02:00
rebnridgway 42a65c5160 Fix crash bug #8579 (#1238)
* Added declaration for deletePrevious function

* Added definition for deletePrevious function

* Fixed crash from deleteThis invalidating pointers

The crash was caused by deleteThis() invalidating the pointer to a constant variable usage.  This happened when a usage followed an assignment.  This fixes bug #8579.

* Added tokensFront to match tokensBack

This means deletePrevious can set the list's front if necessary.

* Initialised tokensFront in appropriate places

* Switched to using default Token constructor

* Switched to using Token default constructor

* Switched to using default constructor for Token

* Added missing argument to Token constructor

* Changed to use default constructor for Tokens

* Switched to using default constructor for Tokens

* Switched to using default constructor for Token

* Added new test for deleting front Token

Also made sure to use the correct constructor for Token in other tests.

* Syntax error

* Replaced tokensFront and tokensBack with a struct

This decreases the size of the Token class for performance purposes.

* Replaced tokensFront and tokensBack with a struct

* Added tokensFrontBack to destructor

* Reworked to use TokensBackFront struct

Also ran astyle.

* Reworked to use TokenList's TokensFrontBack member

* Reworked to use TokensFrontBack struct

* Reworked to use TokensFrontBack struct

* Reworked to work with TokensFrontBack struct

* Removed unnecessary scope operator

* Added missing parentheses

* Fixed syntax error

* Removed unnecessary constructor

* Default constructor now 0-initialises everything

This is safer for not using a temporary TokensFrontBack object, and doesn't use delegating constructors which aren't supported yet.

* Fixed unsafe null check

* Added missing explicit keyword

* Fixing stylistic nits

Removed default constructor as it has been superseded by the single-argument constructor with a default argument value.
Renamed listEnds to tokensFrontBack.
Fixed if statement that was supposed to be adding safety but would actually cause a crash if tokensFrontBack was null.

* Fixing stylistic nits

Removed default constructor and replaced it with a single-argument constructor with a default value.

* Fixing stylistic nits

Renamed _listEnds to _tokensFrontBack.

* Fixing stylistic nits

Renamed _listEnds to _tokensFrontBack.
2018-05-25 07:15:05 +02:00
Daniel Marjamäki ca8e19c96d SymbolDatabase: Refactor SymbolDatabase: variable list 2018-04-28 09:38:33 +02:00
Daniel Marjamäki f336c2efe7 Refactoring; Renamed Scope::classStart and Scope::classEnd 2018-04-27 22:36:30 +02:00
PKEuS e2002db78d Replaced make_container by C++11 initializer lists 2018-04-08 23:03:44 +02:00
Daniel Marjamäki 541e255159 Remove inner identical condition 2018-04-08 08:12:56 +02:00
jrp2014 c367fc9f09 Refactor lib/checkio.cpp 2018-04-05 15:55:57 +02:00
jrp2014 b6504c70ca Improve constness 2018-04-04 21:51:31 +02:00
Daniel Marjamäki 7e4dba6a7e Updated copyright year 2018-03-31 20:59:09 +02:00
orbitcowboy f5e6ef9fd2
checkio: Fixed potential usage of invalid iterator. (#1066)
* checkio: Fixed potential usage of invalid iterator.

* formatted the code.

A ticket about FN (invalidIterator1) is created at https://trac.cppcheck.net/ticket/8373
2018-01-30 08:43:15 +01:00
Daniel Marjamäki c4caee6b18 Updated copyright year 2018-01-14 15:37:52 +01:00
Daniel Marjamäki 43db6147d3 astyle formatting
[ci skip]
2017-11-27 23:32:20 +01:00
Dmitry-Me 4ac56a55be Fix FN for signed short passed as %hx into printf 2017-11-21 22:17:02 +03:00
Dmitry-Me c6bf881ee6 Fix FN for signed char passed as %hhx into printf 2017-11-21 22:14:48 +03:00
Dmitry-Me 5869f6d989 Fix FN for std::intmax_t passed as %ld, %lld into scanf 2017-11-20 23:07:37 +03:00
Dmitry-Me 7cf21f329a Fix FN for size_t, uintmax_t passed as %lx and %llx into printf 2017-11-20 22:56:33 +03:00
Dmitry-Me f0a7365f35 Fix FN for ptrdiff_t passed as %Ix into printf 2017-11-20 22:51:10 +03:00
Dmitry-Me eb4bb893b3 Fix FP for std::intmax_t passed as %jd into scanf 2017-11-20 22:31:13 +03:00
Dmitry-Me c4b6db7e23 Fix FP for std::uintmax_t passed as %ju and %jx into scanf 2017-11-20 22:13:20 +03:00
Dmitry-Me cf05b722a9 Fix FN for intmax_t passed as %jx into printf 2017-11-18 00:00:02 +03:00
Dmitry-Me 73414ee56c Fix FN for std::uintmax_t passed as %Lu and %Lx into scanf 2017-11-17 23:58:09 +03:00
Dmitry-Me 167258a6bf Fix FNs when various types are passed as %tu into printf 2017-11-15 22:40:16 +03:00
Dmitry-Me 4fc0a7998e Remove duplicate error reporting function 2017-11-14 21:46:17 +03:00
Dmitry-Me 916acfc133 Reuse duplicated code for "x" and "u" scanf specifiers 2017-11-09 16:35:09 +03:00
Dmitry-Me 56ba48d705 Unify code handling "x" and "u" scanf specifiers 2017-11-09 16:25:56 +03:00
Dmitry-Me 94dd63f196 Fix FN for std::uintmax_t passed as %lx, %lu scanf read targets 2017-11-09 15:38:48 +03:00
Dmitry-Me b301b44897 Fix FN for unsigned ptrdiff_t passed as %lu into scanf 2017-11-09 14:43:09 +03:00
Dmitry-Me 78be821431 Fix FN for std::uintmax_t passed as %llx, %llu scanf read targets 2017-11-09 11:28:07 +03:00
Dmitry-Me 74c778c5f0 Fix FN when unsigned ptrdiff_t is passed as %llu into scanf 2017-11-09 00:26:07 +03:00
Dmitry-Me 703d86992d Fix FN when size_t, uintmax_t are passed as %Lx into scanf 2017-11-08 23:52:49 +03:00
Dmitry-Me 89b83b2d16 Fix FN for unsigned ptrdiff_t passed as %Ix into scanf 2017-11-08 15:06:51 +03:00
Dmitry-Me 970aee9ce1 Fix FN for ptrdiff_t passed as %zd into scanf 2017-11-08 14:22:03 +03:00
Dmitry-Me aff993115f Remove duplicate check 2017-11-08 00:53:18 +03:00
Dmitry-Me 4c186d2455 Remove dead code - %llf specifier doesn't exist 2017-11-07 22:57:44 +03:00
Dmitry-Me 06fd390b3f Remove duplicate checks 2017-11-07 22:14:29 +03:00
Oleksandr Redko a8700f5622 Remove redundant parts of conditional expressions (#988)
All issues were found with PVS-Studio:
V560 A part of conditional expression is always true: tok. astutils.cpp 407
V560 A part of conditional expression is always true: size > 0. checkbufferoverrun.cpp 709
V547 Expression 'secondTrue' is always true. checkcondition.cpp 1013
V547 Expression 'firstTrue' is always true. checkcondition.cpp 1020
V560 A part of conditional expression is always true: !scan. checkio.cpp 1036
V560 A part of conditional expression is always true: scope->function. checknullpointer.cpp 395
V560 A part of conditional expression is always true: tok2. checkstl.cpp 268
V560 A part of conditional expression is always true: par. tokenize.cpp 9440
V547 Expression '!erased' is always true. symboldatabase.cpp 3990
2017-11-03 10:39:57 +01:00
Dmitry-Me fe5dd55723 Wrong reporting function was being called 2017-10-27 22:21:18 +03:00
Dmitry-Me f653b36b87 Fix actual type reported for unsigned ptrdiff_t passed into scanf 2017-10-26 23:47:11 +03:00
Dmitry-Me 65b2755098 Extract common check and run it first 2017-10-26 23:42:38 +03:00
Dmitry-Me a38854451f Warn for signed values passed as scanf targets with "x" conversion 2017-10-25 21:22:17 +03:00
Dmitry-Me eaa12db761 scanf with %zd expects ssize_t, not ptrdiff_t 2017-10-24 22:01:23 +03:00
Dmitry-Me 9c0e6986da Passing string literals into printf as %p is fine 2017-10-08 11:14:10 +03:00
Dmitry-Me 4601e40615 Simplify code for finding string format token 2017-10-02 18:03:55 +03:00
Dmitry-Me 9fdfada4b5 Compute value earlier and reuse it 2017-09-28 23:41:29 +03:00
Dmitry-Me 7308901add Omit duplicate and opposite checks 2017-09-28 17:59:55 +03:00