git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] run-command: mark path lookup errors with ENOENT

From
Jeff King <peff@peff.net>
Date
Oct 24, 2018, 09:16 UTC
Message-ID
<20181024091617.GA25118@sigill.intra.peff.net>
In-Reply-To
<nycvar.QRO.7.76.6.1810241054110.4546@tvgsbejvaqbjf.bet>
On Wed, Oct 24, 2018 at 11:01:54AM +0200, Johannes Schindelin wrote:
Show 12 quoted lines
> > @@ -910,6 +921,7 @@ int start_command(struct child_process *cmd)
> >  }
> >  #endif
> >  
> > +end_of_spawn:
> 
> Sadly, this fails to build on Windows:
> 
> 	run-command.c: In function 'start_command':
> 	run-command.c:924:1: error: label 'end_of_spawn' defined but not used [-Werror=unused-label]
> 	 end_of_spawn:
> 	 ^~~~~~~~~~~~
Doh. I didn't think of that.
Show 19 quoted lines
> How about squashing in this diff:
> 
> -- snip --
> diff --git a/run-command.c b/run-command.c
> index 639ea5ac3366..3f03795a5995 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -918,6 +918,8 @@ int start_command(struct child_process *cmd)
>  		close(fhout);
>  	if (fherr != 2)
>  		close(fherr);
> +
> +	goto end_of_spawn;
>  }
>  #endif
>  
> -- snap --
> 
> I can confirm that the result compiles and passes t0061.

That leaves the Windows side of the #else with a funny, useless goto (and without even a matching useless one on the Unix side). Let's put it instead inside the half of the #if that actually uses it. Like so (actually courtesy of Jonathan Nieder):

diff --git a/run-command.c b/run-command.c
index 639ea5ac33..d679cc267c 100644
--- a/run-command.c
+++ b/run-command.c
@@ -868,6 +868,8 @@ int start_command(struct child_process *cmd)
 	argv_array_clear(&argv);
 	free(childenv);
 }
+end_of_spawn:
+
 #else
 {
 	int fhin = 0, fhout = 1, fherr = 2;
@@ -921,7 +923,6 @@ int start_command(struct child_process *cmd)
 }
 #endif
 
-end_of_spawn:
 	if (cmd->pid < 0) {
 		if (need_in)
 			close_pair(fdin);

Thanks for your review!

-Peff
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 7 of 8 in “run-command: fix Unix PATH lookup”
  1. 0/2 run-command: fix Unix PATH lookupJeff King, Oct 24, 2018
  2. 1/2 t5410: use longer path for sample scriptJeff King, Oct 24, 2018
  3. Johannes SchindelinOct 24, 2018
  4. Junio C HamanoOct 25, 2018
  5. 2/2 run-command: mark path lookup errors with ENOENTJeff King, Oct 24, 2018
  6. Johannes SchindelinOct 24, 2018
  7. Jeff KingOct 24, 2018
  8. Johannes SchindelinOct 24, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.