public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: tangmeng <tangmeng@uniontech.com>
To: libabigail@sourceware.org
Cc: tangmeng <tangmeng@uniontech.com>
Subject: [PATCH v2] abicompat: Add prompt message for abnormal operation
Date: Fri,  5 Nov 2021 17:38:28 +0800	[thread overview]
Message-ID: <20211105093828.15377-1-tangmeng@uniontech.com> (raw)

When using abicompat, if the --redundant option and --no-redundant
option are used at the same time, no error will be prompted, the
actual option will prevail.

This patch provides a error to notify the user that error.

        * tools/abicompat.cc (parse_command_line): Notify the user when --redundant
        and --no-redundant are used at the same time

Signed-off-by: tangmeng <tangmeng@uniontech.com>
---
 tools/abicompat.cc | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/tools/abicompat.cc b/tools/abicompat.cc
index cf944a49..de5043ea 100644
--- a/tools/abicompat.cc
+++ b/tools/abicompat.cc
@@ -71,6 +71,8 @@ public:
   bool			list_undefined_symbols_only;
   bool			show_base_names;
   bool			show_redundant;
+  bool			seted_redundant;
+  bool			seted_no_redundant;
   bool			show_locs;
 
   options(const char* program_name)
@@ -191,9 +193,15 @@ parse_command_line(int argc, char* argv[], options& opts)
 	  ++i;
 	}
       else if (!strcmp(argv[i], "--redundant"))
-	opts.show_redundant = true;
+        {
+	  opts.show_redundant = true;
+	  opts.seted_redundant = true;
+	}
       else if (!strcmp(argv[i], "--no-redundant"))
-	opts.show_redundant = false;
+        {
+  	  opts.show_redundant = false;
+	  opts.seted_no_redundant = true;
+	}
       else if (!strcmp(argv[i], "--no-show-locs"))
 	opts.show_locs = false;
       else if (!strcmp(argv[i], "--help")
@@ -645,6 +653,14 @@ main(int argc, char* argv[])
 	<< opts.lib2_path << " will be ignored automatically\n";
     }
 
+  if (opts.seted_redundant && opts.seted_no_redundant)
+    {
+      emit_prefix(argv[0], cerr)
+        << "ERROR: The \'--redundant\' and '--no-redundant' option are in conflict. "
+	<< "Please select only one option to use.\n";
+      return 1;
+    }
+
   ABG_ASSERT(!opts.app_path.empty());
   if (!abigail::tools_utils::check_file(opts.app_path, cerr, opts.prog_name))
     return abigail::tools_utils::ABIDIFF_ERROR;
-- 
2.20.1




             reply	other threads:[~2021-11-05  9:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-05  9:38 tangmeng [this message]
2021-11-09 10:18 ` Dodji Seketeli
  -- strict thread matches above, loose matches on Subject: below --
2021-10-29  9:23 tangmeng
2021-11-02  9:18 ` Dodji Seketeli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211105093828.15377-1-tangmeng@uniontech.com \
    --to=tangmeng@uniontech.com \
    --cc=libabigail@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).