From: Markus Elfring <[email protected]>
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 <[email protected]>
---
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(¶ms.line_range);
free(params.target);
- if (params.filter)
- strfilter__delete(params.filter);
+ strfilter__delete(params.filter);
memset(¶ms, 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
From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 07:44:22 +0200
The strfilter__delete() function tests whether its argument is NULL and
then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <[email protected]>
---
tools/perf/builtin-probe.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 1272559..b81cec3 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -297,8 +297,7 @@ static void cleanup_params(void)
clear_perf_probe_event(params.events + i);
line_range__clear(¶ms.line_range);
free(params.target);
- if (params.filter)
- strfilter__delete(params.filter);
+ strfilter__delete(params.filter);
memset(¶ms, 0, sizeof(params));
}
--
2.4.5
On 2015/07/04 14:54, SF Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> Date: Sat, 4 Jul 2015 07:44:22 +0200
>
> The strfilter__delete() function tests whether its argument is NULL and
> then returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
This looks OK for me.
Acked-by: Masami Hiramatsu <[email protected]>
> Signed-off-by: Markus Elfring <[email protected]>
> ---
> tools/perf/builtin-probe.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
> index 1272559..b81cec3 100644
> --- a/tools/perf/builtin-probe.c
> +++ b/tools/perf/builtin-probe.c
> @@ -297,8 +297,7 @@ static void cleanup_params(void)
> clear_perf_probe_event(params.events + i);
> line_range__clear(¶ms.line_range);
> free(params.target);
> - if (params.filter)
> - strfilter__delete(params.filter);
> + strfilter__delete(params.filter);
> memset(¶ms, 0, sizeof(params));
> }
>
>
--
Masami HIRAMATSU
Linux Technology Research Center, System Productivity Research Dept.
Center for Technology Innovation - Systems Engineering
Hitachi, Ltd., Research & Development Group
E-mail: [email protected]
Commit-ID: 200802a4a79b3a7a1cf924ad870d3265023d0787
Gitweb: http://git.kernel.org/tip/200802a4a79b3a7a1cf924ad870d3265023d0787
Author: Markus Elfring <[email protected]>
AuthorDate: Sat, 4 Jul 2015 07:44:22 +0200
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 6 Jul 2015 08:58:36 -0300
perf probe: Delete an unnecessary check before the function call "strfilter__delete"
The strfilter__delete() function tests whether its argument is NULL and
then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <[email protected]>
Acked-by: Masami Hiramatsu <[email protected]>
Cc: Julia Lawall <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/builtin-probe.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 1272559..b81cec3 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -297,8 +297,7 @@ static void cleanup_params(void)
clear_perf_probe_event(params.events + i);
line_range__clear(¶ms.line_range);
free(params.target);
- if (params.filter)
- strfilter__delete(params.filter);
+ strfilter__delete(params.filter);
memset(¶ms, 0, sizeof(params));
}