Skip to contentSkip to conversation

perf record: Simplify perf_record__write

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Jan 12, 2014 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  cf8b2e6941091d2034f19c1799f8d6407bd565a4
Gitweb:     http://git.kernel.org/tip/cf8b2e6941091d2034f19c1799f8d6407bd565a4
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Thu, 19 Dec 2013 14:26:26 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 19 Dec 2013 14:26:26 -0300

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 <[email protected]>
Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/builtin-record.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
tools/perf/builtin-record.c +3 -8
index 8eed3d7..e8d606c 100644
@@ -76,19 +76,14 @@ struct perf_record {
 	long			samples;
 };
 
-static ssize_t perf_record__write(struct perf_record *rec,
-				  void *buf, size_t size)
+static int perf_record__write(struct perf_record *rec, void *bf, size_t size)
 {
-	struct perf_session *session = rec->session;
-	ssize_t ret;
-
-	ret = perf_data_file__write(session->file, buf, size);
-	if (ret < 0) {
+	if (perf_data_file__write(rec->session->file, bf, size) < 0) {
 		pr_err("failed to write perf data, error: %m\n");
 		return -1;
 	}
 
-	rec->bytes_written += ret;
+	rec->bytes_written += size;
 	return 0;
 }