perf session: 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-dyuupcj0hnoyt96vma8b3anv@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 0b04b3dc
...@@ -419,8 +419,7 @@ int cmd_buildid_cache(int argc, const char **argv, ...@@ -419,8 +419,7 @@ int cmd_buildid_cache(int argc, const char **argv,
pr_warning("Couldn't add %s\n", kcore_filename); pr_warning("Couldn't add %s\n", kcore_filename);
out: out:
if (session) perf_session__delete(session);
perf_session__delete(session);
return ret; return ret;
} }
...@@ -756,9 +756,7 @@ static int __cmd_diff(void) ...@@ -756,9 +756,7 @@ static int __cmd_diff(void)
out_delete: out_delete:
data__for_each_file(i, d) { data__for_each_file(i, d) {
if (d->session) perf_session__delete(d->session);
perf_session__delete(d->session);
data__free(d); data__free(d);
} }
......
...@@ -1426,8 +1426,7 @@ static int kvm_events_live(struct perf_kvm_stat *kvm, ...@@ -1426,8 +1426,7 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
err = kvm_events_live_report(kvm); err = kvm_events_live_report(kvm);
out: out:
if (kvm->session) perf_session__delete(kvm->session);
perf_session__delete(kvm->session);
kvm->session = NULL; kvm->session = NULL;
perf_evlist__delete(kvm->evlist); perf_evlist__delete(kvm->evlist);
......
...@@ -178,6 +178,8 @@ static void perf_session__delete_threads(struct perf_session *session) ...@@ -178,6 +178,8 @@ static void perf_session__delete_threads(struct perf_session *session)
void perf_session__delete(struct perf_session *session) void perf_session__delete(struct perf_session *session)
{ {
if (session == NULL)
return;
auxtrace__free(session); auxtrace__free(session);
auxtrace_index__free(&session->auxtrace_index); auxtrace_index__free(&session->auxtrace_index);
perf_session__destroy_kernel_maps(session); perf_session__destroy_kernel_maps(session);
......
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