MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / overlappingStrcmpError

Method overlappingStrcmpError

lib/checkstring.cpp:406–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

404}
405
406void CheckStringImpl::overlappingStrcmpError(const Token *eq0, const Token *ne0)
407{
408 std::string eq0Expr(eq0 ? eq0->expressionString() : std::string("strcmp(x,\"abc\")"));
409 if (eq0 && eq0->astParent()->str() == "!")
410 eq0Expr = "!" + eq0Expr;
411 else
412 eq0Expr += " == 0";
413
414 const std::string ne0Expr = (ne0 ? ne0->expressionString() : std::string("strcmp(x,\"def\")")) + " != 0";
415
416 reportError(ne0, Severity::warning, "overlappingStrcmp", "The expression '" + ne0Expr + "' is suspicious. It overlaps '" + eq0Expr + "'.");
417}
418
419//---------------------------------------------------------------------------
420// Overlapping source and destination passed to sprintf().

Callers 1

getErrorMessagesMethod · 0.80

Calls 4

astParentMethod · 0.80
reportErrorFunction · 0.70
expressionStringMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected