* [PATCH v2] perf expr: Fix return value of ids__new
@ 2021-12-13 16:24 Miaoqian Lin
0 siblings, 0 replies; only message in thread
From: Miaoqian Lin @ 2021-12-13 16:24 UTC (permalink / raw)
Cc: linmq006, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
Ian Rogers, Andi Kleen, German Gomez, linux-perf-users,
linux-kernel
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)
--
2.17.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-12-13 16:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-13 16:24 [PATCH v2] perf expr: Fix return value of ids__new Miaoqian Lin
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).