diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2011-04-18 10:13:24 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2011-04-18 10:20:19 +0300 |
commit | 1a89593cd04d464dc5f7306482c0bb5a0b71e819 (patch) | |
tree | efd08c307a2d76c95fe93116a22b56928e1cfcf9 /rpmio | |
parent | ac524256f7d3f745a5c441e742ed93bc2c8047ef (diff) | |
download | librpm-tizen-1a89593cd04d464dc5f7306482c0bb5a0b71e819.tar.gz librpm-tizen-1a89593cd04d464dc5f7306482c0bb5a0b71e819.tar.bz2 librpm-tizen-1a89593cd04d464dc5f7306482c0bb5a0b71e819.zip |
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
Diffstat (limited to 'rpmio')
-rw-r--r-- | rpmio/rpmurl.h | 2 | ||||
-rw-r--r-- | rpmio/url.c | 11 |
2 files changed, 6 insertions, 7 deletions
diff --git a/rpmio/rpmurl.h b/rpmio/rpmurl.h index 3384bc4ff..e820e95e7 100644 --- a/rpmio/rpmurl.h +++ b/rpmio/rpmurl.h @@ -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); diff --git a/rpmio/url.c b/rpmio/url.c index c609fd1b4..fc31f36a7 100644 --- a/rpmio/url.c +++ b/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; } |