Re: [PATCH] compat/mingw.[ch]: Change return type of exec functions to int
- From
Jeff King <peff@peff.net>
- Date
- Apr 6, 2012, 00:24 UTC
- Message-ID
- <20120406002454.GB14224@sigill.intra.peff.net>
- In-Reply-To
- <20120405223408.GA13910@burratino>
On Thu, Apr 05, 2012 at 05:34:36PM -0500, Jonathan Nieder wrote:
Show 18 quoted lines
> > --- a/run-command.c
> > +++ b/run-command.c
> > @@ -117,8 +117,11 @@ static int exists_in_PATH(const char *file)
> >
> > int sane_execvp(const char *file, char * const argv[])
> > {
> > - if (!execvp(file, argv))
> > - return 0;
> > + /*
> > + * No need to check the return value; if it returns at all, an error
> > + * occurred.
> > + */
> > + execvp(file, argv);
> >
>
> I'd rather have the "return 0" then. Such a comment that focuses on C
> library details rather than providing additional information for
> understanding the sane_execvp function is distracting.I think both (attempt to) document the same thing: that if we get past execvp, we know are in error-checking mode. Which is not explicitly said anywhere. So maybe:
diff --git a/run-command.c b/run-command.c index 7123436..e6ece79 100644 --- a/run-command.c +++ b/run-command.c @@ -117,10 +117,12 @@ static int exists_in_PATH(const char *file) int sane_execvp(const char *file, char * const argv[]) { - if (!execvp(file, argv)) - return 0; + execvp(file, argv); /* + * If we are still running, we know an error occurred; let's try to + * diagnose it more specifically. + * * When a command can't be found because one of the directories * listed in $PATH is unsearchable, execvp reports EACCES, but * careful usability testing (read: analysis of occasional bug