linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] tools:util:Remove the check that map is empty.
@ 2024-08-21 10:14 Yang Ruibin
  2024-08-21 14:37 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Ruibin @ 2024-08-21 10:14 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Liang, Kan, Yang Ruibin,
	Stephen Rothwell, linux-perf-users, linux-kernel, bpf
  Cc: opensource.kernel

The check that map is empty is already done in the bpf_map__fd (map)
function and returns an err_no, which does not run further checks.
 In addition, even if the check for map is run, the return is a pointer,
 which is not consistent with the err_number returned by bpf_map__fd (map).

Signed-off-by: Yang Ruibin <11162571@vivo.com>
---
 tools/perf/util/bpf_map.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/tools/perf/util/bpf_map.c b/tools/perf/util/bpf_map.c
index 81a4d5a7ccf7..578f27d2d6b4 100644
--- a/tools/perf/util/bpf_map.c
+++ b/tools/perf/util/bpf_map.c
@@ -35,9 +35,6 @@ int bpf_map__fprintf(struct bpf_map *map, FILE *fp)
 	if (fd < 0)
 		return fd;
 
-	if(!map)
-		return PTR_ERR(map);
-
 	err = -ENOMEM;
 	key = malloc(bpf_map__key_size(map));
 	if (key == NULL)
-- 
2.34.1


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

* Re: [PATCH v1] tools:util:Remove the check that map is empty.
  2024-08-21 10:14 [PATCH v1] tools:util:Remove the check that map is empty Yang Ruibin
@ 2024-08-21 14:37 ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-08-21 14:37 UTC (permalink / raw)
  To: Yang Ruibin
  Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	Liang, Kan, Stephen Rothwell, linux-perf-users, linux-kernel, bpf,
	opensource.kernel

On Wed, Aug 21, 2024 at 06:14:56AM -0400, Yang Ruibin wrote:
> The check that map is empty is already done in the bpf_map__fd (map)
> function and returns an err_no, which does not run further checks.
>  In addition, even if the check for map is run, the return is a pointer,
>  which is not consistent with the err_number returned by bpf_map__fd (map).

Thanks, applied, looks like an artifact from the patch that removed the
bpf_map__def() API.

- Arnaldo
 
> Signed-off-by: Yang Ruibin <11162571@vivo.com>
> ---
>  tools/perf/util/bpf_map.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/tools/perf/util/bpf_map.c b/tools/perf/util/bpf_map.c
> index 81a4d5a7ccf7..578f27d2d6b4 100644
> --- a/tools/perf/util/bpf_map.c
> +++ b/tools/perf/util/bpf_map.c
> @@ -35,9 +35,6 @@ int bpf_map__fprintf(struct bpf_map *map, FILE *fp)
>  	if (fd < 0)
>  		return fd;
>  
> -	if(!map)
> -		return PTR_ERR(map);
> -
>  	err = -ENOMEM;
>  	key = malloc(bpf_map__key_size(map));
>  	if (key == NULL)
> -- 
> 2.34.1

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

end of thread, other threads:[~2024-08-21 14:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-21 10:14 [PATCH v1] tools:util:Remove the check that map is empty Yang Ruibin
2024-08-21 14:37 ` Arnaldo Carvalho de Melo

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).