[PATCH 15/35] perf record: Simplify perf_record__write

From: Arnaldo Carvalho de Melo
Date: Fri Dec 20 2013 - 14:10:57 EST


From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

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@xxxxxxxxx>
Cc: David Ahern <dsahern@xxxxxxxxx>
Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Mike Galbraith <efault@xxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Stephane Eranian <eranian@xxxxxxxxxx>
Link: http://lkml.kernel.org/n/tip-xwsk964dp681fica3xlqhjin@xxxxxxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/builtin-record.c | 11 +++--------
1 file 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 {
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;
}

--
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/