Skip to content

Commit a2f605f

Browse files
Peter Zijlstraingomolnar
authored andcommitted
objtool: Collate parse_options() users
Ensure there's a single place that parses check_options, in preparation for extending where to get options from. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com> Link: https://lkml.kernel.org/r/20210226110004.193108106@infradead.org
1 parent 8ad15c6 commit a2f605f

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

‎tools/objtool/builtin-check.c‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,21 @@ const struct option check_options[] = {
4242
OPT_END(),
4343
};
4444

45+
int cmd_parse_options(int argc, const char **argv, const char * const usage[])
46+
{
47+
argc = parse_options(argc, argv, check_options, usage, 0);
48+
if (argc != 1)
49+
usage_with_options(usage, check_options);
50+
return argc;
51+
}
52+
4553
int cmd_check(int argc, const char **argv)
4654
{
4755
const char *objname;
4856
struct objtool_file *file;
4957
int ret;
5058

51-
argc = parse_options(argc, argv, check_options, check_usage, 0);
52-
53-
if (argc != 1)
54-
usage_with_options(check_usage, check_options);
55-
59+
argc = cmd_parse_options(argc, argv, check_usage);
5660
objname = argv[0];
5761

5862
file = objtool_open_read(objname);

‎tools/objtool/builtin-orc.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ int cmd_orc(int argc, const char **argv)
3434
struct objtool_file *file;
3535
int ret;
3636

37-
argc = parse_options(argc, argv, check_options, orc_usage, 0);
38-
if (argc != 1)
39-
usage_with_options(orc_usage, check_options);
40-
37+
argc = cmd_parse_options(argc, argv, orc_usage);
4138
objname = argv[0];
4239

4340
file = objtool_open_read(objname);

‎tools/objtool/include/objtool/builtin.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ extern const struct option check_options[];
1111
extern bool no_fp, no_unreachable, retpoline, module, backtrace, uaccess, stats,
1212
validate_dup, vmlinux, mcount, noinstr, backup;
1313

14+
extern int cmd_parse_options(int argc, const char **argv, const char * const usage[]);
15+
1416
extern int cmd_check(int argc, const char **argv);
1517
extern int cmd_orc(int argc, const char **argv);
1618

0 commit comments

Comments
 (0)