abicompat: Add prompt message for abnormal operation

When using abicompat, if the --redundant option and --no-redundant
option are used at the same time, no error is prompted and none of the
options have an impact.

This patch emits an error message in that case.

	* 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>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
tangmeng 2021-11-05 17:38:28 +08:00 committed by Dodji Seketeli
parent c36f8028fd
commit 38d883cc74

View File

@ -71,6 +71,8 @@ public:
bool list_undefined_symbols_only;
bool show_base_names;
bool show_redundant;
bool redundant_opt_set;
bool no_redundant_opt_set;
bool show_locs;
options(const char* program_name)
@ -81,6 +83,8 @@ public:
list_undefined_symbols_only(),
show_base_names(),
show_redundant(true),
redundant_opt_set(),
no_redundant_opt_set(),
show_locs(true)
{}
}; // end struct options
@ -191,9 +195,15 @@ parse_command_line(int argc, char* argv[], options& opts)
++i;
}
else if (!strcmp(argv[i], "--redundant"))
{
opts.show_redundant = true;
opts.redundant_opt_set = true;
}
else if (!strcmp(argv[i], "--no-redundant"))
{
opts.show_redundant = false;
opts.no_redundant_opt_set = true;
}
else if (!strcmp(argv[i], "--no-show-locs"))
opts.show_locs = false;
else if (!strcmp(argv[i], "--help")
@ -645,6 +655,14 @@ main(int argc, char* argv[])
<< opts.lib2_path << " will be ignored automatically\n";
}
if (opts.redundant_opt_set && opts.no_redundant_opt_set)
{
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;