diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-12-19 12:26:26 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-12-19 12:26:26 -0500 |
commit | cf8b2e6941091d2034f19c1799f8d6407bd565a4 (patch) | |
tree | 534cae4349d58ed2ea44e324bde294d008ef5f5e /tools | |
parent | 50a9b8680613a2708ca882d982dcfa4fd9a66673 (diff) |
perf record: Simplify perf_record__write
1. Since all callers either test if it is less than zero or assign its
result to an int variable, convert it from ssize_t to int;
2. There is just one use for the 'session' variable, so use rec->session
directly instead;
3. No need to store the result of perf_data_file__write, since that
result is either 'size' or -1, the later making the error result to
be stored in 'errno' and accessed thru printf's %m in the pr_err
call.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-xwsk964dp681fica3xlqhjin@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-record.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 8eed3d752c80..e8d606caf747 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -76,19 +76,14 @@ struct perf_record { | |||
76 | long samples; | 76 | long samples; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | static ssize_t perf_record__write(struct perf_record *rec, | 79 | static int perf_record__write(struct perf_record *rec, void *bf, size_t size) |
80 | void *buf, size_t size) | ||
81 | { | 80 | { |
82 | struct perf_session *session = rec->session; | 81 | if (perf_data_file__write(rec->session->file, bf, size) < 0) { |
83 | ssize_t ret; | ||
84 | |||
85 | ret = perf_data_file__write(session->file, buf, size); | ||
86 | if (ret < 0) { | ||
87 | pr_err("failed to write perf data, error: %m\n"); | 82 | pr_err("failed to write perf data, error: %m\n"); |
88 | return -1; | 83 | return -1; |
89 | } | 84 | } |
90 | 85 | ||
91 | rec->bytes_written += ret; | 86 | rec->bytes_written += size; |
92 | return 0; | 87 | return 0; |
93 | } | 88 | } |
94 | 89 | ||