From 79e21578d84f3fa874e7bb2d0dc4bc486bb70e0b Mon Sep 17 00:00:00 2001 From: Timo Kokkonen Date: Mon, 7 Oct 2013 21:11:41 +0300 Subject: [PATCH] Move time stamp initialization after first proper log entry is read If we initialize the time stamp too early, the first log entry that we read will not have zero as its timestamp. Move the initialization after we know the data is valid to avoid the problem. Signed-off-by: Timo Kokkonen --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 8e14521..e017fad 100644 --- a/main.c +++ b/main.c @@ -100,9 +100,6 @@ static int read_data(int infd, int outfd) return -1; } - if (!start_time) - start_time = time(NULL); - ret = read_log_line(infd, buf, sizeof(buf), &offset); if (ret < 0) return ret; @@ -116,6 +113,9 @@ static int read_data(int infd, int outfd) continue; } + if (!start_time) + start_time = time(NULL); + cur_time = time(NULL); pr_info("%s\n", buf); -- 2.45.0