abicompat: Add prompt message for abnormal operation
Commit Message
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 (main): 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(-)
@@ -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;