syslog: remove unnecessary sizeof struct between messages
[project/ubox.git] / log / syslog.c
index 4cabb43..856fa60 100644 (file)
@@ -51,7 +51,7 @@ static regex_t pat_tstamp;
 static struct log_head*
 log_next(struct log_head *h, int size)
 {
-       struct log_head *n = (struct log_head *) &h->data[PAD(sizeof(struct log_head) + size)];
+       struct log_head *n = (struct log_head *) &h->data[PAD(size)];
 
        return (n >= log_end) ? (log) : (n);
 }
@@ -66,7 +66,7 @@ log_add(char *buf, int size, int source)
 
        /* bounce out if we don't have init'ed yet (regmatch etc will blow) */
        if (!log) {
-               fprintf(stderr, buf);
+               fprintf(stderr, "%s", buf);
                return;
        }
 
@@ -203,7 +203,7 @@ syslog_open(void)
        int fd;
 
        unlink(log_dev);
-       fd = usock(USOCK_UNIX | USOCK_UDP |  USOCK_SERVER | USOCK_NONBLOCK, log_dev, NULL);
+       fd = usock(USOCK_UNIX | USOCK_UDP | USOCK_SERVER | USOCK_NONBLOCK, log_dev, NULL);
        if (fd < 0) {
                fprintf(stderr,"Failed to open %s\n", log_dev);
                return -1;
@@ -299,4 +299,7 @@ log_shutdown(void)
        ustream_free(&klog.stream);
        close(slog.fd.fd);
        close(klog.fd.fd);
+       free(log);
+       regfree(&pat_prio);
+       regfree(&pat_tstamp);
 }