perf evlist: Destructors should accept NULL

And do nothing, just like free(), to avoid having to test it in callers,
usually in error paths.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-mexbavy0ft387j5w89t365eu@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 89c7cb2c
......@@ -1429,8 +1429,7 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
if (kvm->session)
perf_session__delete(kvm->session);
kvm->session = NULL;
if (kvm->evlist)
perf_evlist__delete(kvm->evlist);
perf_evlist__delete(kvm->evlist);
return err;
}
......
......@@ -200,8 +200,7 @@ static int test_times(int (attach)(struct perf_evlist *),
count.ena, count.run);
out_err:
if (evlist)
perf_evlist__delete(evlist);
perf_evlist__delete(evlist);
return !err ? TEST_OK : TEST_FAIL;
}
......
......@@ -44,8 +44,7 @@ static int process_events(union perf_event **events, size_t count)
for (i = 0; i < count && !err; i++)
err = process_event(&evlist, events[i]);
if (evlist)
perf_evlist__delete(evlist);
perf_evlist__delete(evlist);
return err;
}
......
......@@ -127,6 +127,9 @@ void perf_evlist__exit(struct perf_evlist *evlist)
void perf_evlist__delete(struct perf_evlist *evlist)
{
if (evlist == NULL)
return;
perf_evlist__munmap(evlist);
perf_evlist__close(evlist);
cpu_map__put(evlist->cpus);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment