summaryrefslogtreecommitdiffstats
path: root/log.c
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2013-04-25 21:37:25 +0200
committerJohn Crispin <blogic@openwrt.org>2013-04-25 21:40:08 +0200
commitc28ba8c1947e1b31874bf5888742d1607ed7ae61 (patch)
treebf3813816f56c72ae46048f78b1955ba34cbabd0 /log.c
parent7edfbb45edcf275a855f5e1f5cc24cac81e382ff (diff)
downloadunitd-c28ba8c1947e1b31874bf5888742d1607ed7ae61.tar
unitd-c28ba8c1947e1b31874bf5888742d1607ed7ae61.zip
fix 32 wrap around bug when handling 64 bit time values
Signed-off-by: John Crispin <blogic@openwrt.org>
Diffstat (limited to 'log.c')
-rw-r--r--log.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/log.c b/log.c
index d2a7158..82fb8f8 100644
--- a/log.c
+++ b/log.c
@@ -12,6 +12,8 @@
* GNU General Public License for more details.
*/
+#include <linux/types.h>
+
#include <libubox/uloop.h>
#include <libubox/blobmsg_json.h>
@@ -56,7 +58,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 +118,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)