Clarify few verbose messages.

Dan pointed out to me earlier that he wants both short- and
verbose messages to be independently understandable. So modifying
some verbose messages to be easier to understand without the short
message.
This commit is contained in:
Kimmo Varis 2011-02-04 11:10:24 +02:00
parent 39c68e12ce
commit 7d73b523be
3 changed files with 14 additions and 6 deletions

View File

@ -2731,9 +2731,9 @@ void CheckOther::sprintfOverlappingDataError(const Token *tok, const std::string
{ {
reportError(tok, Severity::error, "sprintfOverlappingData", reportError(tok, Severity::error, "sprintfOverlappingData",
"Undefined behavior: variable is used as parameter and destination in s[n]printf().\n" "Undefined behavior: variable is used as parameter and destination in s[n]printf().\n"
"The variable '" + varname + "' is used both as parameter and destination in " "The variable '" + varname + "' is used both as a parameter and as a destination in "
"and destination buffer overlap. Quote from glibc (C-library) documentation " "s[n]printf(). The origin and destination buffers overlap. Quote from glibc (C-library) "
"(http://www.gnu.org/software/libc/manual/html_mono/libc.html#Formatted-Output-Functions): " "documentation (http://www.gnu.org/software/libc/manual/html_mono/libc.html#Formatted-Output-Functions): "
"'If copying takes place between objects that overlap as a result of a call " "'If copying takes place between objects that overlap as a result of a call "
"to sprintf() or snprintf(), the results are undefined.'"); "to sprintf() or snprintf(), the results are undefined.'");
} }
@ -2846,8 +2846,9 @@ void CheckOther::sizeofsizeofError(const Token *tok)
{ {
reportError(tok, Severity::warning, reportError(tok, Severity::warning,
"sizeofsizeof", "Calling sizeof for 'sizeof'.\n" "sizeofsizeof", "Calling sizeof for 'sizeof'.\n"
"This is suspicious code and most likely there should be just" "Calling sizeof for 'sizeof looks like a suspicious code and "
"one 'sizeof'. The current code is equivalent to 'sizeof(size_t)'"); "most likely there should be just one 'sizeof'. The current "
"code is equivalent to 'sizeof(size_t)'");
} }
void CheckOther::sizeofCalculation() void CheckOther::sizeofCalculation()
@ -2901,6 +2902,7 @@ void CheckOther::assignmentInAssertError(const Token *tok, const std::string &va
{ {
reportError(tok, Severity::warning, reportError(tok, Severity::warning,
"assignmentInAssert", "Assert statement modifies '" + varname + "'.\n" "assignmentInAssert", "Assert statement modifies '" + varname + "'.\n"
"Variable '" + varname + "' is modified insert assert statement. "
"Assert statements are removed from release builds so the code inside " "Assert statements are removed from release builds so the code inside "
"assert statement is not run. If the code is needed also in release " "assert statement is not run. If the code is needed also in release "
"builds this is a bug."); "builds this is a bug.");

View File

@ -101,6 +101,7 @@ void CheckPostfixOperator::postfixOperatorError(const Token *tok)
{ {
reportError(tok, Severity::performance, "postfixOperator", reportError(tok, Severity::performance, "postfixOperator",
"Prefer prefix ++/-- operators for non-primitive types.\n" "Prefer prefix ++/-- operators for non-primitive types.\n"
"Prefix ++/-- operators should be preferred for non-primitive types. "
"Pre-increment/decrement can be more efficient than " "Pre-increment/decrement can be more efficient than "
"post-increment/decrement. Post-increment/decrement usually " "post-increment/decrement. Post-increment/decrement usually "
"involves keeping a copy of the previous value around and " "involves keeping a copy of the previous value around and "

View File

@ -724,6 +724,7 @@ void CheckStl::stlBoundriesError(const Token *tok, const std::string &container_
{ {
reportError(tok, Severity::error, "stlBoundries", reportError(tok, Severity::error, "stlBoundries",
"Dangerous container iterator compare using < operator for " + container_name + "\n" "Dangerous container iterator compare using < operator for " + container_name + "\n"
"Container '" + container_name + "' iterator compared with < operator. "
"Using < operator with container type iterators is dangerous since the order of " "Using < operator with container type iterators is dangerous since the order of "
"the items is not guaranteed. One should use != operator instead when comparing " "the items is not guaranteed. One should use != operator instead when comparing "
"iterators in the container."); "iterators in the container.");
@ -782,6 +783,7 @@ void CheckStl::if_findError(const Token *tok, bool str)
if (str) if (str)
reportError(tok, Severity::warning, "stlIfStrFind", reportError(tok, Severity::warning, "stlIfStrFind",
"Suspicious checking of string::find() return value.\n" "Suspicious checking of string::find() return value.\n"
"Checking of string::find() return value looks Suspicious. "
"string::find will return 0 if the string is found at position 0. " "string::find will return 0 if the string is found at position 0. "
"If that is wanted to check then string::compare is a faster alternative " "If that is wanted to check then string::compare is a faster alternative "
"because it doesn't scan through the string."); "because it doesn't scan through the string.");
@ -870,6 +872,7 @@ void CheckStl::sizeError(const Token *tok)
const std::string varname(tok ? tok->str().c_str() : "list"); const std::string varname(tok ? tok->str().c_str() : "list");
reportError(tok, Severity::performance, "stlSize", reportError(tok, Severity::performance, "stlSize",
"Possible inefficient checking for '" + varname + "' emptiness.\n" "Possible inefficient checking for '" + varname + "' emptiness.\n"
"Checking for '" + varname + "' emptiness might be inefficient. "
"Using " + varname + ".empty() instead of " + varname + ".size() can be faster. " + "Using " + varname + ".empty() instead of " + varname + ".size() can be faster. " +
varname + ".size() can take linear time but " + varname + ".empty() is " varname + ".size() can take linear time but " + varname + ".empty() is "
"guaranteed to take constant time."); "guaranteed to take constant time.");
@ -907,7 +910,9 @@ void CheckStl::redundantCondition()
void CheckStl::redundantIfRemoveError(const Token *tok) void CheckStl::redundantIfRemoveError(const Token *tok)
{ {
reportError(tok, Severity::style, "redundantIfRemove", "Redundant checking of STL container element.\n" reportError(tok, Severity::style, "redundantIfRemove",
"Redundant checking of STL container element.\n"
"Redundant checking of STL container element existence before removing it. "
"The remove method in the STL will not do anything if element doesn't exist"); "The remove method in the STL will not do anything if element doesn't exist");
} }