Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH 2/2] Fix two C nits
- X-seq: zsh-workers 43063
- From: Eitan Adler <lists@xxxxxxxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: [PATCH 2/2] Fix two C nits
- Date: Mon, 18 Jun 2018 22:31:43 -0700
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eitanadler.com; s=0xdeadbeef; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=2cXZGpFgK83f5YYm7lTpO35Uhopha/+nETSESkV2IIc=; b=tagaSog1pNCHhLHWDYxPoztSbrvoksoRl8bt2P3M8I7KzZs3yxNWAZse9alEUQ6SxN yzes6nxqJo5ZJ0PhY2y3Z674Nygprw5wosooylIlWIyz7c7L2xPOXnPA/djakl8/N36N xInwdA0Sgkyv9HdUNxFDOe8GRQWB+UuyMKi2A=
- In-reply-to: <20180618092243eucas1p133cc109ed17712cd4253a72da472fa54~5NsPXgtMr0676306763eucas1p1g@eucas1p1.samsung.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CGME20180616021439epcas4p327f4346b40d9e10d94ce055058fe0d71@epcas4p3.samsung.com> <20180616010427.2916-2-lists@eitanadler.com> <20180618092243eucas1p133cc109ed17712cd4253a72da472fa54~5NsPXgtMr0676306763eucas1p1g@eucas1p1.samsung.com>
On 18 June 2018 at 02:22, Peter Stephenson <p.stephenson@xxxxxxxxxxx> 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;
>> }
>
> I'm not 100% sure about this since you're relying on the compiler
> knowing that _exit won't return. Probably the majority of compilers
> we're involved with for zsh will work that out, but I'm not sure
> it's actually required by the C standard that they know the function
> doesn't return, is it? You may know some corner I haven't investigated.
It is only required that any function either return, exit, or loop
forever [0]. While I don't much about non-modern compilers, it
shouldn't affect anything to remove the return. At best, it'll do
nothing. At worst older compilers might incorrectly issue a
diagnostic. IMHO we should defer to modern compilers when it comes to
diagnostics provided the more esoteric options still work.
> I'd have been tempted to add /*NOTREACHED*/ on the next line.
[0] there is some interesting ancient nuance here, but it's not
important for this discussion.
--
Eitan Adler
Messages sorted by:
Reverse Date,
Date,
Thread,
Author