From: Petr Machata Date: Wed, 15 Sep 2010 21:31:18 +0000 (+0200) Subject: dwarflint: Only warn about unused rules if we had a chance to match them X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3b7732442455a53dbf61ab1e045dd3f4d5305320;p=thirdparty%2Felfutils.git dwarflint: Only warn about unused rules if we had a chance to match them --- diff --git a/dwarflint/main.cc b/dwarflint/main.cc index d82c8c8d8..53a61a444 100644 --- a/dwarflint/main.cc +++ b/dwarflint/main.cc @@ -198,6 +198,7 @@ main (int argc, char *argv[]) /* Now process all the files given at the command line. */ bool only_one = remaining + 1 == argc; + bool one_passed = false; do { try @@ -208,6 +209,7 @@ main (int argc, char *argv[]) if (!only_one) std::cout << std::endl << fname << ":" << std::endl; dwarflint lint (fname, check_option.rules); + one_passed = true; if (prev_error_count == error_count && !be_quiet) puts (gettext ("No errors")); @@ -220,11 +222,12 @@ main (int argc, char *argv[]) } while (++remaining < argc); - for (checkrules::const_iterator it = check_option.rules.begin (); - it != check_option.rules.end (); ++it) - if (!it->used ()) - std::cerr << "warning: the rule `" << it->name () - << "' never matched." << std::endl; + if (one_passed) + for (checkrules::const_iterator it = check_option.rules.begin (); + it != check_option.rules.end (); ++it) + if (!it->used ()) + std::cerr << "warning: the rule `" << it->name () + << "' never matched." << std::endl; return error_count != 0; } diff --git a/dwarflint/tests/run-nodebug.sh b/dwarflint/tests/run-nodebug.sh index 346d9d8cb..5bfc2c552 100755 --- a/dwarflint/tests/run-nodebug.sh +++ b/dwarflint/tests/run-nodebug.sh @@ -46,3 +46,26 @@ EOF testrun_compare ./dwarflint --check=oentuh -q nodebug <