From 2b1e7ec413381639441f5b27a1b5b86cf8d417d9 Mon Sep 17 00:00:00 2001 From: Stephane Eranian Date: Tue, 15 May 2012 13:11:11 +0200 Subject: [PATCH] --- yaml --- r: 311193 b: refs/heads/master c: fc3e4d077d5c7a7bc1ad5bc143895b4e070e5a8b h: refs/heads/master i: 311191: d1086cd8c0d97d016eb6538d051a024f63661085 v: v3 --- [refs] | 2 +- trunk/tools/perf/builtin-stat.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 6d528bc87792..704ab84f5085 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 80c0120a3cca30166c0ab8b24e44be67e97b79af +refs/heads/master: fc3e4d077d5c7a7bc1ad5bc143895b4e070e5a8b diff --git a/trunk/tools/perf/builtin-stat.c b/trunk/tools/perf/builtin-stat.c index 262589991ea4..07b5c7703dd1 100644 --- a/trunk/tools/perf/builtin-stat.c +++ b/trunk/tools/perf/builtin-stat.c @@ -1179,6 +1179,12 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used) fprintf(stderr, "cannot use both --output and --log-fd\n"); usage_with_options(stat_usage, options); } + + if (output_fd < 0) { + fprintf(stderr, "argument to --log-fd must be a > 0\n"); + usage_with_options(stat_usage, options); + } + if (!output) { struct timespec tm; mode = append_file ? "a" : "w"; @@ -1190,7 +1196,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used) } clock_gettime(CLOCK_REALTIME, &tm); fprintf(output, "# started on %s\n", ctime(&tm.tv_sec)); - } else if (output_fd != 2) { + } else if (output_fd > 0) { mode = append_file ? "a" : "w"; output = fdopen(output_fd, mode); if (!output) {