diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp
index 1fb18b928..9db58c500 100644
--- a/cli/cmdlineparser.cpp
+++ b/cli/cmdlineparser.cpp
@@ -246,8 +246,6 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
// Check library definitions
else if (std::strcmp(argv[i], "--check-library") == 0) {
mSettings->checkLibrary = true;
- // need to add "information" or no messages will be shown at all
- mSettings->addEnabled("information");
}
else if (std::strncmp(argv[i], "--checks-max-time=", 18) == 0) {
diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp
index 761c8449e..50bb91c65 100644
--- a/lib/checkfunctions.cpp
+++ b/lib/checkfunctions.cpp
@@ -594,7 +594,7 @@ void CheckFunctions::memsetValueOutOfRangeError(const Token *tok, const std::str
void CheckFunctions::checkLibraryMatchFunctions()
{
- if (!mSettings->checkLibrary || !mSettings->severity.isEnabled(Severity::information))
+ if (!mSettings->checkLibrary)
return;
bool insideNew = false;
diff --git a/lib/checkleakautovar.cpp b/lib/checkleakautovar.cpp
index ab8672918..0e0dc25cf 100644
--- a/lib/checkleakautovar.cpp
+++ b/lib/checkleakautovar.cpp
@@ -169,7 +169,7 @@ void CheckLeakAutoVar::deallocReturnError(const Token *tok, const Token *dealloc
void CheckLeakAutoVar::configurationInfo(const Token* tok, const std::string &functionName)
{
- if (mSettings->checkLibrary && mSettings->severity.isEnabled(Severity::information)) {
+ if (mSettings->checkLibrary) {
reportError(tok,
Severity::information,
"checkLibraryUseIgnore",
diff --git a/lib/checkunusedvar.cpp b/lib/checkunusedvar.cpp
index 7aa6433fb..00bd1ed4c 100644
--- a/lib/checkunusedvar.cpp
+++ b/lib/checkunusedvar.cpp
@@ -1147,14 +1147,14 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
void CheckUnusedVar::checkFunctionVariableUsage()
{
- if (!mSettings->severity.isEnabled(Severity::style))
+ if (!mSettings->severity.isEnabled(Severity::style) && !mSettings->checkLibrary)
return;
// Parse all executing scopes..
const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase();
auto reportLibraryCfgError = [this](const Token* tok, const std::string& typeName) {
- if (mSettings->checkLibrary && mSettings->severity.isEnabled(Severity::information)) {
+ if (mSettings->checkLibrary) {
reportError(tok,
Severity::information,
"checkLibraryCheckType",
@@ -1380,16 +1380,25 @@ void CheckUnusedVar::checkFunctionVariableUsage()
void CheckUnusedVar::unusedVariableError(const Token *tok, const std::string &varname)
{
+ if (!mSettings->severity.isEnabled(Severity::style))
+ return;
+
reportError(tok, Severity::style, "unusedVariable", "$symbol:" + varname + "\nUnused variable: $symbol", CWE563, Certainty::normal);
}
void CheckUnusedVar::allocatedButUnusedVariableError(const Token *tok, const std::string &varname)
{
+ if (!mSettings->severity.isEnabled(Severity::style))
+ return;
+
reportError(tok, Severity::style, "unusedAllocatedMemory", "$symbol:" + varname + "\nVariable '$symbol' is allocated memory that is never used.", CWE563, Certainty::normal);
}
void CheckUnusedVar::unreadVariableError(const Token *tok, const std::string &varname, bool modified)
{
+ if (!mSettings->severity.isEnabled(Severity::style))
+ return;
+
if (modified)
reportError(tok, Severity::style, "unreadVariable", "$symbol:" + varname + "\nVariable '$symbol' is modified but its new value is never used.", CWE563, Certainty::normal);
else
@@ -1398,6 +1407,9 @@ void CheckUnusedVar::unreadVariableError(const Token *tok, const std::string &va
void CheckUnusedVar::unassignedVariableError(const Token *tok, const std::string &varname)
{
+ if (!mSettings->severity.isEnabled(Severity::style))
+ return;
+
reportError(tok, Severity::style, "unassignedVariable", "$symbol:" + varname + "\nVariable '$symbol' is not assigned a value.", CWE665, Certainty::normal);
}
diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp
index 19a3891f3..7812b9661 100644
--- a/lib/tokenize.cpp
+++ b/lib/tokenize.cpp
@@ -7172,7 +7172,7 @@ bool Tokenizer::isScopeNoReturn(const Token *endScopeToken, bool *unknown) const
}
if (unknown)
*unknown = !unknownFunc.empty();
- if (!unknownFunc.empty() && mSettings->checkLibrary && mSettings->severity.isEnabled(Severity::information)) {
+ if (!unknownFunc.empty() && mSettings->checkLibrary) {
bool warn = true;
if (Token::simpleMatch(endScopeToken->tokAt(-2), ") ; }")) {
const Token * const ftok = endScopeToken->linkAt(-2)->previous();
diff --git a/man/manual-ja.docbook b/man/manual-ja.docbook
index 2fa180636..1c13d3d05 100644
--- a/man/manual-ja.docbook
+++ b/man/manual-ja.docbook
@@ -1360,9 +1360,9 @@ Checking minsize.c...
# cppcheck noreturn.c
Checking noreturn.c...
- しかし、--check-library と--enable=informationをつかうとエラーが出力されます。:
+ しかし、--check-library をつかうとエラーが出力されます。:
- # cppcheck --check-library --enable=information noreturn.c
+ # cppcheck --check-library noreturn.c
Checking noreturn.c...
[noreturn.c:7]: (information) --check-library: Function ZeroMemory() should have <noreturn> configuration
diff --git a/man/manual.md b/man/manual.md
index 1aa1d7b9c..36c190594 100644
--- a/man/manual.md
+++ b/man/manual.md
@@ -925,7 +925,7 @@ Cppcheck already contains configurations for several libraries. They can be load
## Using your own custom .cfg file
-You can create and use your own .cfg files for your projects. Use `--check-library` and `--enable=information` to get hints about what you should configure.
+You can create and use your own .cfg files for your projects. Use `--check-library` to get hints about what you should configure.
You can use the `Library Editor` in the `Cppcheck GUI` to edit configuration files. It is available in the `View` menu.
diff --git a/man/reference-cfg-format.md b/man/reference-cfg-format.md
index 2c1a88c49..657798c3a 100644
--- a/man/reference-cfg-format.md
+++ b/man/reference-cfg-format.md
@@ -89,7 +89,7 @@ If instead `dostuff` takes care of the memory then this can be configured with:
-The `