diff options
author | Arnaldo Carvalho de Melo <[email protected]> | 2016-06-22 10:19:11 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <[email protected]> | 2016-06-22 10:19:11 -0300 |
commit | 32ca678dcd250f05183cf0c8a9e516545c6068bc (patch) | |
tree | 25604da734a20e54457e79e8bc02ec09b631feb0 | |
parent | 61b3f66a3f99bb8a6a5145b1c2bd7eb98bf64748 (diff) |
perf machine: 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 <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Wang Nan <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
-rw-r--r-- | tools/perf/util/machine.c | 6 | ||||
-rw-r--r-- | tools/perf/util/probe-event.c | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index a0c186acb1f3..bc2cdbd09a25 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -138,8 +138,10 @@ void machine__exit(struct machine *machine) void machine__delete(struct machine *machine) { - machine__exit(machine); - free(machine); + if (machine) { + machine__exit(machine); + free(machine); + } } void machines__init(struct machines *machines) diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 084756c17309..caad19d8c7ef 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -102,10 +102,8 @@ out: void exit_probe_symbol_maps(void) { - if (host_machine) { - machine__delete(host_machine); - host_machine = NULL; - } + machine__delete(host_machine); + host_machine = NULL; symbol__exit(); } |