[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <b3992bba-04ac-ff0b-7970-8f9cf410d786@arm.com>
Date: Mon, 13 Dec 2021 16:02:40 +0000
From: German Gomez <german.gomez@....com>
To: Miaoqian Lin <linmq006@...il.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
Ian Rogers <irogers@...gle.com>,
Andi Kleen <ak@...ux.intel.com>,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] perf expr: Fix return value of ids__new
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@...il.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.
>> [...]
Powered by blists - more mailing lists