Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH 2/2] Fix two C nits



On Tue, 19 Jun 2018 15:46:29 +0200
Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
> On 2018-06-18 10:22:41 +0100, Peter Stephenson wrote:
> > On Sat, 16 Jun 2018 01:04:27 +0000
> > Eitan Adler <lists@xxxxxxxxxxxxxx> wrote:  
> > > - avoid returning from a function that will never return
> > >
> > > diff --git a/Src/exec.c b/Src/exec.c
> > > index d44527841..b36bcef64 100644
> > > --- a/Src/exec.c
> > > +++ b/Src/exec.c
> > > @@ -4954,7 +4954,6 @@ getpipe(char *cmd, int nullexec)
> > >      execode(prog, 0, 1, out ? "outsubst" : "insubst");
> > >      cmdpop();
> > >      _exit(lastval);
> > > -    return 0;
> > >  }  
>
> The _exit function is non-standard.

That means from the basic C point of view it's not safe simply to remove
the return.  We are not in the game of guessing what the compiler knows.

As the code's uambiguously correct as it is, and the compiler is
perfectly at liberty to optimise out the return if it knows the function
won't return, it can stay as it is.

Anything we *can* detect about the compiler / configuration is
fair game for improvement, however...

pws



Messages sorted by: Reverse Date, Date, Thread, Author