| 555 | } |
| 556 | |
| 557 | void CheckNullPointerImpl::redundantConditionWarning(const Token* tok, const ValueFlow::Value *value, const Token *condition, bool inconclusive) |
| 558 | { |
| 559 | // cppcheck-suppress shadowFunction - TODO: fix this |
| 560 | std::string arithmetic = arithmeticTypeString(tok); |
| 561 | std::string errmsg; |
| 562 | if (tok && tok->str()[0] == '-') { |
| 563 | errmsg = ValueFlow::eitherTheConditionIsRedundant(condition) + " or there is overflow in pointer " + arithmetic + "."; |
| 564 | } else { |
| 565 | errmsg = ValueFlow::eitherTheConditionIsRedundant(condition) + " or there is pointer arithmetic with NULL pointer."; |
| 566 | } |
| 567 | ErrorPath errorPath = getErrorPath(tok, value, "Null pointer " + arithmetic); |
| 568 | reportError(std::move(errorPath), |
| 569 | Severity::warning, |
| 570 | "nullPointerArithmeticRedundantCheck", |
| 571 | errmsg, |
| 572 | CWE_INCORRECT_CALCULATION, |
| 573 | inconclusive ? Certainty::inconclusive : Certainty::normal); |
| 574 | } |
| 575 | |
| 576 | // NOLINTNEXTLINE(readability-non-const-parameter) - used as callback so we need to preserve the signature |
| 577 | static bool isUnsafeUsage(const Settings &settings, const Token *vartok, CTU::FileInfo::Value *value) |
no test coverage detected