Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754769AbcDDIN5 (ORCPT ); Mon, 4 Apr 2016 04:13:57 -0400 Received: from mail.kernel.org ([198.145.29.136]:57809 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752717AbcDDINy (ORCPT ); Mon, 4 Apr 2016 04:13:54 -0400 MIME-Version: 1.0 In-Reply-To: <1459616904-1682-2-git-send-email-treeze.taeung@gmail.com> References: <1459616904-1682-1-git-send-email-treeze.taeung@gmail.com> <1459616904-1682-2-git-send-email-treeze.taeung@gmail.com> From: Masami Hiramatsu Date: Mon, 4 Apr 2016 17:13:31 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 1/4] perf config: Introduce perf_config_set class To: Taeung Song Cc: Arnaldo Carvalho de Melo , linux-kernel@vger.kernel.org, Jiri Olsa , Namhyung Kim , Ingo Molnar , Peter Zijlstra Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1471 Lines: 53 Hi, 2016-04-03 2:08 GMT+09:00 Taeung Song : [...] > +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(§ion->items); > + section->name = strdup(section_name); > + if (!section->name) { > + pr_debug("%s: strdup failed\n", __func__); > + free(section); > + return NULL; > + } > + > + list_add_tail(§ion->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. Thank you, > + } > + > + list_add_tail(&item->node, §ion->items); > + return item; > + > +out_err: > + free(item); > + return NULL; > +}