[PATCH] elfcompress: fix exit status in case of an error
Wed May 12 21:13:08 GMT 2021
On Wed, May 12, 2021 at 11:35:27PM +0300, Dmitry V. Levin wrote:
> On Wed, May 12, 2021 at 10:29:33PM +0200, Mark Wielaard wrote:
> > On Wed, May 12, 2021 at 04:00:00PM +0000, Dmitry V. Levin wrote:
> > > Exit status of 255 in case of an error is probably not what elfcompress
> > > users expect, change it to 1.
> > >
> > > Reported-by: Vitaly Chikunov <email@example.com>
> > > Fixes: 92acb57eb046 ("elfcompress: New utility.")
> > > [...]
> > > diff --git a/src/elfcompress.c b/src/elfcompress.c
> > > index 05f3bc2c..dacaff32 100644
> > > --- a/src/elfcompress.c
> > > +++ b/src/elfcompress.c
> > > @@ -1358,5 +1358,5 @@ main (int argc, char **argv)
> > > while (++remaining < argc);
> > >
> > > free_patterns ();
> > > - return result;
> > > + return !!result;
> > > }
> > The change to return 1 (or zero) is good.
> > But could we instead initialize res to 1
> That is, change process_file() to return 1 (or EXIT_FAILURE)
> instead of -1 in case of an error?
Yes. I admit I assumed this was already in process_file. But this is
really just a nitpick because I always get confused when reading the
!! pattern. The important part returning zero or one from main.
More information about the Elfutils-devel