The following commit has been merged in the master branch:
commit e61824e3e7d37d0b4fcf1e2128b709292a0867cb
Author: Guillem Jover <[email protected]>
Date: Thu Jan 20 18:21:38 2011 +0100
libdpkg: Refactor error output into a function variable in subproc_check()
This deduplicates two sets of identical strings.
diff --git a/lib/dpkg/subproc.c b/lib/dpkg/subproc.c
index b82248e..b4d5658 100644
--- a/lib/dpkg/subproc.c
+++ b/lib/dpkg/subproc.c
@@ -100,34 +100,31 @@ subproc_fork(void)
int
subproc_check(int status, const char *desc, int flags)
{
+ void (*out)(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
int n;
+ if (flags & PROCWARN)
+ out = warning;
+ else
+ out = ohshit;
+
if (WIFEXITED(status)) {
n = WEXITSTATUS(status);
if (!n)
return 0;
if (flags & PROCNOERR)
return n;
- if (flags & PROCWARN)
- warning(_("subprocess %s returned error exit status
%d"),
- desc, n);
- else
- ohshit(_("subprocess %s returned error exit status %d"),
- desc, n);
+
+ out(_("subprocess %s returned error exit status %d"), desc, n);
} else if (WIFSIGNALED(status)) {
n = WTERMSIG(status);
if (!n)
return 0;
if ((flags & PROCPIPE) && n == SIGPIPE)
return 0;
- if (flags & PROCWARN)
- warning(_("subprocess %s killed by signal (%s)%s"),
- desc, strsignal(n),
- WCOREDUMP(status) ? _(", core dumped") : "");
- else
- ohshit(_("subprocess %s killed by signal (%s)%s"),
- desc, strsignal(n),
- WCOREDUMP(status) ? _(", core dumped") : "");
+
+ out(_("subprocess %s killed by signal (%s)%s"), desc,
+ strsignal(n), WCOREDUMP(status) ? _(", core dumped") : "");
} else {
ohshit(_("subprocess %s failed with wait status code %d"),
desc, status);
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]