From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756539AbcJSA3T (ORCPT ); Tue, 18 Oct 2016 20:29:19 -0400 Received: from LGEAMRELO13.lge.com ([156.147.23.53]:36443 "EHLO lgeamrelo13.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756202AbcJSA3S (ORCPT ); Tue, 18 Oct 2016 20:29:18 -0400 X-Original-SENDERIP: 156.147.1.121 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 165.244.249.25 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 10.177.227.17 X-Original-MAILFROM: namhyung@kernel.org Date: Wed, 19 Oct 2016 09:25:39 +0900 From: Namhyung Kim To: Arnaldo Carvalho de Melo CC: Steven Rostedt , Honggyu Kim , Subject: Re: [PATCH 2/3] tools lib traceevent: Check the return value of asprintf Message-ID: <20161019002539.GG31113@sejong> References: <20161017141712.11932-1-hong.gyu.kim@lge.com> <20161017141712.11932-2-hong.gyu.kim@lge.com> <20161018175917.GW12815@kernel.org> MIME-Version: 1.0 In-Reply-To: <20161018175917.GW12815@kernel.org> User-Agent: Mutt/1.7.0 (2016-08-17) X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB02/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/10/19 09:25:44, Serialize by Router on LGEKRMHUB02/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/10/19 09:25:44, Serialize complete at 2016/10/19 09:25:44 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnaldo, You can add my Acked-by for all 3 patches. Thanks, Namhyung On Tue, Oct 18, 2016 at 02:59:17PM -0300, Arnaldo Carvalho de Melo wrote: > Steven, one more, please ack. > > - Arnaldo > > Em Mon, Oct 17, 2016 at 11:17:11PM +0900, Honggyu Kim escreveu: > > Since asprintf generates a compiler warning when its return value is not > > not properly handled, this patch checks that asprintf call is successful > > or not. > > > > Signed-off-by: Honggyu Kim > > --- > > tools/lib/traceevent/parse-filter.c | 29 +++++++++++++++++++---------- > > 1 file changed, 19 insertions(+), 10 deletions(-) > > > > diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c > > index 7c214ce..f0fcdcd 100644 > > --- a/tools/lib/traceevent/parse-filter.c > > +++ b/tools/lib/traceevent/parse-filter.c > > @@ -2122,7 +2122,8 @@ static char *op_to_str(struct event_filter *filter, struct filter_arg *arg) > > default: > > break; > > } > > - asprintf(&str, val ? "TRUE" : "FALSE"); > > + if (asprintf(&str, val ? "TRUE" : "FALSE") < 0) > > + return NULL; > > break; > > } > > } > > @@ -2140,7 +2141,8 @@ static char *op_to_str(struct event_filter *filter, struct filter_arg *arg) > > break; > > } > > > > - asprintf(&str, "(%s) %s (%s)", left, op, right); > > + if (asprintf(&str, "(%s) %s (%s)", left, op, right) < 0) > > + return NULL; > > break; > > > > case FILTER_OP_NOT: > > @@ -2156,10 +2158,12 @@ static char *op_to_str(struct event_filter *filter, struct filter_arg *arg) > > right_val = 0; > > if (right_val >= 0) { > > /* just return the opposite */ > > - asprintf(&str, right_val ? "FALSE" : "TRUE"); > > + if (asprintf(&str, right_val ? "FALSE" : "TRUE") < 0) > > + return NULL; > > break; > > } > > - asprintf(&str, "%s(%s)", op, right); > > + if (asprintf(&str, "%s(%s)", op, right) < 0) > > + return NULL; > > break; > > > > default: > > @@ -2175,7 +2179,8 @@ static char *val_to_str(struct event_filter *filter, struct filter_arg *arg) > > { > > char *str = NULL; > > > > - asprintf(&str, "%lld", arg->value.val); > > + if (asprintf(&str, "%lld", arg->value.val) < 0) > > + return NULL; > > > > return str; > > } > > @@ -2233,7 +2238,8 @@ static char *exp_to_str(struct event_filter *filter, struct filter_arg *arg) > > break; > > } > > > > - asprintf(&str, "%s %s %s", lstr, op, rstr); > > + if (asprintf(&str, "%s %s %s", lstr, op, rstr) < 0) > > + return NULL; > > out: > > free(lstr); > > free(rstr); > > @@ -2277,7 +2283,8 @@ static char *num_to_str(struct event_filter *filter, struct filter_arg *arg) > > if (!op) > > op = "<="; > > > > - asprintf(&str, "%s %s %s", lstr, op, rstr); > > + if (asprintf(&str, "%s %s %s", lstr, op, rstr) < 0) > > + return NULL; > > break; > > > > default: > > @@ -2312,8 +2319,9 @@ static char *str_to_str(struct event_filter *filter, struct filter_arg *arg) > > if (!op) > > op = "!~"; > > > > - asprintf(&str, "%s %s \"%s\"", > > - arg->str.field->name, op, arg->str.val); > > + if (asprintf(&str, "%s %s \"%s\"", > > + arg->str.field->name, op, arg->str.val) < 0) > > + return NULL; > > break; > > > > default: > > @@ -2329,7 +2337,8 @@ static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg) > > > > switch (arg->type) { > > case FILTER_ARG_BOOLEAN: > > - asprintf(&str, arg->boolean.value ? "TRUE" : "FALSE"); > > + if (asprintf(&str, arg->boolean.value ? "TRUE" : "FALSE") < 0) > > + return NULL; > > return str; > > > > case FILTER_ARG_OP: > > -- > > 2.10.0.rc2.dirty