summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2008-10-15 09:34:36 +0300
committerGuillem Jover <guillem@debian.org>2008-11-14 09:09:44 +0200
commit9080bf737b8beb5b34efb7546e39857787412e23 (patch)
tree04b9043d823cc94c126ef4f7a43e411d2bc0969b /lib
parent3a451882182f648f23e46957dd1255d957ff2116 (diff)
downloaddpkg-9080bf737b8beb5b34efb7546e39857787412e23.tar.gz
libdpkg: Refactor error handler execution code
Move all longjmp calls to a new run_error_handler function.
Diffstat (limited to 'lib')
-rw-r--r--lib/ehandle.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/ehandle.c b/lib/ehandle.c
index 5d857ede2..fbd69c283 100644
--- a/lib/ehandle.c
+++ b/lib/ehandle.c
@@ -70,6 +70,14 @@ void set_error_display(error_printer *printerror,
econtext->contextstring= contextstring;
}
+static void run_error_handler(void) NONRETURNING;
+
+static void
+run_error_handler(void)
+{
+ longjmp(*econtext->jbufp, 1);
+}
+
void push_error_handler(jmp_buf *jbufp,
error_printer *printerror,
const char *contextstring) {
@@ -80,7 +88,8 @@ void push_error_handler(jmp_buf *jbufp,
snprintf(errmsgbuf, sizeof(errmsgbuf), "%s%s",
_("out of memory pushing error handler: "), strerror(e));
errmsg= errmsgbuf;
- if (econtext) longjmp(*econtext->jbufp,1);
+ if (econtext)
+ run_error_handler();
fprintf(stderr, "%s: %s\n", thisname, errmsgbuf); exit(2);
}
necp->next= econtext;
@@ -219,7 +228,8 @@ void ohshit(const char *fmt, ...) {
vsnprintf(errmsgbuf,sizeof(errmsgbuf),fmt,al);
va_end(al);
errmsg= errmsgbuf;
- longjmp(*econtext->jbufp,1);
+
+ run_error_handler();
}
void print_error_fatal(const char *emsg, const char *contextstring) {
@@ -232,13 +242,15 @@ void ohshitvb(struct varbuf *vb) {
m= m_malloc(strlen(vb->buf));
strcpy(m,vb->buf);
errmsg= m;
- longjmp(*econtext->jbufp,1);
+
+ run_error_handler();
}
void ohshitv(const char *fmt, va_list al) {
vsnprintf(errmsgbuf,sizeof(errmsgbuf),fmt,al);
errmsg= errmsgbuf;
- longjmp(*econtext->jbufp,1);
+
+ run_error_handler();
}
void ohshite(const char *fmt, ...) {
@@ -253,7 +265,8 @@ void ohshite(const char *fmt, ...) {
snprintf(errmsgbuf,sizeof(errmsgbuf),"%s: %s",buf,strerror(e));
errmsg= errmsgbuf;
- longjmp(*econtext->jbufp,1);
+
+ run_error_handler();
}
void warningf(const char *fmt, ...) {