syslog: fix incorrect use of sizeof() in vsnprintf()
[project/procd.git] / log.c
diff --git a/log.c b/log.c
index d2a7158..d367388 100644 (file)
--- a/log.c
+++ b/log.c
  * GNU General Public License for more details.
  */
 
+#include <linux/types.h>
+
 #include <libubox/uloop.h>
 #include <libubox/blobmsg_json.h>
 
 #include "procd.h"
 #include "syslog.h"
 
-static struct ubus_subscriber log_event;
-
 static int notify;
 struct ubus_context *_ctx;
 static struct blob_buf b;
@@ -56,7 +56,7 @@ static int read_log(struct ubus_context *ctx, struct ubus_object *obj,
                blobmsg_add_u32(&b, "id", l->id);
                blobmsg_add_u32(&b, "priority", l->priority);
                blobmsg_add_u32(&b, "source", l->source);
-               blobmsg_add_u64(&b, "time", (l->ts.tv_sec * 1000) + (l->ts.tv_nsec / 1000000));
+               blobmsg_add_u64(&b, "time", l->ts.tv_sec);
                blobmsg_close_table(&b, entry);
                l = log_list(count, l);
        }
@@ -116,7 +116,7 @@ void ubus_notify_log(struct log_head *l)
        blobmsg_add_u32(&b, "id", l->id);
        blobmsg_add_u32(&b, "priority", l->priority);
        blobmsg_add_u32(&b, "source", l->source);
-       blobmsg_add_u64(&b, "time", (l->ts.tv_sec * 1000) + (l->ts.tv_nsec / 1000000));
+       blobmsg_add_u64(&b, "time", (((__u64) l->ts.tv_sec) * 1000) + (l->ts.tv_nsec / 1000000));
 
        ret = ubus_notify(_ctx, &log_object, l->data, b.head, -1);
        if (ret)
@@ -132,8 +132,4 @@ void ubus_init_log(struct ubus_context *ctx)
        ret = ubus_add_object(ctx, &log_object);
        if (ret)
                ERROR("Failed to add object: %s\n", ubus_strerror(ret));
-
-       ret = ubus_register_subscriber(ctx, &log_event);
-       if (ret)
-               ERROR("Failed to add watch handler: %s\n", ubus_strerror(ret));
 }