linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Taeung Song <treeze.taeung@gmail.com>
To: Masami Hiramatsu <mhiramat@kernel.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH v5 1/4] perf config: Introduce perf_config_set class
Date: Mon, 4 Apr 2016 17:41:16 +0900	[thread overview]
Message-ID: <570228AC.8090004@gmail.com> (raw)
In-Reply-To: <CADyE4xGtr-54PThpkwgPUiSaxT1FtfLBRjAAsLkYEwz6P8783g@mail.gmail.com>

Hi, Masami Hiramatsu

On 04/04/2016 05:13 PM, Masami Hiramatsu wrote:
> Hi,
>
> 2016-04-03 2:08 GMT+09:00 Taeung Song <treeze.taeung@gmail.com>:
> [...]
>> +static struct perf_config_section *add_section(struct list_head *sections,
>> +                                              const char *section_name)
>> +{
>> +       struct perf_config_section *section = zalloc(sizeof(*section));
>> +
>> +       if (!section)
>> +               return NULL;
>> +
>> +       INIT_LIST_HEAD(&section->items);
>> +       section->name = strdup(section_name);
>> +       if (!section->name) {
>> +               pr_debug("%s: strdup failed\n", __func__);
>> +               free(section);
>> +               return NULL;
>> +       }
>> +
>> +       list_add_tail(&section->node, sections);
>> +       return section;
>> +}
>> +
>> +static struct perf_config_item *add_config_item(struct perf_config_section *section,
>> +                                               const char *name)
>> +{
>> +       struct perf_config_item *item = zalloc(sizeof(*item));
>> +
>> +       if (!item)
>> +               return NULL;
>> +
>> +       item->name = strdup(name);
>> +       if (!item->name) {
>> +               pr_debug("%s: strdup failed\n", __func__);
>> +               goto out_err;
>
> As you did in above add_section(), you can do free(item)
> and return NULL here instead of using goto.
>
> Other parts looks OK for me.
>

I got it.
What you mean is like below ?

diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index e636d09..53e756e 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -580,15 +580,12 @@ static struct perf_config_item 
*add_config_item(struct perf_config_section *sect
          item->name = strdup(name);
          if (!item->name) {
                  pr_debug("%s: strdup failed\n", __func__);
-                goto out_err;
+                free(item);
+                return NULL;
          }

          list_add_tail(&item->node, &section->items);
          return item;
-
-out_err:
-        free(item);
-        return NULL;
  }

  static int set_value(struct perf_config_item *item, const char *value)


I'll resend v6 with this.
Thank you for your review. :-)

Taeung

  reply	other threads:[~2016-04-04  8:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-02 17:08 [PATCH v5 0/4] Infrastructure code for perf-config Taeung Song
2016-04-02 17:08 ` [PATCH v5 1/4] perf config: Introduce perf_config_set class Taeung Song
2016-04-04  8:13   ` Masami Hiramatsu
2016-04-04  8:41     ` Taeung Song [this message]
2016-04-02 17:08 ` [PATCH v5 2/4] perf config: Let show_config() work with perf_config_set Taeung Song
2016-04-02 17:08 ` [PATCH v5 3/4] perf config: Prepare all default configs Taeung Song
2016-04-02 17:08 ` [PATCH v5 4/4] perf config: Initialize perf_config_set with " Taeung Song

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=570228AC.8090004@gmail.com \
    --to=treeze.taeung@gmail.com \
    --cc=acme@kernel.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.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;
as well as URLs for NNTP newsgroup(s).