Skip to content

Commit e9318d7

Browse files
committed
Refactorization: Avoid creating a temporary string
1 parent e92a951 commit e9318d7

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

cli/cppcheckexecutor.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,38 +1126,38 @@ bool CppCheckExecutor::tryLoadLibrary(Library& destination, const char* basepath
11261126
if (err.errorcode == Library::UNKNOWN_ELEMENT)
11271127
std::cout << "cppcheck: Found unknown elements in configuration file '" << filename << "': " << err.reason << std::endl;
11281128
else if (err.errorcode != Library::OK) {
1129-
std::string errmsg;
1129+
std::cout << "cppcheck: Failed to load library configuration file '" << filename << "'. ";
11301130
switch (err.errorcode) {
11311131
case Library::OK:
11321132
break;
11331133
case Library::FILE_NOT_FOUND:
1134-
errmsg = "File not found";
1134+
std::cout << "File not found";
11351135
break;
11361136
case Library::BAD_XML:
1137-
errmsg = "Bad XML";
1137+
std::cout << "Bad XML";
11381138
break;
11391139
case Library::UNKNOWN_ELEMENT:
1140-
errmsg = "Unexpected element";
1140+
std::cout << "Unexpected element";
11411141
break;
11421142
case Library::MISSING_ATTRIBUTE:
1143-
errmsg = "Missing attribute";
1143+
std::cout << "Missing attribute";
11441144
break;
11451145
case Library::BAD_ATTRIBUTE_VALUE:
1146-
errmsg = "Bad attribute value";
1146+
std::cout << "Bad attribute value";
11471147
break;
11481148
case Library::UNSUPPORTED_FORMAT:
1149-
errmsg = "File is of unsupported format version";
1149+
std::cout << "File is of unsupported format version";
11501150
break;
11511151
case Library::DUPLICATE_PLATFORM_TYPE:
1152-
errmsg = "Duplicate platform type";
1152+
std::cout << "Duplicate platform type";
11531153
break;
11541154
case Library::PLATFORM_TYPE_REDEFINED:
1155-
errmsg = "Platform type redefined";
1155+
std::cout << "Platform type redefined";
11561156
break;
11571157
}
11581158
if (!err.reason.empty())
1159-
errmsg += " '" + err.reason + "'";
1160-
std::cout << "cppcheck: Failed to load library configuration file '" << filename << "'. " << errmsg << std::endl;
1159+
std::cout << " '" + err.reason + "'";
1160+
std::cout << std::endl;
11611161
return false;
11621162
}
11631163
return true;

0 commit comments

Comments
 (0)