Skip to contentSkip to conversation

perf expr: Fix return value of ids__new

PATCH Superseded Miaoqian Lin 1 participant 1 message Dec 13, 2021 perf events

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 perf expr: Fix return value of ids__new

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.

---
 tools/perf/util/expr.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tools/perf/util/expr.c +7 -1
index 1d532b9fed29..aabdc112300c 100644
@@ -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)
Signature · 1 line
2.17.1