From: Guillem Jover Date: Sat, 28 Jun 2008 03:38:17 +0000 (+0300) Subject: libdpkg: Make checksubprocerr less deep and a bit more readable X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ec776bb1827cdd62cc626324bc51cfea38ef999;p=dpkg libdpkg: Make checksubprocerr less deep and a bit more readable Move the PROCNOERR check before the reporting, and exit directly instead in case of error. --- diff --git a/ChangeLog b/ChangeLog index a850820d..8226ee06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-06-28 Guillem Jover + + * lib/mlib.c (checksubprocerr): Move the PROCNOERR check before + the reporting, and exit directly instead in case of error. + 2008-06-28 Guillem Jover * lib/ehandle.c (badusage): Use ohshit instead of its own error diff --git a/lib/mlib.c b/lib/mlib.c index 976dc3ef..5f9cee41 100644 --- a/lib/mlib.c +++ b/lib/mlib.c @@ -123,12 +123,13 @@ int checksubprocerr(int status, const char *description, int flags) { int n; if (WIFEXITED(status)) { n= WEXITSTATUS(status); if (!n) return n; - if(!(flags & PROCNOERR)) { - if(flags & PROCWARN) - fprintf(stderr, _("dpkg: warning - %s returned error exit status %d\n"),description,n); - else - ohshit(_("subprocess %s returned error exit status %d"),description,n); - } + if (flags & PROCNOERR) + return -1; + if (flags & PROCWARN) + fprintf(stderr, _("dpkg: warning - %s returned error exit status %d\n"), + description, n); + else + ohshit(_("subprocess %s returned error exit status %d"), description, n); } else if (WIFSIGNALED(status)) { n= WTERMSIG(status); if (!n || ((flags & PROCPIPE) && n==SIGPIPE)) return 0; if (flags & PROCWARN)