예제 #1
0
void CheckBool::bitwiseOnBooleanError(const Token *tok, const std::string &varname, const std::string &op)
{
    reportError(tok, Severity::style, "bitwiseOnBoolean",
                "Boolean variable '" + varname + "' is used in bitwise operation. Did you mean '" + op + "'?",
                CWE(0),
                true);
}
예제 #2
0
void CheckNullPointer::arithmeticError(const Token *tok, const ValueFlow::Value *value)
{
    std::string errmsg;
    if (value && value->condition)
        errmsg = ValueFlow::eitherTheConditionIsRedundant(value->condition) + " or there is overflow in pointer subtraction.";
    else
        errmsg = "Overflow in pointer arithmetic, NULL pointer is subtracted.";

    std::list<const Token*> callstack;
    callstack.push_back(tok);
    if (value && value->condition)
        callstack.push_back(value->condition);

    reportError(callstack,
                (value && value->condition) ? Severity::warning : Severity::error,
                (value && value->condition) ? "nullPointerArithmeticRedundantCheck" : "nullPointerArithmetic",
                errmsg,
                CWE(0), // unknown - pointer overflow
                value && value->inconclusive);
}