updated style messages

This commit is contained in:
Daniel Marjamäki 2015-06-01 21:22:47 +02:00
parent ffcf45ab34
commit 4bde4d5a4a
2 changed files with 6 additions and 4 deletions

View File

@ -366,7 +366,8 @@ void CheckType::longCastAssignError(const Token *tok)
reportError(tok,
Severity::style,
"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)
@ -374,5 +375,6 @@ void CheckType::longCastReturnError(const Token *tok)
reportError(tok,
Severity::style,
"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'.");
}

View File

@ -146,7 +146,7 @@ private:
" const long ret = x * y;\n"
" return ret;\n"
"}\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
check("long f(int x, int y) {\n"
@ -170,7 +170,7 @@ private:
check("long f(int x, int y) {\n"
" return x * y;\n"
"}\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
check("size_t f(int x, int y) {\n"