Skip to content

Commit 1855b79

Browse files
committed
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 <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 4624f19 commit 1855b79

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tools/perf/util/affinity.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void affinity__set(struct affinity *a, int cpu)
6262
clear_bit(cpu, a->sched_cpus);
6363
}
6464

65-
void affinity__cleanup(struct affinity *a)
65+
static void __affinity__cleanup(struct affinity *a)
6666
{
6767
int cpu_set_size = get_cpu_set_size();
6868

@@ -71,3 +71,9 @@ void affinity__cleanup(struct affinity *a)
7171
zfree(&a->sched_cpus);
7272
zfree(&a->orig_cpus);
7373
}
74+
75+
void affinity__cleanup(struct affinity *a)
76+
{
77+
if (a != NULL)
78+
__affinity__cleanup(a);
79+
}

0 commit comments

Comments
 (0)