[PATCH 1/1] perf tools: Deletion of unnecessary checks before two function calls

From: SF Markus Elfring
Date: Mon Nov 17 2014 - 12:12:20 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 17 Nov 2014 18:05:57 +0100

The functions free_event_desc() and strfilter__delete() test whether their
argument is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
tools/perf/builtin-probe.c | 6 ++----
tools/perf/util/header.c | 3 +--
2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index c63fa29..1b72bf2 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -254,8 +254,7 @@ static int opt_set_filter(const struct option *opt __maybe_unused,

if (str) {
pr_debug2("Set filter: %s\n", str);
- if (params.filter)
- strfilter__delete(params.filter);
+ strfilter__delete(params.filter);
params.filter = strfilter__new(str, &err);
if (!params.filter) {
pr_err("Filter parse error at %td.\n", err - str + 1);
@@ -283,8 +282,7 @@ static void cleanup_params(void)
strlist__delete(params.dellist);
line_range__clear(&params.line_range);
free(params.target);
- if (params.filter)
- strfilter__delete(params.filter);
+ strfilter__delete(params.filter);
memset(&params, 0, sizeof(params));
}

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 158c787..a62fbc6 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1367,8 +1367,7 @@ out:
free(buf);
return events;
error:
- if (events)
- free_event_desc(events);
+ free_event_desc(events);
events = NULL;
goto out;
}
--
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/