Re: [PATCH] kernel/trace: fix compiler warning
From: Steven Rostedt
Date: Tue Feb 11 2014 - 11:04:01 EST
On Tue, 11 Feb 2014 23:41:41 +0800
Qiaowei Ren <qiaowei.ren@xxxxxxxxx> wrote:
> The patch fixes the following compiler warning:
> CC kernel/trace/trace_events.o
> kernel/trace/trace_events.c: In function 'event_enable_read'
> kernel/trace/trace_events.c:693: warning: 'flags' may be used \
> uninitialized in this function
You don't happen to have the branch profilers enabled?
Is CONFIG_TRACE_BRANCH_PROFILING set?
>
> Signed-off-by: Qiaowei Ren <qiaowei.ren@xxxxxxxxx>
> ---
> kernel/trace/trace_events.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> index e71ffd4..b7915f2 100644
> --- a/kernel/trace/trace_events.c
> +++ b/kernel/trace/trace_events.c
> @@ -690,7 +690,7 @@ event_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
> loff_t *ppos)
> {
> struct ftrace_event_file *file;
> - unsigned long flags;
> + unsigned long flags = 0;
> char buf[4] = "0";
>
> mutex_lock(&event_mutex);
False warning, and most likely because the branch profilers screw up
gcc's ability to figure these things out.
Here's the content of that function:
mutex_lock(&event_mutex);
file = event_file_data(filp);
if (likely(file))
flags = file->flags;
mutex_unlock(&event_mutex);
if (!file)
return -ENODEV;
if (flags & FTRACE_EVENT_FL_ENABLED &&
Pretty obvious that flags can not be used uninitialized. If you happen
to have BRANCH profiling enabled, you must ignore all the gcc "might be
used uninitialized" warnings. They are useless.
This is not a bug, sorry.
-- Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/