Messages in this thread | | | Date | Sat, 8 Aug 2009 04:30:39 +0200 | From | Frederic Weisbecker <> | Subject | Re: [PATCH 1/3] perfcounter: Initialize tracepoint record before any use |
| |
On Sat, Aug 08, 2009 at 04:26:35AM +0200, Frederic Weisbecker wrote: > Despite that the tracepoint record is always present when the > PERF_SAMPLE_TP_RECORD flag is set, gcc whines, 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> > ---
Hmm, sorry I've resent the perf tools series by mistake. Please ignore the [PATCH */4] "perf tools: *" series that has already been sent.
The only ones are [PATCH */3] perfcounter: *
Thanks.
> kernel/perf_counter.c | 7 ++++--- > 1 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c > index 142ae5a..a6963e2 100644 > --- a/kernel/perf_counter.c > +++ b/kernel/perf_counter.c > @@ -2647,7 +2647,7 @@ void perf_counter_output(struct perf_counter *counter, int nmi, > u64 counter; > } group_entry; > struct perf_callchain_entry *callchain = NULL; > - struct perf_tracepoint_record *tp; > + struct perf_tracepoint_record *tp = NULL; > int callchain_size = 0; > u64 time; > struct { > @@ -2718,7 +2718,8 @@ void perf_counter_output(struct perf_counter *counter, int nmi, > > if (sample_type & PERF_SAMPLE_TP_RECORD) { > tp = data->private; > - header.size += tp->size; > + if (tp) > + header.size += tp->size; > } > > ret = perf_output_begin(&handle, counter, header.size, nmi, 1); > @@ -2784,7 +2785,7 @@ 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_end(&handle); > -- > 1.6.2.3 >
-- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |