Skip to contentSkip to conversation

perf tools: Normalize sq_quote_argv() error reporting

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Oct 24, 2016 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  e7b32d12a287a79f2831c1246baf3de0aed95dcc
Gitweb:     http://git.kernel.org/tip/e7b32d12a287a79f2831c1246baf3de0aed95dcc
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Fri, 14 Oct 2016 17:57:11 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 24 Oct 2016 11:07:44 -0300

perf tools: Normalize sq_quote_argv() error reporting

It already returns whatever strbuf_(grow|addch)() returns in case of failure, so just return -ENOSPC in the only case where it was die()ing. When it returns, its only caller will call die() anyway, so no need to be so eager, die later.

---
 tools/perf/util/quote.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/quote.c +1 -1
index 639d1da..293534c 100644
@@ -54,7 +54,7 @@ int sq_quote_argv(struct strbuf *dst, const char** argv, size_t maxlen)
 			break;
 		ret = sq_quote_buf(dst, argv[i]);
 		if (maxlen && dst->len > maxlen)
-			die("Too many or long arguments");
+			return -ENOSPC;
 	}
 	return ret;
 }