perf_counter: Work around gcc warning by initializing tracepoint record unconditionally
Despite that the tracepoint record is always present when the PERF_SAMPLE_TP_RECORD flag is set, gcc raises a warning, thinking it might not be initialized: kernel/perf_counter.c: In function ‘perf_counter_output’: kernel/perf_counter.c:2650: warning: ‘tp’ may be used uninitialized in this function Then, initialize it to NULL and always check if it's not NULL before dereference it. Reported-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1249698400-5441-2-git-send-email-fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
25446036cb
commit
10b8e30660
1 changed files with 4 additions and 3 deletions
|
@ -2646,7 +2646,7 @@ static void perf_counter_output(struct perf_counter *counter, int nmi,
|
||||||
u64 counter;
|
u64 counter;
|
||||||
} group_entry;
|
} group_entry;
|
||||||
struct perf_callchain_entry *callchain = NULL;
|
struct perf_callchain_entry *callchain = NULL;
|
||||||
struct perf_tracepoint_record *tp;
|
struct perf_tracepoint_record *tp = NULL;
|
||||||
int callchain_size = 0;
|
int callchain_size = 0;
|
||||||
u64 time;
|
u64 time;
|
||||||
struct {
|
struct {
|
||||||
|
@ -2717,6 +2717,7 @@ static void perf_counter_output(struct perf_counter *counter, int nmi,
|
||||||
|
|
||||||
if (sample_type & PERF_SAMPLE_TP_RECORD) {
|
if (sample_type & PERF_SAMPLE_TP_RECORD) {
|
||||||
tp = data->private;
|
tp = data->private;
|
||||||
|
if (tp)
|
||||||
header.size += tp->size;
|
header.size += tp->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2783,7 +2784,7 @@ static void perf_counter_output(struct perf_counter *counter, int nmi,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sample_type & PERF_SAMPLE_TP_RECORD)
|
if ((sample_type & PERF_SAMPLE_TP_RECORD) && tp)
|
||||||
perf_output_copy(&handle, tp->record, tp->size);
|
perf_output_copy(&handle, tp->record, tp->size);
|
||||||
|
|
||||||
perf_output_end(&handle);
|
perf_output_end(&handle);
|
||||||
|
|
Loading…
Add table
Reference in a new issue