From: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@kernel.org>,
Namhyung Kim <namhyung.kim@lge.com>,
LKML <linux-kernel@vger.kernel.org>, Jiri Olsa <jolsa@redhat.com>
Subject: Re: [PATCH 13/14] tools lib traceevent: Get rid of die() in some string conversion funcitons
Date: Tue, 17 Dec 2013 17:02:39 -0300 [thread overview]
Message-ID: <20131217200239.GE6517@ghostprotocols.net> (raw)
In-Reply-To: <878uvkgx9f.fsf@sejong.aot.lge.com>
Em Tue, Dec 17, 2013 at 09:02:36AM +0900, Namhyung Kim escreveu:
> On Mon, 16 Dec 2013 09:40:51 -0300, Arnaldo Carvalho de Melo wrote:
> > Em Mon, Dec 16, 2013 at 01:49:11PM +0900, Namhyung Kim escreveu:
> >> On Fri, 13 Dec 2013 11:52:04 -0300, Arnaldo Carvalho de Melo wrote:
> >> > All the rest is ok, so its just the malloc + strcpy that remains to be
> >> > converted, do you want me to do it?
> >> Hmm.. did you mean like this?
> >> str = NULL;
> >> if (val)
> >> asprintf(&str, "TRUE");
> >> else
> >> asprintf(&str, "FALSE");
> >> return str;
> > More compact:
> > if (asprintf(&str, "%s", val ? "TRUE" : "FALSE") < 0)
> > // error handling path
> > At that point str already is set to NULL.
> Okay, this is a new one:
Thanks, it all seems now, but just prior to applying this I noticed:
> Those functions are for stringify filter arguments. As caller of
> those functions handles NULL string properly, it seems that it's
> enough to return NULL rather than calling die().
It handles NULL in what way? This comment:
> @@ -2369,7 +2340,7 @@ static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg)
> * Returns a string that displays the filter contents.
> * This string must be freed with free(str).
> - * NULL is returned if no filter is found.
> + * NULL is returned if no filter is found or allocation failed.
> */
> char *
> pevent_filter_make_string(struct event_filter *filter, int event_id)
Made me a bit unconfortable, so if it handles NULL as a filter not
found, how will it figure out what happened?
/me looks at the callers...
>From just a quick look I couldn't see cases where NULL could cause
segfaults, but saw some cases where allocation errors would not be
notified in any way to the user :-\
Anyway, applying this patch, those are other kinds of problems, i.e. further
fallout from converting from the previous panic()-at-alloc-failure approach.
- Arnaldo
next prev parent reply other threads:[~2013-12-17 20:02 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-12 7:36 [PATCHSET 00/14] tools lib traceevent: Get rid of *die() calls from parse-filter.c (v2) Namhyung Kim
2013-12-12 7:36 ` [PATCH 01/14] tools lib traceevent: Get rid of malloc_or_die() in show_error() Namhyung Kim
2013-12-16 15:27 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 02/14] tools lib traceevent: Get rid of die in add_filter_type() Namhyung Kim
2013-12-16 15:28 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 03/14] tools lib traceevent: Get rid of malloc_or_die() allocate_arg() Namhyung Kim
2013-12-16 15:28 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 04/14] tools lib traceevent: Get rid of malloc_or_die() in read_token() Namhyung Kim
2013-12-16 15:28 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 05/14] tools lib traceevent: Get rid of malloc_or_die() in find_event() Namhyung Kim
2013-12-16 15:28 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 06/14] tools lib traceevent: Get rid of die() in add_right() Namhyung Kim
2013-12-16 15:28 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 07/14] tools lib traceevent: Make add_left() return pevent_errno Namhyung Kim
2013-12-16 15:28 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 08/14] tools lib traceevent: Get rid of die() in reparent_op_arg() Namhyung Kim
2013-12-16 15:28 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 09/14] tools lib traceevent: Refactor create_arg_item() Namhyung Kim
2013-12-16 15:29 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 10/14] tools lib traceevent: Refactor process_filter() Namhyung Kim
2013-12-16 15:29 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 11/14] tools lib traceevent: Make pevent_filter_add_filter_str() return pevent_errno Namhyung Kim
2013-12-16 15:29 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 12/14] tools lib traceevent: Refactor pevent_filter_match() to get rid of die() Namhyung Kim
2013-12-16 15:29 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 13/14] tools lib traceevent: Get rid of die() in some string conversion funcitons Namhyung Kim
2013-12-12 18:41 ` Arnaldo Carvalho de Melo
2013-12-13 0:15 ` Namhyung Kim
2013-12-13 14:52 ` Arnaldo Carvalho de Melo
2013-12-16 4:49 ` Namhyung Kim
2013-12-16 12:40 ` Arnaldo Carvalho de Melo
2013-12-17 0:02 ` Namhyung Kim
2013-12-17 20:02 ` Arnaldo Carvalho de Melo [this message]
2013-12-18 4:09 ` Namhyung Kim
2013-12-18 10:33 ` [tip:perf/core] tools lib traceevent: Get rid of die() in some string conversion functions tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 14/14] tools lib traceevent: Introduce pevent_filter_strerror() Namhyung Kim
2014-01-12 18:31 ` [tip:perf/core] " tip-bot for Namhyung Kim
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=20131217200239.GE6517@ghostprotocols.net \
--to=acme@ghostprotocols.net \
--cc=a.p.zijlstra@chello.nl \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung.kim@lge.com \
--cc=namhyung@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