2020-05-11 17:39:15

by Matt Helsley

[permalink] [raw]
Subject: [RFC][PATCH 1/5] objtool: Exit successfully when requesting help

When the user requests help it's not an error so do not exit with
a non-zero exit code. This is not especially useful for a user but
any script that might wish to check that objtool --help is at least
available can't rely on the exit code to crudely check that, for
example building an objtool executable succeeds.

Signed-off-by: Matt Helsley <[email protected]>
---
tools/objtool/objtool.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/objtool/objtool.c b/tools/objtool/objtool.c
index 0b3528f05053..593ec85915a9 100644
--- a/tools/objtool/objtool.c
+++ b/tools/objtool/objtool.c
@@ -58,7 +58,10 @@ static void cmd_usage(void)

printf("\n");

- exit(129);
+ if (!help)
+ exit(129);
+ else
+ exit(0);
}

static void handle_options(int *argc, const char ***argv)
--
2.20.1


2020-05-15 19:54:48

by Josh Poimboeuf

[permalink] [raw]
Subject: Re: [RFC][PATCH 1/5] objtool: Exit successfully when requesting help

On Mon, May 11, 2020 at 10:35:09AM -0700, Matt Helsley wrote:
> When the user requests help it's not an error so do not exit with
> a non-zero exit code. This is not especially useful for a user but
> any script that might wish to check that objtool --help is at least
> available can't rely on the exit code to crudely check that, for
> example building an objtool executable succeeds.
>
> Signed-off-by: Matt Helsley <[email protected]>
> ---
> tools/objtool/objtool.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tools/objtool/objtool.c b/tools/objtool/objtool.c
> index 0b3528f05053..593ec85915a9 100644
> --- a/tools/objtool/objtool.c
> +++ b/tools/objtool/objtool.c
> @@ -58,7 +58,10 @@ static void cmd_usage(void)
>
> printf("\n");
>
> - exit(129);
> + if (!help)
> + exit(129);
> + else
> + exit(0);

Looks fine, though the 'else' isn't needed.

--
Josh

2020-05-18 18:35:37

by Matt Helsley

[permalink] [raw]
Subject: Re: [RFC][PATCH 1/5] objtool: Exit successfully when requesting help

On Fri, May 15, 2020 at 02:52:53PM -0500, Josh Poimboeuf wrote:
> On Mon, May 11, 2020 at 10:35:09AM -0700, Matt Helsley wrote:
> > When the user requests help it's not an error so do not exit with
> > a non-zero exit code. This is not especially useful for a user but
> > any script that might wish to check that objtool --help is at least
> > available can't rely on the exit code to crudely check that, for
> > example building an objtool executable succeeds.
> >
> > Signed-off-by: Matt Helsley <[email protected]>
> > ---
> > tools/objtool/objtool.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/objtool/objtool.c b/tools/objtool/objtool.c
> > index 0b3528f05053..593ec85915a9 100644
> > --- a/tools/objtool/objtool.c
> > +++ b/tools/objtool/objtool.c
> > @@ -58,7 +58,10 @@ static void cmd_usage(void)
> >
> > printf("\n");
> >
> > - exit(129);
> > + if (!help)
> > + exit(129);
> > + else
> > + exit(0);
>
> Looks fine, though the 'else' isn't needed.

OK, removed the 'else'.

Cheers,
-Matt Helsley