Skip to content

Commit 2932ab7

Browse files
authored
Revert "Fixed #12071 (suppressing critical error, no indication to user that analysis of file fails) (#5771)" (#5775)
This reverts commit 7c316fb.
1 parent 1c7036f commit 2932ab7

21 files changed

Lines changed: 26 additions & 113 deletions

.github/workflows/CI-unixish.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,7 @@ jobs:
423423
run: |
424424
./cppcheck --error-exitcode=1 --inline-suppr --addon=threadsafety addons/test/threadsafety
425425
./cppcheck --error-exitcode=1 --inline-suppr --addon=threadsafety --std=c++03 addons/test/threadsafety
426-
./cppcheck --error-exitcode=1 --dump addons/test/misra/crash*.c
427-
python3 addons/misra.py --cli addons/test/misra/crash*.c.dump > /dev/null
426+
./cppcheck --error-exitcode=1 --inline-suppr --addon=misra addons/test/misra/crash*.c
428427
./cppcheck --error-exitcode=1 --inline-suppr --addon=misra --enable=information addons/test/misra/config*.c
429428
430429
./cppcheck --addon=misra --enable=style --inline-suppr --enable=information --error-exitcode=1 addons/test/misra/misra-ctu-*-test.c

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ if(LIBXML2_XMLLINT_EXECUTABLE)
4747
add_custom_target(errorlist-xml $<TARGET_FILE:cppcheck> --errorlist > ${CMAKE_BINARY_DIR}/errorlist.xml
4848
DEPENDS cppcheck)
4949

50-
add_custom_target(example-xml $<TARGET_FILE:cppcheck> --xml --enable=all --inconclusive --max-configs=1 ${CMAKE_SOURCE_DIR}/samples -i${CMAKE_SOURCE_DIR}/samples/syntaxError/bad.c 2> ${CMAKE_BINARY_DIR}/example.xml
50+
add_custom_target(example-xml $<TARGET_FILE:cppcheck> --xml --enable=all --inconclusive --max-configs=1 ${CMAKE_SOURCE_DIR}/samples 2> ${CMAKE_BINARY_DIR}/example.xml
5151
DEPENDS cppcheck)
5252

5353
add_custom_target(createXMLExamples DEPENDS errorlist-xml example-xml)

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ validatePlatforms: ${PlatformFilesCHECKED}
439439
/tmp/errorlist.xml: cppcheck
440440
./cppcheck --errorlist >$@
441441
/tmp/example.xml: cppcheck
442-
./cppcheck --xml --enable=all --inconclusive --max-configs=1 samples -isamples/syntaxError/bad.c 2>/tmp/example.xml
442+
./cppcheck --xml --enable=all --inconclusive --max-configs=1 samples 2>/tmp/example.xml
443443
createXMLExamples:/tmp/errorlist.xml /tmp/example.xml
444444
.PHONY: validateXML
445445
validateXML: createXMLExamples

cli/cmdlineparser.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,10 +587,6 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
587587
if (!parseNumberArg(argv[i], 17, mSettings.exitCode))
588588
return Result::Fail;
589589
}
590-
// --unsafe-exitcode => for tests, critical errors will not force non-zero exitcode
591-
else if (std::strcmp(argv[i], "--unsafe-exitcode") == 0) {
592-
mSettings.unsafeExitCode = true;
593-
}
594590

595591
// Exception handling inside cppcheck client
596592
else if (std::strcmp(argv[i], "--exception-handling") == 0) {

cli/cppcheckexecutor.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,6 @@ class CppCheckExecutor::StdLogger : public ErrorLogger
118118
*/
119119
void writeCheckersReport() const;
120120

121-
bool hasCriticalErrors() const {
122-
return !mCriticalErrors.empty();
123-
}
124-
125121
private:
126122
/**
127123
* Information about progress is directed here. This should be
@@ -291,12 +287,9 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck) const
291287

292288
mStdLogger->writeCheckersReport();
293289

294-
if (!settings.unsafeExitCode && mStdLogger->hasCriticalErrors())
295-
return settings.exitCode > 0 ? settings.exitCode : EXIT_FAILURE;
296-
297290
if (returnValue)
298291
return settings.exitCode;
299-
return EXIT_SUCCESS;
292+
return 0;
300293
}
301294

302295
void CppCheckExecutor::StdLogger::writeCheckersReport() const
@@ -405,10 +398,6 @@ void CppCheckExecutor::StdLogger::reportErr(const ErrorMessage &msg)
405398
if (!mCriticalErrors.empty())
406399
mCriticalErrors += ", ";
407400
mCriticalErrors += msg.id;
408-
if (msg.severity == Severity::none) {
409-
mCriticalErrors += " (suppressed)";
410-
return;
411-
}
412401
}
413402

414403
if (mSettings.xml)

gui/resultstree.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -666,11 +666,6 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
666666
menu.addAction(hideallid);
667667

668668
QAction *suppress = new QAction(tr("Suppress selected id(s)"), &menu);
669-
{
670-
QVariantMap data = mContextItem->data().toMap();
671-
const QString messageId = data[ERRORID].toString();
672-
suppress->setEnabled(!ErrorLogger::isCriticalErrorId(messageId.toStdString()));
673-
}
674669
menu.addAction(suppress);
675670
connect(suppress, &QAction::triggered, this, &ResultsTree::suppressSelectedIds);
676671

gui/resultsview.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,6 @@ void ResultsView::error(const ErrorItem &item)
168168

169169
handleCriticalError(item);
170170

171-
if (item.severity == Severity::none)
172-
return;
173-
174171
if (mUI->mTree->addErrorItem(item)) {
175172
emit gotResults();
176173
mStatistics->addItem(item.tool(), ShowTypes::SeverityToShowType(item.severity));
@@ -565,14 +562,10 @@ void ResultsView::handleCriticalError(const ErrorItem &item)
565562
if (!mCriticalErrors.isEmpty())
566563
mCriticalErrors += ",";
567564
mCriticalErrors += item.errorId;
568-
if (item.severity == Severity::none)
569-
mCriticalErrors += " (suppressed)";
570565
}
571566
QString msg = tr("There was a critical error with id '%1'").arg(item.errorId);
572567
if (!item.file0.isEmpty())
573568
msg += ", " + tr("when checking %1").arg(item.file0);
574-
else
575-
msg += ", " + tr("when checking a file");
576569
msg += ". " + tr("Analysis was aborted.");
577570
mUI->mLabelCriticalErrors->setText(msg);
578571
mUI->mLabelCriticalErrors->setVisible(true);

htmlreport/check.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ validate_html "$INDEX_HTML"
4040
validate_html "$STATS_HTML"
4141

4242

43-
../cppcheck ../samples -i../samples/syntaxError/bad.c --enable=all --inconclusive --xml-version=2 2> "$GUI_TEST_XML"
43+
../cppcheck ../samples --enable=all --inconclusive --xml-version=2 2> "$GUI_TEST_XML"
4444
xmllint --noout "$GUI_TEST_XML"
4545
$PYTHON cppcheck-htmlreport --file "$GUI_TEST_XML" --title "xml2 + inconclusive test" --report-dir "$REPORT_DIR"
4646
echo ""
@@ -49,7 +49,7 @@ validate_html "$INDEX_HTML"
4949
validate_html "$STATS_HTML"
5050

5151

52-
../cppcheck ../samples -i../samples/syntaxError/bad.c --enable=all --inconclusive --verbose --xml-version=2 2> "$GUI_TEST_XML"
52+
../cppcheck ../samples --enable=all --inconclusive --verbose --xml-version=2 2> "$GUI_TEST_XML"
5353
xmllint --noout "$GUI_TEST_XML"
5454
$PYTHON cppcheck-htmlreport --file "$GUI_TEST_XML" --title "xml2 + inconclusive + verbose test" --report-dir "$REPORT_DIR"
5555
echo -e "\n"

lib/cppcheck.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,19 +1599,6 @@ void CppCheck::reportErr(const ErrorMessage &msg)
15991599
const auto errorMessage = Suppressions::ErrorMessage::fromErrorMessage(msg, macroNames);
16001600

16011601
if (mSettings.nomsg.isSuppressed(errorMessage, mUseGlobalSuppressions)) {
1602-
if (ErrorLogger::isCriticalErrorId(msg.id)) {
1603-
mExitCode = 1;
1604-
1605-
if (mSettings.nomsg.isSuppressedExplicitly(errorMessage, mUseGlobalSuppressions)) {
1606-
ErrorMessage temp;
1607-
temp.severity = Severity::none;
1608-
temp.id = msg.id;
1609-
mErrorLogger.reportErr(temp);
1610-
} else {
1611-
// Report critical error that is not explicitly suppressed
1612-
mErrorLogger.reportErr(msg);
1613-
}
1614-
}
16151602
return;
16161603
}
16171604

lib/settings.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,6 @@ class CPPCHECKLIB WARN_UNUSED Settings {
358358
/** @brief The maximum time in seconds for the typedef simplification */
359359
std::size_t typedefMaxTime{};
360360

361-
/** @brief Unsafe exitcode => do not force non-zero exitcode when there are critical errors */
362-
bool unsafeExitCode = false;
363-
364361
/** @brief defines given by the user */
365362
std::string userDefines;
366363

0 commit comments

Comments
 (0)