Clean up urlGetFile() return values
- Its callers only care about success vs failure, so only ever return 0 or -1 and take waitpid() errors into account too. As a side effect shuts up a set-but-unused compiler warning too
This commit is contained in:
parent
ac524256f7
commit
1a89593cd0
|
@ -41,7 +41,7 @@ urltype urlPath(const char * url, const char ** pathp);
|
|||
* Copy data from URL to local file.
|
||||
* @param url url string of source
|
||||
* @param dest file name of destination
|
||||
* @return 0 on success, otherwise FTPERR_* code
|
||||
* @return 0 on success, -1 on error
|
||||
*/
|
||||
int urlGetFile(const char * url, const char * dest);
|
||||
|
||||
|
|
11
rpmio/url.c
11
rpmio/url.c
|
@ -97,8 +97,8 @@ int urlGetFile(const char * url, const char * dest)
|
|||
char *cmd = NULL;
|
||||
const char *target = NULL;
|
||||
char *urlhelper = NULL;
|
||||
int rc;
|
||||
pid_t pid, wait;
|
||||
int status;
|
||||
pid_t pid;
|
||||
|
||||
urlhelper = rpmExpand("%{?_urlhelper}", NULL);
|
||||
|
||||
|
@ -119,9 +119,8 @@ int urlGetFile(const char * url, const char * dest)
|
|||
execvp(argv[0], argv);
|
||||
exit(127); /* exit with 127 for compatibility with bash(1) */
|
||||
}
|
||||
wait = waitpid(pid, &rc, 0);
|
||||
cmd = _free(cmd);
|
||||
|
||||
return rc;
|
||||
free(cmd);
|
||||
|
||||
return ((waitpid(pid, &status, 0) != -1) &&
|
||||
WIFEXITED(status) && (WEXITSTATUS(status) == 0)) ? 0 : -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue