]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
log: add token to all `fatalx` instances
authorVincent Bernat <vincent@bernat.im>
Wed, 18 Mar 2015 13:12:58 +0000 (14:12 +0100)
committerVincent Bernat <vincent@bernat.im>
Wed, 18 Mar 2015 13:12:58 +0000 (14:12 +0100)
The inability to use a token is quite artificial.

src/client/jansson_writer.c
src/client/jsonc_writer.c
src/client/text_writer.c
src/client/xml_writer.c
src/daemon/event.c
src/daemon/lldpd.c
src/daemon/priv-seccomp.c
src/daemon/priv.c
src/log.c
src/log.h

index e76632476497846a1c48c5931f7b044359044a82..d367f8cd6b69beea803671c38a6efe88480badfb 100644 (file)
@@ -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);
index 28e764b2db4436b36cfd4b523b199c7744cc43a7..1e6d48ea807b52401206f898d227dec057a99c8b 100644 (file)
@@ -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);
index 208211cc8ec3a76dd35fa56d2d4e5551a2f17732..68b772acc070bb704888b5558679d347163837d3 100644 (file)
@@ -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;
        }
index 32ec285a3b2e78662e1f1d0524f77a86365b1cd6..802390c11c1aa9ee78ad4800648c84955561a366 100644 (file)
@@ -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;
        }
 
index 1ac5b5b3d4c8c7cda778bf680b3da697d2458112..314d71b91d62ab74716a191b7d581cae4521841d 100644 (file)
@@ -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 */
index 6a3a160d6354b71c049fd9ab9a4b1333b9e1d1d4..9acc7db49018f01631514455c737a9a000d71054 100644 (file)
@@ -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)
index c69d82a34db9c2c25b12167f33690db54656ffa5..a47d97185ce590881ca06fcac4bc95403e279666 100644 (file)
@@ -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);
 }
 
index 92d7824c596d15525dae446cd5bbdcd2160fb12b..0588fab06c4cb0af14aaacb7b6e5891b633d4c5c 100644 (file)
@@ -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;
        }
 }
index 07ea08f20e5248285431d386c283ec7f0bf0a43a..4f266bfcf93243df10a5187bc82c65480477f6b6 100644 (file)
--- 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);
 }
index 94a122d01abf6f6812986ced1a1d219fe1913a76..df9858579358931ce2eb7fac07afdbd51eb73ec3 100644 (file)
--- 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 *);