linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] perf expr: Fix return value of ids__new
@ 2021-12-14  1:10 Miaoqian Lin
  2021-12-21  8:29 ` Jiri Olsa
  2021-12-21 14:19 ` Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 4+ messages in thread
From: Miaoqian Lin @ 2021-12-14  1:10 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.

---
Changes in v3:
fix compilation error and add tags.
---
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Tested-by: German Gomez <german.gomez@arm.com>
Reviewed-by: German Gomez <german.gomez@arm.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..f225247acc01 100644
--- a/tools/perf/util/expr.c
+++ b/tools/perf/util/expr.c
@@ -12,6 +12,7 @@
 #include "expr-bison.h"
 #include "expr-flex.h"
 #include "smt.h"
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/zalloc.h>
 #include <ctype.h>
@@ -65,7 +66,12 @@ 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;
+	return hash;
 }
 
 void ids__free(struct hashmap *ids)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] perf expr: Fix return value of ids__new
  2021-12-14  1:10 [PATCH v3] perf expr: Fix return value of ids__new Miaoqian Lin
@ 2021-12-21  8:29 ` Jiri Olsa
  2021-12-21 14:19 ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 4+ messages in thread
From: Jiri Olsa @ 2021-12-21  8:29 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Namhyung Kim, Ian Rogers,
	Andi Kleen, German Gomez, linux-perf-users, linux-kernel

On Tue, Dec 14, 2021 at 01:10:27AM +0000, 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.
> 
> ---
> Changes in v3:
> fix compilation error and add tags.

Acked-by: Jiri Olsa <jolsa@redhat.com>

thanks,
jirka

> ---
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> Tested-by: German Gomez <german.gomez@arm.com>
> Reviewed-by: German Gomez <german.gomez@arm.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..f225247acc01 100644
> --- a/tools/perf/util/expr.c
> +++ b/tools/perf/util/expr.c
> @@ -12,6 +12,7 @@
>  #include "expr-bison.h"
>  #include "expr-flex.h"
>  #include "smt.h"
> +#include <linux/err.h>
>  #include <linux/kernel.h>
>  #include <linux/zalloc.h>
>  #include <ctype.h>
> @@ -65,7 +66,12 @@ 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;
> +	return hash;
>  }
>  
>  void ids__free(struct hashmap *ids)
> -- 
> 2.17.1
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] perf expr: Fix return value of ids__new
  2021-12-14  1:10 [PATCH v3] perf expr: Fix return value of ids__new Miaoqian Lin
  2021-12-21  8:29 ` Jiri Olsa
@ 2021-12-21 14:19 ` Arnaldo Carvalho de Melo
  2021-12-22  4:25   ` [PATCH v4] " Miaoqian Lin
  1 sibling, 1 reply; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-12-21 14:19 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Ian Rogers, Andi Kleen, German Gomez,
	linux-perf-users, linux-kernel

Em Tue, Dec 14, 2021 at 01:10:27AM +0000, Miaoqian Lin escreveu:
> 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.

Please don't use --- as a separator inside the commit message, it breaks
scripts that expect it to be a separator from the commit log message to
the diffstat + patch.

Applying after fixing this.

- Arnaldo
 
> ---
> Changes in v3:
> fix compilation error and add tags.
> ---
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> Tested-by: German Gomez <german.gomez@arm.com>
> Reviewed-by: German Gomez <german.gomez@arm.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..f225247acc01 100644
> --- a/tools/perf/util/expr.c
> +++ b/tools/perf/util/expr.c
> @@ -12,6 +12,7 @@
>  #include "expr-bison.h"
>  #include "expr-flex.h"
>  #include "smt.h"
> +#include <linux/err.h>
>  #include <linux/kernel.h>
>  #include <linux/zalloc.h>
>  #include <ctype.h>
> @@ -65,7 +66,12 @@ 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;
> +	return hash;
>  }
>  
>  void ids__free(struct hashmap *ids)
> -- 
> 2.17.1

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v4] perf expr: Fix return value of ids__new
  2021-12-21 14:19 ` Arnaldo Carvalho de Melo
@ 2021-12-22  4:25   ` Miaoqian Lin
  0 siblings, 0 replies; 4+ messages in thread
From: Miaoqian Lin @ 2021-12-22  4:25 UTC (permalink / raw)
  To: acme
  Cc: ak, alexander.shishkin, german.gomez, irogers, jolsa, linmq006,
	linux-kernel, linux-perf-users, mark.rutland, mingo, namhyung,
	peterz

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>
Tested-by: German Gomez <german.gomez@arm.com>
Reviewed-by: German Gomez <german.gomez@arm.com>
---
Changes in v4:
fix the separator in commit message.
---
 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..f225247acc01 100644
--- a/tools/perf/util/expr.c
+++ b/tools/perf/util/expr.c
@@ -12,6 +12,7 @@
 #include "expr-bison.h"
 #include "expr-flex.h"
 #include "smt.h"
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/zalloc.h>
 #include <ctype.h>
@@ -65,7 +66,12 @@ 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;
+	return hash;
 }
 
 void ids__free(struct hashmap *ids)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-22  4:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14  1:10 [PATCH v3] perf expr: Fix return value of ids__new Miaoqian Lin
2021-12-21  8:29 ` Jiri Olsa
2021-12-21 14:19 ` Arnaldo Carvalho de Melo
2021-12-22  4:25   ` [PATCH v4] " 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).