From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Honggyu Kim <hong.gyu.kim@lge.com>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/3] tools lib traceevent: Check the return value of asprintf
Date: Wed, 19 Oct 2016 09:25:39 +0900 [thread overview]
Message-ID: <20161019002539.GG31113@sejong> (raw)
In-Reply-To: <20161018175917.GW12815@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 <hong.gyu.kim@lge.com>
> > ---
> > 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
next prev parent reply other threads:[~2016-10-19 0:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-17 14:17 [PATCH 1/3] tools lib traceevent: Add -O2 option to traceevent Honggyu Kim
2016-10-17 14:17 ` [PATCH 2/3] tools lib traceevent: Check the return value of asprintf Honggyu Kim
2016-10-18 17:59 ` Arnaldo Carvalho de Melo
2016-10-19 0:25 ` Namhyung Kim [this message]
2016-10-17 14:17 ` [PATCH 3/3] tools lib traceevent: Fix to set uninitialized variables Honggyu Kim
2016-10-18 17:59 ` Arnaldo Carvalho de Melo
2016-10-18 2:01 ` [PATCH 1/3] tools lib traceevent: Add -O2 option to traceevent Namhyung Kim
2016-10-18 15:29 ` Steven Rostedt
2016-10-19 17:48 ` Arnaldo Carvalho de Melo
2016-10-19 18:05 ` Arnaldo Carvalho de Melo
2016-10-19 18:06 ` Arnaldo Carvalho de Melo
2016-10-19 19:26 ` Steven Rostedt
2016-10-19 19:21 ` Steven Rostedt
2016-10-19 18:21 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161019002539.GG31113@sejong \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=hong.gyu.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox