summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2009-10-17 08:43:17 +0200
committerIngo Molnar <mingo@elte.hu>2009-10-17 09:29:10 +0200
commitf39cdf25bf77219676ec5360980ac40b1a7e144a (patch)
tree2143a3653933efc5ffacea647ce8be72952b3a44
parent434a83c3fbb951908a3a52040f7f0e0b8ba00dd0 (diff)
perf tools: Move dereference after NULL test
In each case, if the NULL test on thread is needed, then the dereference should be after the NULL test. A simplified version of the semantic match that detects this problem is as follows (http://coccinelle.lip6.fr/): // <smpl> @match exists@ expression x, E; identifier fld; @@ * x->fld ... when != \(x = E\|&x\) * x == NULL // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> LKML-Reference: <Pine.LNX.4.64.0910170842500.9213@ask.diku.dk> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--tools/perf/builtin-annotate.c4
-rw-r--r--tools/perf/builtin-report.c4
-rw-r--r--tools/perf/builtin-sched.c4
-rw-r--r--tools/perf/builtin-trace.c4
4 files changed, 8 insertions, 8 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 3fe0de03004..56ba71658d7 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -104,14 +104,14 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
event->ip.pid,
(void *)(long)ip);
- dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
-
if (thread == NULL) {
fprintf(stderr, "problem processing %d event, skipping it.\n",
event->header.type);
return -1;
}
+ dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
+
if (event->header.misc & PERF_RECORD_MISC_KERNEL) {
level = 'k';
sym = kernel_maps__find_symbol(ip, &map);
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 015c7974596..a4f8cc20915 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -629,14 +629,14 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
}
}
- dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
-
if (thread == NULL) {
eprintf("problem processing %d event, skipping it.\n",
event->header.type);
return -1;
}
+ dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
+
if (comm_list && !strlist__has_entry(comm_list, thread->comm))
return 0;
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index c9c68563e96..57ad3f458ef 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1667,14 +1667,14 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
(void *)(long)ip,
(long long)period);
- dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
-
if (thread == NULL) {
eprintf("problem processing %d event, skipping it.\n",
event->header.type);
return -1;
}
+ dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
+
if (profile_cpu != -1 && profile_cpu != (int) cpu)
return 0;
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index ce8459ac284..4c129ff0bb1 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -80,14 +80,14 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
(void *)(long)ip,
(long long)period);
- dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
-
if (thread == NULL) {
eprintf("problem processing %d event, skipping it.\n",
event->header.type);
return -1;
}
+ dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
+
if (sample_type & PERF_SAMPLE_RAW) {
struct {
u32 size;