mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-07 07:08:07 +00:00
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>
This commit is contained in:
parent
50a9b86806
commit
cf8b2e6941
1 changed files with 3 additions and 8 deletions
|
@ -76,19 +76,14 @@ struct perf_record {
|
||||||
long samples;
|
long samples;
|
||||||
};
|
};
|
||||||
|
|
||||||
static ssize_t perf_record__write(struct perf_record *rec,
|
static int perf_record__write(struct perf_record *rec, void *bf, size_t size)
|
||||||
void *buf, size_t size)
|
|
||||||
{
|
{
|
||||||
struct perf_session *session = rec->session;
|
if (perf_data_file__write(rec->session->file, bf, size) < 0) {
|
||||||
ssize_t ret;
|
|
||||||
|
|
||||||
ret = perf_data_file__write(session->file, buf, size);
|
|
||||||
if (ret < 0) {
|
|
||||||
pr_err("failed to write perf data, error: %m\n");
|
pr_err("failed to write perf data, error: %m\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rec->bytes_written += ret;
|
rec->bytes_written += size;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue