]> git.itanic.dy.fi Git - log-plotter/commitdiff
Move time stamp initialization after first proper log entry is read
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Mon, 7 Oct 2013 18:11:41 +0000 (21:11 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Mon, 7 Oct 2013 18:11:41 +0000 (21:11 +0300)
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 <timo.t.kokkonen@iki.fi>
main.c

diff --git a/main.c b/main.c
index 8e145218aa4e463c88e5ecbf33914cae58c93655..e017fadc92fa7f8ad835e02d0aeefd36143c6c0e 100644 (file)
--- 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);