From: Vincent Bernat Date: Wed, 18 Mar 2015 13:12:58 +0000 (+0100) Subject: log: add token to all `fatalx` instances X-Git-Tag: 0.7.14~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a87db231990af317cfb07aa8f725a40c0aa45713;p=thirdparty%2Flldpd.git log: add token to all `fatalx` instances The inability to use a token is quite artificial. --- diff --git a/src/client/jansson_writer.c b/src/client/jansson_writer.c index e7663247..d367f8cd 100644 --- a/src/client/jansson_writer.c +++ b/src/client/jansson_writer.c @@ -225,7 +225,7 @@ jansson_init(FILE *fh) TAILQ_INSERT_TAIL(priv, root, next); root->el = json_object(); if (root->el == NULL) - fatalx("cannot create JSON root object"); + fatalx("lldpctl", "cannot create JSON root object"); result = malloc(sizeof(*result)); if (result == NULL) fatal(NULL, NULL); diff --git a/src/client/jsonc_writer.c b/src/client/jsonc_writer.c index 28e764b2..1e6d48ea 100644 --- a/src/client/jsonc_writer.c +++ b/src/client/jsonc_writer.c @@ -162,7 +162,7 @@ jsonc_init(FILE *fh) TAILQ_INSERT_TAIL(priv, root, next); root->el = json_object_new_object(); if (root->el == NULL) - fatalx("cannot create JSON root object"); + fatalx("lldpctl", "cannot create JSON root object"); result = malloc(sizeof(*result)); if (result == NULL) fatal(NULL, NULL); diff --git a/src/client/text_writer.c b/src/client/text_writer.c index 208211cc..68b772ac 100644 --- a/src/client/text_writer.c +++ b/src/client/text_writer.c @@ -126,7 +126,7 @@ txt_init(FILE* fh) { priv = malloc(sizeof(*priv)); if (!priv) { - fatalx("out of memory"); + fatalx("lldpctl", "out of memory"); return NULL; } @@ -136,7 +136,7 @@ txt_init(FILE* fh) { result = malloc(sizeof(struct writer)); if (!result) { - fatalx("out of memory"); + fatalx("llpctl", "out of memory"); free(priv); return NULL; } diff --git a/src/client/xml_writer.c b/src/client/xml_writer.c index 32ec285a..802390c1 100644 --- a/src/client/xml_writer.c +++ b/src/client/xml_writer.c @@ -91,26 +91,26 @@ struct writer * xml_init(FILE * fh) { priv = malloc( sizeof( *priv ) ); if ( ! priv ) { - fatalx("out of memory"); + fatalx("lldpctl", "out of memory"); return NULL; } priv->xw = xmlNewTextWriterDoc(&(priv->doc), 0); if ( ! priv->xw ) { - fatalx("cannot create xml writer"); + fatalx("lldpctl", "cannot create xml writer"); return NULL; } xmlTextWriterSetIndent(priv->xw, 4); if (xmlTextWriterStartDocument(priv->xw, NULL, MY_ENCODING, NULL) < 0 ) { - fatalx("cannot start xml document"); + fatalx("lldpctl", "cannot start xml document"); return NULL; } result = malloc( sizeof( struct writer ) ); if ( ! result ) { - fatalx("out of memory"); + fatalx("lldpctl", "out of memory"); return NULL; } diff --git a/src/daemon/event.c b/src/daemon/event.c index 1ac5b5b3..314d71b9 100644 --- a/src/daemon/event.c +++ b/src/daemon/event.c @@ -432,7 +432,7 @@ levent_init(struct lldpd *cfg) log_debug("event", "initialize libevent"); event_set_log_callback(levent_log_cb); if (!(cfg->g_base = event_base_new())) - fatalx("unable to create a new libevent base"); + fatalx("event", "unable to create a new libevent base"); log_info("event", "libevent %s initialized with %s method", event_get_version(), event_base_get_method(cfg->g_base)); @@ -445,10 +445,10 @@ levent_init(struct lldpd *cfg) levent_snmp_timeout, cfg); if (!cfg->g_snmp_timeout) - fatalx("unable to setup timeout function for SNMP"); + fatalx("event", "unable to setup timeout function for SNMP"); if ((cfg->g_snmp_fds = malloc(sizeof(struct ev_l))) == NULL) - fatalx("unable to allocate memory for SNMP events"); + fatalx("event", "unable to allocate memory for SNMP events"); TAILQ_INIT(levent_snmp_fds(cfg)); } #endif @@ -458,7 +458,7 @@ levent_init(struct lldpd *cfg) if (!(cfg->g_main_loop = event_new(cfg->g_base, -1, 0, levent_update_and_send, cfg))) - fatalx("unable to setup main timer"); + fatalx("event", "unable to setup main timer"); event_active(cfg->g_main_loop, EV_TIMEOUT, 1); /* Setup unix socket */ @@ -468,7 +468,7 @@ levent_init(struct lldpd *cfg) levent_make_socket_nonblocking(cfg->g_ctl); if ((ctl_event = event_new(cfg->g_base, cfg->g_ctl, EV_READ|EV_PERSIST, levent_ctl_accept, cfg)) == NULL) - fatalx("unable to setup control socket event"); + fatalx("event", "unable to setup control socket event"); event_add(ctl_event, NULL); /* Signals */ diff --git a/src/daemon/lldpd.c b/src/daemon/lldpd.c index 6a3a160d..9acc7db4 100644 --- a/src/daemon/lldpd.c +++ b/src/daemon/lldpd.c @@ -1517,7 +1517,7 @@ lldpd_main(int argc, char *argv[], char *envp[]) /* Another instance is running */ close(tfd); log_warnx("main", "another instance is running, please stop it"); - fatalx("giving up"); + fatalx("main", "giving up"); } else if (errno == ECONNREFUSED) { /* Nobody is listening */ log_info("main", "old control socket is present, clean it"); @@ -1525,10 +1525,10 @@ lldpd_main(int argc, char *argv[], char *envp[]) continue; } log_warn("main", "cannot determine if another daemon is already running"); - fatalx("giving up"); + fatalx("main", "giving up"); } log_warn("main", "unable to create control socket"); - fatalx("giving up"); + fatalx("main", "giving up"); } #ifdef ENABLE_PRIVSEP if (chown(ctlname, uid, gid) == -1) diff --git a/src/daemon/priv-seccomp.c b/src/daemon/priv-seccomp.c index c69d82a3..a47d9718 100644 --- a/src/daemon/priv-seccomp.c +++ b/src/daemon/priv-seccomp.c @@ -79,7 +79,7 @@ priv_seccomp_trap_handler(int signal, siginfo_t *info, void *vctx) /* Kill children and exit */ kill(monitored, SIGTERM); - fatalx("invalid syscall not allowed: stop here"); + fatalx("seccomp", "invalid syscall not allowed: stop here"); _exit(161); } diff --git a/src/daemon/priv.c b/src/daemon/priv.c index 92d7824c..0588fab0 100644 --- a/src/daemon/priv.c +++ b/src/daemon/priv.c @@ -418,7 +418,7 @@ priv_loop(int privileged, int once) } } if (a->function == NULL) - fatal("privsep", "bogus message received"); + fatalx("privsep", "bogus message received"); if (once) break; } } diff --git a/src/log.c b/src/log.c index 07ea08f2..4f266bfc 100644 --- a/src/log.c +++ b/src/log.c @@ -244,8 +244,8 @@ fatal(const char *token, const char *emsg) } void -fatalx(const char *emsg) +fatalx(const char *token, const char *emsg) { errno = 0; - fatal(NULL, emsg); + fatal(token, emsg); } diff --git a/src/log.h b/src/log.h index 94a122d0..df985857 100644 --- a/src/log.h +++ b/src/log.h @@ -25,7 +25,7 @@ void log_warnx(const char *, const char *, ...) __attribute__ ((form void log_info(const char *, const char *, ...) __attribute__ ((format (printf, 2, 3))); void log_debug(const char *, const char *, ...) __attribute__ ((format (printf, 2, 3))); void fatal(const char*, const char *) __attribute__((__noreturn__)); -void fatalx(const char *) __attribute__((__noreturn__)); +void fatalx(const char *, const char *) __attribute__((__noreturn__)); void log_register(void (*cb)(int, const char*)); void log_accept(const char *);