From: German Gomez <german.gomez@arm.com>
To: Miaoqian Lin <linmq006@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>, Andi Kleen <ak@linux.intel.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf expr: Fix return value of ids__new
Date: Mon, 13 Dec 2021 16:02:40 +0000 [thread overview]
Message-ID: <b3992bba-04ac-ff0b-7970-8f9cf410d786@arm.com> (raw)
In-Reply-To: <d0fabb42-399f-2b72-412b-4f5ba6b9eea4@arm.com>
On 13/12/2021 13:13, German Gomez wrote:
> [...]
>
> On 13/12/2021 07:09, Miaoqian Lin wrote:
>> callers of ids__new() function only do NULL checking for the return
>> value. ids__new() calles hashmap__new(), which may return
>> ERR_PTR(-ENOMEM). Instead of changing the checking one-by-one.
>> return NULL instead of ERR_PTR(-ENOMEM) to keep
>> consistent.
>>
>> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
>> ---
>> tools/perf/util/expr.c | 8 +++++++-
>> 1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
>> index 1d532b9fed29..aabdc112300c 100644
>> --- a/tools/perf/util/expr.c
>> +++ b/tools/perf/util/expr.c
>> @@ -65,7 +65,13 @@ static bool key_equal(const void *key1, const void *key2,
>>
>> struct hashmap *ids__new(void)
>> {
>> - return hashmap__new(key_hash, key_equal, NULL);
>> + struct hashmap *hash;
>> +
>> + hash = hashmap__new(key_hash, key_equal, NULL);
>> + if (IS_ERR(hash))
>> + return NULL;
>> + else
>> + return hash;
Small nitpick but can remove the else branch and simply return at the
end? Your patch still compiles for me but I think most other functions
do that.
>> [...]
next prev parent reply other threads:[~2021-12-13 16:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-12 4:23 [PATCH] perf stat: Fix NULL vs IS_ERR() checking in check_per_pkg Miaoqian Lin
2021-12-12 14:55 ` German Gomez
2021-12-12 15:37 ` German Gomez
2021-12-13 7:09 ` [PATCH] perf expr: Fix return value of ids__new Miaoqian Lin
2021-12-13 13:13 ` German Gomez
2021-12-13 16:02 ` German Gomez [this message]
2021-12-13 13:57 ` German Gomez
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=b3992bba-04ac-ff0b-7970-8f9cf410d786@arm.com \
--to=german.gomez@arm.com \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@redhat.com \
--cc=linmq006@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--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