perf: Fix stat's stdout on the console
authorBarret Rhoden <brho@cs.berkeley.edu>
Thu, 23 Jun 2016 14:49:43 +0000 (10:49 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Fri, 24 Jun 2016 18:23:03 +0000 (14:23 -0400)
The old version worked if you ssh'd in, but not if we were directly on
the console.  Actually, I shouldn't have bothered with fdopen() in the
first place.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
tools/dev-util/perf/perf.c
tools/dev-util/perf/xlib.c

index b6b3aa1..bd03a9f 100644 (file)
@@ -361,14 +361,14 @@ static error_t parse_stat_opt(int key, char *arg, struct argp_state *state)
                p_opts->stat_bignum = TRUE;
                break;
        case 'o':
-               p_opts->outfile = xfopen(arg, "w+");
+               p_opts->outfile = xfopen(arg, "w");
                break;
        case ARGP_KEY_END:
                if (!p_opts->events)
                        p_opts->events = "cache-misses,cache-references,"
                                         "branch-misses,branches,instructions,cycles";
                if (!p_opts->outfile)
-                       p_opts->outfile = xfdopen(1, "w+");
+                       p_opts->outfile = stdout;
                break;
        default:
                return ARGP_ERR_UNKNOWN;
index 897b68e..1eb83f5 100644 (file)
@@ -84,7 +84,7 @@ FILE *xfdopen(int fd, const char *mode)
        FILE *file = fdopen(fd, mode);
 
        if (!file) {
-               fprintf(stderr, "Unable to reopen fd '%d' for mode '%s;: %s\n", fd,
+               fprintf(stderr, "Unable to reopen fd '%d' for mode '%s': %s\n", fd,
                        mode, strerror(errno));
                exit(1);
        }