perf tools: Use O_LARGEFILE to open perf data file
[safe/jmp/linux-2.6] / tools / perf / util / trace-event-read.c
index 44292e0..ca3c26d 100644 (file)
@@ -83,7 +83,7 @@ static char *read_string(void)
        char *str = NULL;
        int size = 0;
        int i;
-       int r;
+       s64 r;
 
        for (;;) {
                r = read(input_fd, buf, BUFSIZ);
@@ -117,7 +117,7 @@ static char *read_string(void)
        i++;
 
        /* move the file descriptor to the end of the string */
-       r = lseek(input_fd, -(r - i), SEEK_CUR);
+       r = lseek64(input_fd, -(r - i), SEEK_CUR);
        if (r < 0)
                die("lseek");
 
@@ -145,8 +145,9 @@ static void read_proc_kallsyms(void)
        if (!size)
                return;
 
-       buf = malloc_or_die(size);
+       buf = malloc_or_die(size + 1);
        read_or_die(buf, size);
+       buf[size] = '\0';
 
        parse_proc_kallsyms(buf, size);
 
@@ -471,11 +472,11 @@ void trace_report(int fd)
 
        read_or_die(buf, 3);
        if (memcmp(buf, test, 3) != 0)
-               die("not an trace data file");
+               die("no trace data in the file");
 
        read_or_die(buf, 7);
        if (memcmp(buf, "tracing", 7) != 0)
-               die("not a trace file (missing tracing)");
+               die("not a trace file (missing 'tracing' tag)");
 
        version = read_string();
        if (show_version)