Re: [PATCH 4/7] run_command: report system call errors instead of returning error codes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Johannes Sixt schrieb:
>  	cmd->pid = mingw_spawnvpe(cmd->argv[0], cmd->argv, env);
> +	if (cmd->pid < 0 && errno != ENOENT)
> +		error("cannot spawn %s: %s", cmd->argv[0],
> +			strerror(failed_errno = errno));
>  
>  	if (cmd->env)
>  		free_environ(env);
> @@ -189,7 +203,6 @@ int start_command(struct child_process *cmd)
>  #endif
>  
>  	if (cmd->pid < 0) {
> -		int err = errno;
>  		if (need_in)
>  			close_pair(fdin);
>  		else if (cmd->in)
> @@ -200,9 +213,8 @@ int start_command(struct child_process *cmd)
>  			close(cmd->out);
>  		if (need_err)
>  			close_pair(fderr);
> -		return err == ENOENT ?
> -			-ERR_RUN_COMMAND_EXEC :
> -			-ERR_RUN_COMMAND_FORK;
> +		errno = failed_errno;
> +		return -1;
>  	}

Sorry to bother you once again. 'gcc -O2' correctly points out that
failed_errno could be used uninitialized (MinGW code path only).
Would you please squash this in?

-- Hannes

diff --git a/run-command.c b/run-command.c
--- a/run-command.c
+++ b/run-command.c
@@ -184,9 +184,9 @@ fail_pipe:
 	}

 	cmd->pid = mingw_spawnvpe(cmd->argv[0], cmd->argv, env);
+	failed_errno = errno;
 	if (cmd->pid < 0 && (!cmd->silent_exec_failure || errno != ENOENT))
-		error("cannot spawn %s: %s", cmd->argv[0],
-			strerror(failed_errno = errno));
+		error("cannot spawn %s: %s", cmd->argv[0], strerror(errno));

 	if (cmd->env)
 		free_environ(env);

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]