fix timestamp parsing
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 7 May 2011 20:09:40 +0000 (16:09 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 7 May 2011 20:09:40 +0000 (16:09 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
converter/babeltrace-log.c

index b2935ac9fa488cc3406549df69eebea9cf035c47..711937352eea3c884f774178ad7076aaef05c11e 100644 (file)
@@ -35,7 +35,7 @@
 #include <babeltrace/babeltrace.h>
 #include <babeltrace/ctf/types.h>
 
-#define NSEC_PER_SEC 1000000UL
+#define USEC_PER_SEC 1000000UL
 
 #ifndef UUID_STR_LEN
 #define UUID_STR_LEN   37      /* With \0 */
@@ -154,7 +154,7 @@ void write_event_header(struct ctf_stream_pos *pos, char *line,
                        char **tline, size_t len, size_t *tlen,
                        uint64_t *ts)
 {
-       unsigned long sec, nsec;
+       unsigned long sec, usec;
        int ret;
 
        if (!s_timestamp)
@@ -163,13 +163,16 @@ void write_event_header(struct ctf_stream_pos *pos, char *line,
        /* Only need to be executed on first pass (dummy) */
        if (pos->dummy) {
                /* Extract time from input line */
-               ret = sscanf(line, "[%lu.%lu] ", &sec, &nsec);
+               ret = sscanf(line, "[%lu.%lu] ", &sec, &usec);
                if (ret == 2) {
                        *tline = strchr(line, ']');
-                       if ((*tline)[1] == ' ')
+                       assert(*tline);
+                       (*tline)++;
+                       if ((*tline)[0] == ' ') {
                                (*tline)++;
+                       }
                        *tlen = len + line - *tline;
-                       *ts = (uint64_t) sec * NSEC_PER_SEC + (uint64_t) nsec;
+                       *ts = (uint64_t) sec * USEC_PER_SEC + (uint64_t) usec;
                }
        }
        /* timestamp */
This page took 0.024745 seconds and 4 git commands to generate.