提交 f39cdf25 编写于 作者: J Julia Lawall 提交者: Ingo Molnar

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: NJulia Lawall <julia@diku.dk>
LKML-Reference: <Pine.LNX.4.64.0910170842500.9213@ask.diku.dk>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 434a83c3
...@@ -104,14 +104,14 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head) ...@@ -104,14 +104,14 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
event->ip.pid, event->ip.pid,
(void *)(long)ip); (void *)(long)ip);
dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
if (thread == NULL) { if (thread == NULL) {
fprintf(stderr, "problem processing %d event, skipping it.\n", fprintf(stderr, "problem processing %d event, skipping it.\n",
event->header.type); event->header.type);
return -1; return -1;
} }
dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
if (event->header.misc & PERF_RECORD_MISC_KERNEL) { if (event->header.misc & PERF_RECORD_MISC_KERNEL) {
level = 'k'; level = 'k';
sym = kernel_maps__find_symbol(ip, &map); sym = kernel_maps__find_symbol(ip, &map);
......
...@@ -629,14 +629,14 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head) ...@@ -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) { if (thread == NULL) {
eprintf("problem processing %d event, skipping it.\n", eprintf("problem processing %d event, skipping it.\n",
event->header.type); event->header.type);
return -1; return -1;
} }
dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
if (comm_list && !strlist__has_entry(comm_list, thread->comm)) if (comm_list && !strlist__has_entry(comm_list, thread->comm))
return 0; return 0;
......
...@@ -1667,14 +1667,14 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head) ...@@ -1667,14 +1667,14 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
(void *)(long)ip, (void *)(long)ip,
(long long)period); (long long)period);
dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
if (thread == NULL) { if (thread == NULL) {
eprintf("problem processing %d event, skipping it.\n", eprintf("problem processing %d event, skipping it.\n",
event->header.type); event->header.type);
return -1; return -1;
} }
dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
if (profile_cpu != -1 && profile_cpu != (int) cpu) if (profile_cpu != -1 && profile_cpu != (int) cpu)
return 0; return 0;
......
...@@ -80,14 +80,14 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head) ...@@ -80,14 +80,14 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
(void *)(long)ip, (void *)(long)ip,
(long long)period); (long long)period);
dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
if (thread == NULL) { if (thread == NULL) {
eprintf("problem processing %d event, skipping it.\n", eprintf("problem processing %d event, skipping it.\n",
event->header.type); event->header.type);
return -1; return -1;
} }
dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
if (sample_type & PERF_SAMPLE_RAW) { if (sample_type & PERF_SAMPLE_RAW) {
struct { struct {
u32 size; u32 size;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册