From: Timo Kokkonen Date: Mon, 7 Oct 2013 18:11:41 +0000 (+0300) Subject: Move time stamp initialization after first proper log entry is read X-Git-Url: http://git.itanic.dy.fi/?p=log-plotter;a=commitdiff_plain;h=79e21578d84f3fa874e7bb2d0dc4bc486bb70e0b 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 --- 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);