updated style messages
This commit is contained in:
parent
ffcf45ab34
commit
4bde4d5a4a
|
@ -366,7 +366,8 @@ void CheckType::longCastAssignError(const Token *tok)
|
||||||
reportError(tok,
|
reportError(tok,
|
||||||
Severity::style,
|
Severity::style,
|
||||||
"truncLongCastAssignment",
|
"truncLongCastAssignment",
|
||||||
"possible loss of information, int result is assigned to long variable");
|
"int result is assigned to long variable. If the variable is long to avoid loss of information, then you have loss of information.\n"
|
||||||
|
"int result is assigned to long variable. If the variable is long to avoid loss of information, then there is loss of information. To avoid loss of information you must cast a calculation operand to long, for example 'l = a * b;' => 'l = (long)a * b;'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckType::longCastReturnError(const Token *tok)
|
void CheckType::longCastReturnError(const Token *tok)
|
||||||
|
@ -374,5 +375,6 @@ void CheckType::longCastReturnError(const Token *tok)
|
||||||
reportError(tok,
|
reportError(tok,
|
||||||
Severity::style,
|
Severity::style,
|
||||||
"truncLongCastReturn",
|
"truncLongCastReturn",
|
||||||
"possible loss of information, int result is returned as long value");
|
"int result is returned as long value. If the return value is long to avoid loss of information, then you have loss of information.\n"
|
||||||
|
"int result is returned as long value. If the return value is long to avoid loss of information, then there is loss of information. To avoid loss of information you must cast a calculation operand to long, for example 'return a*b;' => 'return (long)a*b'.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,7 @@ private:
|
||||||
" const long ret = x * y;\n"
|
" const long ret = x * y;\n"
|
||||||
" return ret;\n"
|
" return ret;\n"
|
||||||
"}\n", &settings);
|
"}\n", &settings);
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (style) possible loss of information, int result is assigned to long variable\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2]: (style) int result is assigned to long variable. If the variable is long to avoid loss of information, then you have loss of information.\n", errout.str());
|
||||||
|
|
||||||
// typedef
|
// typedef
|
||||||
check("long f(int x, int y) {\n"
|
check("long f(int x, int y) {\n"
|
||||||
|
@ -170,7 +170,7 @@ private:
|
||||||
check("long f(int x, int y) {\n"
|
check("long f(int x, int y) {\n"
|
||||||
" return x * y;\n"
|
" return x * y;\n"
|
||||||
"}\n", &settings);
|
"}\n", &settings);
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (style) possible loss of information, int result is returned as long value\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2]: (style) int result is returned as long value. If the return value is long to avoid loss of information, then you have loss of information.\n", errout.str());
|
||||||
|
|
||||||
// typedef
|
// typedef
|
||||||
check("size_t f(int x, int y) {\n"
|
check("size_t f(int x, int y) {\n"
|
||||||
|
|
Loading…
Reference in New Issue