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

Method longCastAssignError

lib/checktype.cpp:417–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

415}
416
417void CheckTypeImpl::longCastAssignError(const Token *tok, const ValueType* src, const ValueType* tgt)
418{
419 std::string srcStr = src ? src->str() : "int";
420 makeBaseTypeString(srcStr);
421 std::string tgtStr = tgt ? tgt->str() : "long";
422 makeBaseTypeString(tgtStr);
423 reportError(tok,
424 Severity::style,
425 "truncLongCastAssignment",
426 srcStr + " result is assigned to " + tgtStr + " variable. If the variable is " + tgtStr + " to avoid loss of information, then you have loss of information.\n" +
427 srcStr + " result is assigned to " + tgtStr + " variable. If the variable is " + tgtStr + " to avoid loss of information, then there is loss of information. To avoid loss of information you must cast a calculation operand to " + tgtStr + ", for example 'l = a * b;' => 'l = (" + tgtStr + ")a * b;'.", CWE197, Certainty::normal);
428}
429
430void CheckTypeImpl::longCastReturnError(const Token *tok, const ValueType* src, const ValueType* tgt)
431{

Callers 1

getErrorMessagesMethod · 0.80

Calls 3

makeBaseTypeStringFunction · 0.85
reportErrorFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected