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


Groups > linux.kernel > #1391201 > unrolled thread

[RFC PATCH 0/8] perf tools: Update strbuf to remove xrealloc

Started byMasami Hiramatsu <mhiramat@kernel.org>
First post2016-04-29 16:50 +0200
Last post2016-04-29 17:20 +0200
Articles 7 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [RFC PATCH 0/8] perf tools: Update strbuf to remove xrealloc Masami Hiramatsu <mhiramat@kernel.org> - 2016-04-29 16:50 +0200
    [RFC PATCH 3/8] perf help: Make check_emacsclient_version to check strbuf APIs Masami Hiramatsu <mhiramat@kernel.org> - 2016-04-29 16:50 +0200
    [RFC PATCH 1/8] perf: Rewrite strbuf not to die Masami Hiramatsu <mhiramat@kernel.org> - 2016-04-29 16:50 +0200
    [RFC PATCH 6/8] perf pmu: Make pmu_formats_string to check return value of strbuf Masami Hiramatsu <mhiramat@kernel.org> - 2016-04-29 16:50 +0200
    [RFC PATCH 4/8] perf: Make alias handler to check return value of strbuf Masami Hiramatsu <mhiramat@kernel.org> - 2016-04-29 16:50 +0200
    Re: [RFC PATCH 0/8] perf tools: Update strbuf to remove xrealloc Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-04-29 17:00 +0200
      Re: [RFC PATCH 0/8] perf tools: Update strbuf to remove xrealloc Masami Hiramatsu <mhiramat@kernel.org> - 2016-04-29 17:20 +0200

#1391201 — [RFC PATCH 0/8] perf tools: Update strbuf to remove xrealloc

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2016-04-29 16:50 +0200
Subject[RFC PATCH 0/8] perf tools: Update strbuf to remove xrealloc
Message-ID<rthTY-7HC-9@gated-at.bofh.it>
Hi Arnaldo, 

This patch series does refactoring strbuf and xrealloc related code
to remove xrealloc since it can call die() to exit immediately when
it hits any error. Instead of that, it should return error code to
the caller so that the caller can handle its error.

Thus, at first, this changes the strbuf APIs to return error code
instead of die() immediately. And then changing API callers according
to the following rules.
 - Check the return value of strbuf APIs and handle errors and,
   - If the caller returns an error code (errno), it returns
     the return value of strbuf APIs.
   - If the caller just return -1 or NULl in error case, it also
     returns -1 or NULL in case of strbuf error. 
   - If the caller can call die() directly, it also call die()
     in case of strbuf error.
 - Error checking patches are splitted for each subcommand, since
   it will help review.

This also removes xrealloc and ALLOC_GROW from libperf, so that no
one use it anymore.

This series actually depends on the series of SDT support patches
which I've sent an hour ago. It is also able to change this not to
depend on it easily. Please ask me if you'd like so.

Thank you,

---

Masami Hiramatsu (8):
      perf: Rewrite strbuf not to die
      perf probe: Check the return value of strbuf APIs
      perf help: Make check_emacsclient_version to check strbuf APIs
      perf: Make alias handler to check return value of strbuf
      perf header: Make topology checkers to check return value of strbuf
      perf pmu: Make pmu_formats_string to check return value of strbuf
      perf help: Do not use ALLOC_GROW in add_cmd_list
      perf tools: Remove xrealloc and ALLOC_GROW


 tools/perf/builtin-help.c          |   18 ++--
 tools/perf/perf.c                  |    8 +-
 tools/perf/util/Build              |    1 
 tools/perf/util/cache.h            |   19 ----
 tools/perf/util/dwarf-aux.c        |   50 +++++------
 tools/perf/util/header.c           |   31 ++++---
 tools/perf/util/help-unknown-cmd.c |   30 +++++-
 tools/perf/util/pmu.c              |   10 +-
 tools/perf/util/probe-event.c      |  167 +++++++++++++++++++++---------------
 tools/perf/util/probe-finder.c     |   30 ++++--
 tools/perf/util/quote.c            |   36 ++++----
 tools/perf/util/quote.h            |    2 
 tools/perf/util/strbuf.c           |   93 ++++++++++++++------
 tools/perf/util/strbuf.h           |   25 +++--
 tools/perf/util/util.h             |    6 -
 tools/perf/util/wrapper.c          |   29 ------
 16 files changed, 302 insertions(+), 253 deletions(-)
 delete mode 100644 tools/perf/util/wrapper.c

--
Masami Hiramatsu

[toc] | [next] | [standalone]


#1391202 — [RFC PATCH 3/8] perf help: Make check_emacsclient_version to check strbuf APIs

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2016-04-29 16:50 +0200
Subject[RFC PATCH 3/8] perf help: Make check_emacsclient_version to check strbuf APIs
Message-ID<rthTZ-7HC-33@gated-at.bofh.it>
In reply to#1391201
Make check_emacsclient_version() to check the return
value of strbuf APIs so that it can handle errors in
strbuf.
---
 tools/perf/builtin-help.c |   18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index bc1de9b..f9830c9 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -61,6 +61,7 @@ static int check_emacsclient_version(void)
 	struct child_process ec_process;
 	const char *argv_ec[] = { "emacsclient", "--version", NULL };
 	int version;
+	int ret = -1;
 
 	/* emacsclient prints its version number on stderr */
 	memset(&ec_process, 0, sizeof(ec_process));
@@ -71,7 +72,10 @@ static int check_emacsclient_version(void)
 		fprintf(stderr, "Failed to start emacsclient.\n");
 		return -1;
 	}
-	strbuf_read(&buffer, ec_process.err, 20);
+	if (strbuf_read(&buffer, ec_process.err, 20) < 0) {
+		fprintf(stderr, "Failed to read emacsclient version\n");
+		goto out;
+	}
 	close(ec_process.err);
 
 	/*
@@ -82,8 +86,7 @@ static int check_emacsclient_version(void)
 
 	if (prefixcmp(buffer.buf, "emacsclient")) {
 		fprintf(stderr, "Failed to parse emacsclient version.\n");
-		strbuf_release(&buffer);
-		return -1;
+		goto out;
 	}
 
 	version = atoi(buffer.buf + strlen("emacsclient"));
@@ -92,12 +95,11 @@ static int check_emacsclient_version(void)
 		fprintf(stderr,
 			"emacsclient version '%d' too old (< 22).\n",
 			version);
-		strbuf_release(&buffer);
-		return -1;
-	}
-
+	} else
+		ret = 0;
+out:
 	strbuf_release(&buffer);
-	return 0;
+	return ret;
 }
 
 static void exec_woman_emacs(const char *path, const char *page)

[toc] | [prev] | [next] | [standalone]


#1391203 — [RFC PATCH 1/8] perf: Rewrite strbuf not to die

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2016-04-29 16:50 +0200
Subject[RFC PATCH 1/8] perf: Rewrite strbuf not to die
Message-ID<rthTZ-7HC-29@gated-at.bofh.it>
In reply to#1391201
Rewrite strbuf implementation not to use die() nor xrealloc().
Instead of die, now most of the API returns error code or 0 if
succeeded.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 tools/perf/util/strbuf.c |   93 +++++++++++++++++++++++++++++++++-------------
 tools/perf/util/strbuf.h |   25 +++++++-----
 2 files changed, 82 insertions(+), 36 deletions(-)

diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c
index 8fb7329..a98bb60 100644
--- a/tools/perf/util/strbuf.c
+++ b/tools/perf/util/strbuf.c
@@ -1,3 +1,4 @@
+#include "debug.h"
 #include "cache.h"
 #include <linux/kernel.h>
 
@@ -17,12 +18,13 @@ int prefixcmp(const char *str, const char *prefix)
  */
 char strbuf_slopbuf[1];
 
-void strbuf_init(struct strbuf *sb, ssize_t hint)
+int strbuf_init(struct strbuf *sb, ssize_t hint)
 {
 	sb->alloc = sb->len = 0;
 	sb->buf = strbuf_slopbuf;
 	if (hint)
-		strbuf_grow(sb, hint);
+		return strbuf_grow(sb, hint);
+	return 0;
 }
 
 void strbuf_release(struct strbuf *sb)
@@ -42,67 +44,104 @@ char *strbuf_detach(struct strbuf *sb, size_t *sz)
 	return res;
 }
 
-void strbuf_grow(struct strbuf *sb, size_t extra)
+int strbuf_grow(struct strbuf *sb, size_t extra)
 {
-	if (sb->len + extra + 1 <= sb->len)
-		die("you want to use way too much memory");
-	if (!sb->alloc)
-		sb->buf = NULL;
-	ALLOC_GROW(sb->buf, sb->len + extra + 1, sb->alloc);
+	char *buf;
+	size_t nr = sb->len + extra + 1;
+
+	if (nr < sb->alloc)
+		return 0;
+
+	if (nr <= sb->len)
+		return -E2BIG;
+
+	if (alloc_nr(sb->alloc) > nr)
+		nr = alloc_nr(sb->alloc);
+
+	buf = malloc(nr * sizeof(*buf));
+	if (!buf)
+		return -ENOMEM;
+
+	if (sb->alloc) {
+		memcpy(buf, sb->buf, sb->alloc);
+		free(sb->buf);
+	}
+	sb->buf = buf;
+	sb->alloc = nr;
+	return 0;
 }
 
-void strbuf_addch(struct strbuf *sb, int c)
+int strbuf_addch(struct strbuf *sb, int c)
 {
-	strbuf_grow(sb, 1);
+	int ret = strbuf_grow(sb, 1);
+	if (ret)
+		return ret;
+
 	sb->buf[sb->len++] = c;
 	sb->buf[sb->len] = '\0';
+	return 0;
 }
 
-void strbuf_add(struct strbuf *sb, const void *data, size_t len)
+int strbuf_add(struct strbuf *sb, const void *data, size_t len)
 {
-	strbuf_grow(sb, len);
+	int ret = strbuf_grow(sb, len);
+	if (ret)
+		return ret;
+
 	memcpy(sb->buf + sb->len, data, len);
-	strbuf_setlen(sb, sb->len + len);
+	return strbuf_setlen(sb, sb->len + len);
 }
 
-static void strbuf_addv(struct strbuf *sb, const char *fmt, va_list ap)
+static int strbuf_addv(struct strbuf *sb, const char *fmt, va_list ap)
 {
-	int len;
+	int len, ret;
 	va_list ap_saved;
 
-	if (!strbuf_avail(sb))
-		strbuf_grow(sb, 64);
+	if (!strbuf_avail(sb)) {
+		ret = strbuf_grow(sb, 64);
+		if (ret)
+			return ret;
+	}
 
 	va_copy(ap_saved, ap);
 	len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap);
 	if (len < 0)
-		die("your vsnprintf is broken");
+		return len;
 	if (len > strbuf_avail(sb)) {
-		strbuf_grow(sb, len);
+		ret = strbuf_grow(sb, len);
+		if (ret)
+			return ret;
 		len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap_saved);
 		va_end(ap_saved);
 		if (len > strbuf_avail(sb)) {
-			die("this should not happen, your vsnprintf is broken");
+			pr_debug("this should not happen, your vsnprintf is broken");
+			return -EINVAL;
 		}
 	}
-	strbuf_setlen(sb, sb->len + len);
+	return strbuf_setlen(sb, sb->len + len);
 }
 
-void strbuf_addf(struct strbuf *sb, const char *fmt, ...)
+int strbuf_addf(struct strbuf *sb, const char *fmt, ...)
 {
 	va_list ap;
+	int ret;
 
 	va_start(ap, fmt);
-	strbuf_addv(sb, fmt, ap);
+	ret = strbuf_addv(sb, fmt, ap);
 	va_end(ap);
+	return ret;
 }
 
 ssize_t strbuf_read(struct strbuf *sb, int fd, ssize_t hint)
 {
 	size_t oldlen = sb->len;
 	size_t oldalloc = sb->alloc;
+	int ret;
+
+	ret = strbuf_grow(sb, hint ? hint : 8192);
+	if (ret)
+		return ret;
 
-	strbuf_grow(sb, hint ? hint : 8192);
 	for (;;) {
 		ssize_t cnt;
 
@@ -112,12 +151,14 @@ ssize_t strbuf_read(struct strbuf *sb, int fd, ssize_t hint)
 				strbuf_release(sb);
 			else
 				strbuf_setlen(sb, oldlen);
-			return -1;
+			return cnt;
 		}
 		if (!cnt)
 			break;
 		sb->len += cnt;
-		strbuf_grow(sb, 8192);
+		ret = strbuf_grow(sb, 8192);
+		if (ret)
+			return ret;
 	}
 
 	sb->buf[sb->len] = '\0';
