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 16:38:34 +0200
Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
> It's safe because whether the "return 0;" line is here or not, this
> will not change the behavior since this line is not reachable (even
> if the compiler doesn't know this).
> 
> If the compiler doesn't know that _exit never returns, it will
> typically add an instruction corresponding to the "return 0;",

If I were a compiler and I saw

static int getpipe(char *cmd, int nullexec)
{
   /* ... blah ... */
   some_random_function();
}

I would immediately warn about missing return values --- indeed, gcc
does this with functions it hasn't been told about as I tested:

gcc_return.c:14:1: warning: no return statement in function returning non-void [-Wreturn-type]

so we've taken a step back in terms of clean code (even if gcc itself
isn't the problem on a typical GNU-based system where it does know about
_exit).

Anyway, I've completely lost interest in this non-issue with what's
currently entirely valid code and don't propose to discuss it further.

pws



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