From: Panu Matilainen Date: Mon, 18 Apr 2011 07:13:24 +0000 (+0300) Subject: Clean up urlGetFile() return values X-Git-Tag: tznext/4.11.0.1.tizen20130304~1207 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1a89593cd04d464dc5f7306482c0bb5a0b71e819;p=tools%2Flibrpm-tizen.git 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 --- diff --git a/rpmio/rpmurl.h b/rpmio/rpmurl.h index 3384bc4..e820e95 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 c609fd1..fc31f36 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; }