diff --git a/tools/perf/util/strbuf.h b/tools/perf/util/strbuf.h
index ab9be0fb..54b4092 100644
--- a/tools/perf/util/strbuf.h
+++ b/tools/perf/util/strbuf.h
@@ -51,7 +51,7 @@ struct strbuf {
 #define STRBUF_INIT  { 0, 0, strbuf_slopbuf }
 
 /*----- strbuf life cycle -----*/
-void strbuf_init(struct strbuf *buf, ssize_t hint);
+int strbuf_init(struct strbuf *buf, ssize_t hint);
 void strbuf_release(struct strbuf *buf);
 char *strbuf_detach(struct strbuf *buf, size_t *);
 
@@ -60,26 +60,31 @@ static inline ssize_t strbuf_avail(const struct strbuf *sb) {
 	return sb->alloc ? sb->alloc - sb->len - 1 : 0;
 }
 
-void strbuf_grow(struct strbuf *buf, size_t);
+int strbuf_grow(struct strbuf *buf, size_t);
 
-static inline void strbuf_setlen(struct strbuf *sb, size_t len) {
-	if (!sb->alloc)
-		strbuf_grow(sb, 0);
+static inline int strbuf_setlen(struct strbuf *sb, size_t len) {
+	int ret;
+	if (!sb->alloc) {
+		ret = strbuf_grow(sb, 0);
+		if (ret)
+			return ret;
+	}
 	assert(len < sb->alloc);
 	sb->len = len;
 	sb->buf[len] = '\0';
+	return 0;
 }
 
 /*----- add data in your buffer -----*/
-void strbuf_addch(struct strbuf *sb, int c);
+int strbuf_addch(struct strbuf *sb, int c);
 
-void strbuf_add(struct strbuf *buf, const void *, size_t);
-static inline void strbuf_addstr(struct strbuf *sb, const char *s) {
-	strbuf_add(sb, s, strlen(s));
+int strbuf_add(struct strbuf *buf, const void *, size_t);
+static inline int strbuf_addstr(struct strbuf *sb, const char *s) {
+	return strbuf_add(sb, s, strlen(s));
 }
 
 __attribute__((format(printf,2,3)))
-void strbuf_addf(struct strbuf *sb, const char *fmt, ...);
+int strbuf_addf(struct strbuf *sb, const char *fmt, ...);
 
 /* XXX: if read fails, any partial read is undone */
 ssize_t strbuf_read(struct strbuf *, int fd, ssize_t hint);

[toc] | [prev] | [next] | [standalone]


#1391204 — [RFC PATCH 6/8] perf pmu: Make pmu_formats_string to check return value of strbuf

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2016-04-29 16:50 +0200
Subject[RFC PATCH 6/8] perf pmu: Make pmu_formats_string to check return value of strbuf
Message-ID<rthTZ-7HC-39@gated-at.bofh.it>
In reply to#1391201
Make pmu_formats_string() to check return value of
strbuf APIs so that it can detect errors in it.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 tools/perf/util/pmu.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index bf34468..ddb0261 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -643,20 +643,20 @@ static int pmu_resolve_param_term(struct parse_events_term *term,
 static char *pmu_formats_string(struct list_head *formats)
 {
 	struct perf_pmu_format *format;
-	char *str;
-	struct strbuf buf;
+	char *str = NULL;
+	struct strbuf buf = STRBUF_INIT;
 	unsigned i = 0;
 
 	if (!formats)
 		return NULL;
 
-	strbuf_init(&buf, 0);
 	/* sysfs exported terms */
 	list_for_each_entry(format, formats, list)
-		strbuf_addf(&buf, i++ ? ",%s" : "%s",
-			    format->name);
+		if (strbuf_addf(&buf, i++ ? ",%s" : "%s", format->name) < 0)
+			goto error;
 
 	str = strbuf_detach(&buf, NULL);
+error:
 	strbuf_release(&buf);
 
 	return str;

[toc] | [prev] | [next] | [standalone]


#1391205 — [RFC PATCH 4/8] perf: Make alias handler to check return value of strbuf

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2016-04-29 16:50 +0200
Subject[RFC PATCH 4/8] perf: Make alias handler to check return value of strbuf
Message-ID<rthTZ-7HC-43@gated-at.bofh.it>
In reply to#1391201
Make alias handler and sq_quote_argv to check the return
value of strbuf APIs.
In sq_quote_argv() calls die(), but this fix handles strbuf
failure as a special case and returns to caller, since
the caller - handle_alias() also has to check the return
value of other strbuf APIs and those checks can be merged
to one if() statement.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 tools/perf/perf.c       |    8 +++++---
 tools/perf/util/quote.c |   36 ++++++++++++++++++++----------------
 tools/perf/util/quote.h |    2 +-
 3 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 83ffe7c..7970008 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -309,9 +309,11 @@ static int handle_alias(int *argcp, const char ***argv)
 			if (*argcp > 1) {
 				struct strbuf buf;
 
-				strbuf_init(&buf, PATH_MAX);
-				strbuf_addstr(&buf, alias_string);
-				sq_quote_argv(&buf, (*argv) + 1, PATH_MAX);
+				if (strbuf_init(&buf, PATH_MAX) < 0 ||
+				    strbuf_addstr(&buf, alias_string) < 0 ||
+				    sq_quote_argv(&buf, (*argv) + 1,
+						  PATH_MAX) < 0)
+					die("Failed to allocate memory.");
 				free(alias_string);
 				alias_string = buf.buf;
 			}
diff --git a/tools/perf/util/quote.c b/tools/perf/util/quote.c
index 01f0324..c6d4ee2 100644
--- a/tools/perf/util/quote.c
+++ b/tools/perf/util/quote.c
@@ -17,38 +17,42 @@ static inline int need_bs_quote(char c)
 	return (c == '\'' || c == '!');
 }
 
-static void sq_quote_buf(struct strbuf *dst, const char *src)
+static int sq_quote_buf(struct strbuf *dst, const char *src)
 {
 	char *to_free = NULL;
+	int ret;
 
 	if (dst->buf == src)
 		to_free = strbuf_detach(dst, NULL);
 
-	strbuf_addch(dst, '\'');
-	while (*src) {
+	ret = strbuf_addch(dst, '\'');
+	while (!ret && *src) {
 		size_t len = strcspn(src, "'!");
-		strbuf_add(dst, src, len);
+		ret = strbuf_add(dst, src, len);
 		src += len;
-		while (need_bs_quote(*src)) {
-			strbuf_addstr(dst, "'\\");
-			strbuf_addch(dst, *src++);
-			strbuf_addch(dst, '\'');
-		}
+		while (!ret && need_bs_quote(*src))
+			ret = strbuf_addf(dst, "'\\%c\'", *src++);
 	}
-	strbuf_addch(dst, '\'');
+	if (!ret)
+		ret = strbuf_addch(dst, '\'');
 	free(to_free);
+
+	return ret;
 }
 
-void sq_quote_argv(struct strbuf *dst, const char** argv, size_t maxlen)
+int sq_quote_argv(struct strbuf *dst, const char** argv, size_t maxlen)
 {
-	int i;
+	int i, ret;
 
 	/* Copy into destination buffer. */
-	strbuf_grow(dst, 255);
-	for (i = 0; argv[i]; ++i) {
-		strbuf_addch(dst, ' ');
-		sq_quote_buf(dst, argv[i]);
+	ret = strbuf_grow(dst, 255);
+	for (i = 0; !ret && argv[i]; ++i) {
+		ret = strbuf_addch(dst, ' ');
+		if (ret)
+			break;
+		ret = sq_quote_buf(dst, argv[i]);
 		if (maxlen && dst->len > maxlen)
 			die("Too many or long arguments");
 	}
+	return ret;
 }
diff --git a/tools/perf/util/quote.h b/tools/perf/util/quote.h
index 3340c9c..e1ec191 100644
--- a/tools/perf/util/quote.h
+++ b/tools/perf/util/quote.h
@@ -24,6 +24,6 @@
  * sq_quote() in a real application.
  */
 
-void sq_quote_argv(struct strbuf *, const char **argv, size_t maxlen);
+int sq_quote_argv(struct strbuf *, const char **argv, size_t maxlen);
 
 #endif /* __PERF_QUOTE_H */

[toc] | [prev] | [next] | [standalone]


#1391209

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-04-29 17:00 +0200
Message-ID<rti3E-7N6-57@gated-at.bofh.it>
In reply to#1391201
Em Fri, Apr 29, 2016 at 11:46:32PM +0900, Masami Hiramatsu escreveu:
> Hi Arnaldo, 
> 
> This patch series does refactoring strbuf and xrealloc related code
> to remove xrealloc since it can call die() to exit immediately when
> it hits any error. Instead of that, it should return error code to
> the caller so that the caller can handle its error.
> 
> Thus, at first, this changes the strbuf APIs to return error code
> instead of die() immediately. And then changing API callers according
> to the following rules.
>  - Check the return value of strbuf APIs and handle errors and,
>    - If the caller returns an error code (errno), it returns
>      the return value of strbuf APIs.
>    - If the caller just return -1 or NULl in error case, it also
>      returns -1 or NULL in case of strbuf error. 
>    - If the caller can call die() directly, it also call die()
>      in case of strbuf error.
>  - Error checking patches are splitted for each subcommand, since
>    it will help review.
> 
> This also removes xrealloc and ALLOC_GROW from libperf, so that no
> one use it anymore.
> 
> This series actually depends on the series of SDT support patches
> which I've sent an hour ago. It is also able to change this not to
> depend on it easily. Please ask me if you'd like so.

Please do so, as this one looks easier to review, so can go in faster.

- Arnaldo
 
> Thank you,
> 
> ---
> 
> Masami Hiramatsu (8):
>       perf: Rewrite strbuf not to die
>       perf probe: Check the return value of strbuf APIs
>       perf help: Make check_emacsclient_version to check strbuf APIs
>       perf: Make alias handler to check return value of strbuf
>       perf header: Make topology checkers to check return value of strbuf
>       perf pmu: Make pmu_formats_string to check return value of strbuf
>       perf help: Do not use ALLOC_GROW in add_cmd_list
>       perf tools: Remove xrealloc and ALLOC_GROW
> 
> 
>  tools/perf/builtin-help.c          |   18 ++--
>  tools/perf/perf.c                  |    8 +-
>  tools/perf/util/Build              |    1 
>  tools/perf/util/cache.h            |   19 ----
>  tools/perf/util/dwarf-aux.c        |   50 +++++------
>  tools/perf/util/header.c           |   31 ++++---
>  tools/perf/util/help-unknown-cmd.c |   30 +++++-
>  tools/perf/util/pmu.c              |   10 +-
>  tools/perf/util/probe-event.c      |  167 +++++++++++++++++++++---------------
>  tools/perf/util/probe-finder.c     |   30 ++++--
>  tools/perf/util/quote.c            |   36 ++++----
>  tools/perf/util/quote.h            |    2 
>  tools/perf/util/strbuf.c           |   93 ++++++++++++++------
>  tools/perf/util/strbuf.h           |   25 +++--
>  tools/perf/util/util.h             |    6 -
>  tools/perf/util/wrapper.c          |   29 ------
>  16 files changed, 302 insertions(+), 253 deletions(-)
>  delete mode 100644 tools/perf/util/wrapper.c
> 
> --
> Masami Hiramatsu

[toc] | [prev] | [next] | [standalone]


#1391240

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2016-04-29 17:20 +0200
Message-ID<rtin0-8fU-17@gated-at.bofh.it>
In reply to#1391209
On Fri, 29 Apr 2016 11:54:54 -0300
Arnaldo Carvalho de Melo <acme@kernel.org> wrote:

> Em Fri, Apr 29, 2016 at 11:46:32PM +0900, Masami Hiramatsu escreveu:
> > Hi Arnaldo, 
> > 
> > This patch series does refactoring strbuf and xrealloc related code
> > to remove xrealloc since it can call die() to exit immediately when
> > it hits any error. Instead of that, it should return error code to
> > the caller so that the caller can handle its error.
> > 
> > Thus, at first, this changes the strbuf APIs to return error code
> > instead of die() immediately. And then changing API callers according
> > to the following rules.
> >  - Check the return value of strbuf APIs and handle errors and,
> >    - If the caller returns an error code (errno), it returns
> >      the return value of strbuf APIs.
> >    - If the caller just return -1 or NULl in error case, it also
> >      returns -1 or NULL in case of strbuf error. 
> >    - If the caller can call die() directly, it also call die()
> >      in case of strbuf error.
> >  - Error checking patches are splitted for each subcommand, since
> >    it will help review.
> > 
> > This also removes xrealloc and ALLOC_GROW from libperf, so that no
> > one use it anymore.
> > 
> > This series actually depends on the series of SDT support patches
> > which I've sent an hour ago. It is also able to change this not to
> > depend on it easily. Please ask me if you'd like so.
> 
> Please do so, as this one looks easier to review, so can go in faster.

OK, I sent it as v2 in order to avoid confusion.

Thank you!



-- 
Masami Hiramatsu <mhiramat@kernel.org>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web