From: Arnaldo Carvalho de Melo Date: Mon, 17 Jan 2022 16:09:28 +0000 (-0300) Subject: perf affinity: Allow passing a NULL arg to affinity__cleanup() X-Git-Tag: v6.1-rc5~2137^2~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1855b796f2f672cbb25400be2d3171c26fc869a3;p=platform%2Fkernel%2Flinux-starfive.git perf affinity: Allow passing a NULL arg to affinity__cleanup() Just like with free(), NULL is checked to avoid having all callers do it. Its convenient for when not using affinity setup/cleanup for dummy CPU maps, i.e. CPU maps for pid targets. Acked-by: Ian Rogers Cc: Adrian Hunter Cc: Andi Kleen Cc: Ian Rogers Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lore.kernel.org/r/20220117160931.1191712-2-acme@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/affinity.c b/tools/perf/util/affinity.c index f1e30d5..4d216c0 100644 --- a/tools/perf/util/affinity.c +++ b/tools/perf/util/affinity.c @@ -62,7 +62,7 @@ void affinity__set(struct affinity *a, int cpu) clear_bit(cpu, a->sched_cpus); } -void affinity__cleanup(struct affinity *a) +static void __affinity__cleanup(struct affinity *a) { int cpu_set_size = get_cpu_set_size(); @@ -71,3 +71,9 @@ void affinity__cleanup(struct affinity *a) zfree(&a->sched_cpus); zfree(&a->orig_cpus); } + +void affinity__cleanup(struct affinity *a) +{ + if (a != NULL) + __affinity__cleanup(a); +}