Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1689680

[PATCH v6 03/16] perf header: fail on write_padded error

From David Carrillo-Cisneros <davidcc@google.com>
Newsgroups linux.kernel
Subject [PATCH v6 03/16] perf header: fail on write_padded error
Date 2017-07-18 06:40 +0200
Message-ID <u4ssF-6bP-5@gated-at.bofh.it> (permalink)
References <u4siZ-67a-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Do not proceed if write_padded error failed.

Also, add comments to remind that the return value of write_*
functions in util/header.c is an erro code and not the number
of bytes written.

Signed-off-by: David Carrillo-Cisneros <davidcc@google.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 3b833f06c4e7..8dda19b68ac4 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -74,6 +74,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) {
@@ -89,6 +90,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];
@@ -103,6 +105,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;
@@ -3200,7 +3203,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.2.932.g7449e964c-goog

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v6 00/16] perf tool: add meta-data header support for pipe-mode David Carrillo-Cisneros <davidcc@google.com> - 2017-07-18 06:30 +0200
  [PATCH v6 13/16] perf header: change FEAT_OP* macros David Carrillo-Cisneros <davidcc@google.com> - 2017-07-18 06:30 +0200
    [tip:perf/core] perf header: Change FEAT_OP* macros tip-bot for David Carrillo-Cisneros <tipbot@zytor.com> - 2017-07-20 11:20 +0200
  [PATCH v6 10/16] perf header: use struct feat_fd in read header records David Carrillo-Cisneros <davidcc@google.com> - 2017-07-18 06:30 +0200
    [tip:perf/core] perf header: Use struct feat_fd in read header  records tip-bot for David Carrillo-Cisneros <tipbot@zytor.com> - 2017-07-20 11:10 +0200
  [PATCH v6 15/16] perf tools: add feature header record to pipe-mode David Carrillo-Cisneros <davidcc@google.com> - 2017-07-18 06:30 +0200
    [tip:perf/core] perf tools: Add feature header record to pipe-mode tip-bot for David Carrillo-Cisneros <tipbot@zytor.com> - 2017-07-20 11:10 +0200
  [PATCH v6 08/16] perf header: use struct feat_fd to process header records David Carrillo-Cisneros <davidcc@google.com> - 2017-07-18 06:30 +0200
    [tip:perf/core] perf header: Use struct feat_fd to process header  records tip-bot for David Carrillo-Cisneros <tipbot@zytor.com> - 2017-07-20 11:10 +0200
  [PATCH v6 03/16] perf header: fail on write_padded error David Carrillo-Cisneros <davidcc@google.com> - 2017-07-18 06:40 +0200
    [tip:perf/core] perf header: Fail on write_padded error tip-bot for David Carrillo-Cisneros <tipbot@zytor.com> - 2017-07-20 11:10 +0200
  Re: [PATCH v6 00/16] perf tool: add meta-data header support for  pipe-mode Jiri Olsa <jolsa@redhat.com> - 2017-07-18 09:30 +0200

csiph-web