lkml.org 
[lkml]   [2021]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] perf expr: Fix return value of ids__new
From
Date
This message appeared in my client as a separate thread, but it seems to
be a reply to a message from a different thread:

"In-Reply-To: <864ad02d-6afe-791c-f742-56582b633482@arm.com>"

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;
> }
>
> void ids__free(struct hashmap *ids)

\
 
 \ /
  Last update: 2021-12-13 14:58    [W:1.338 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site