From 3ec776bb1827cdd62cc626324bc51cfea38ef999 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 28 Jun 2008 06:38:17 +0300 Subject: [PATCH] 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. --- ChangeLog | 5 +++++ lib/mlib.c | 13 +++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) 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) -- 2.39.5