[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170518041602.28689-2-davidcc@google.com>
Date: Wed, 17 May 2017 21:15:56 -0700
From: David Carrillo-Cisneros <davidcc@...gle.com>
To: linux-kernel@...r.kernel.org
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Andi Kleen <ak@...ux.intel.com>, Simon Que <sque@...omium.org>,
Wang Nan <wangnan0@...wei.com>, Jiri Olsa <jolsa@...nel.org>,
He Kuang <hekuang@...wei.com>,
Masami Hiramatsu <mhiramat@...nel.org>,
David Ahern <dsa@...ulusnetworks.com>,
Namhyung Kim <namhyung@...nel.org>,
Stephane Eranian <eranian@...gle.com>,
Paul Turner <pjt@...gle.com>,
David Carrillo-Cisneros <davidcc@...gle.com>
Subject: [PATCH 1/7] perf header: fail on write_padded error
Do not proceed if write_padded error failed.
Also, add comments to remind that return value of write_*
functions in util/header.c do not return number of bytes written.
Signed-off-by: David Carrillo-Cisneros <davidcc@...gle.com>
---
tools/perf/util/header.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 948b2c5efb65..2415d41282d8 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -72,6 +72,7 @@ bool perf_header__has_feat(const struct perf_header *header, int feat)
return test_bit(feat, header->adds_features);
}
+/* Return: 0 if succeded, -ERR if failed. */
static int do_write(int fd, const void *buf, size_t size)
{
while (size) {
@@ -87,6 +88,7 @@ static int do_write(int fd, const void *buf, size_t size)
return 0;
}
+/* Return: 0 if succeded, -ERR if failed. */
int write_padded(int fd, const void *bf, size_t count, size_t count_aligned)
{
static const char zero_buf[NAME_ALIGN];
@@ -101,6 +103,7 @@ int write_padded(int fd, const void *bf, size_t count, size_t count_aligned)
#define string_size(str) \
(PERF_ALIGN((strlen(str) + 1), NAME_ALIGN) + sizeof(u32))
+/* Return: 0 if succeded, -ERR if failed. */
static int do_write_string(int fd, const char *str)
{
u32 len, olen;
@@ -3277,7 +3280,8 @@ int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd,
*/
tracing_data_put(tdata);
- write_padded(fd, NULL, 0, padding);
+ if (write_padded(fd, NULL, 0, padding))
+ return -1;
return aligned_size;
}
--
2.13.0.303.g4ebf302169-goog
Powered by blists - more mailing lists