mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Raphael Santana carvalho <utroz@oakcoders.com>
Cc: fweisbec@gmail.com, mingo@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] kernel/trace: gcc warning: uninitialized variable.
Date: Fri, 11 May 2012 23:08:02 -0400	[thread overview]
Message-ID: <1336792082.14207.262.camel@gandalf.stny.rr.com> (raw)
In-Reply-To: <CADeC0sNq41kGWw6JbASu6WE-SkTHihf9SnKCTaBTSyas4TJoMg@mail.gmail.com>

On Fri, 2012-05-11 at 23:26 -0300, Raphael Santana carvalho wrote:
> >From 2f1490c5e8e2a393d9376d959e2ff6836757f51a Mon Sep 17 00:00:00 2001
> From: Raphael S.Carvalho <utroz@oakcoders.com>
> Date: Fri, 11 May 2012 22:58:43 -0300
> Subject: [PATCH 1/1] kernel/trace: gcc warning: uninitialized variable.
> 
> I've received a problem in this file when I was compiling my own kernel.
> It's a simple uninitialized variable, so that gcc is warning about it.
> 
> The function is actually working correctly, because it's impossible to use the
> variable(page2) uninitialized because it's only referenced if nr_pages == 2,
> and we will have previously set it in that case.

Correct.

> 
> gcc version 4.5.2 (GCC) - Follows the warning:

It's a bug in gcc. If you use gcc 4.6 or later it does not warn.

As this code may change in the future, I don't want to hide errors that
gcc 4.6 could catch. Thus I'm not going to take this patch.

Don't feel bad, you're probably the 5th person I declined this change
from. At least you noticed that it was just gcc complaining and did not
blindly set the variable to NULL.

-- Steve

> kernel/trace/trace.c:3755:8 warning: 'page2': may be used uninitialized in this function
> 
> Signed-off-by: Raphael S.Carvalho <utroz@oakcoders.com>
> ---
>  kernel/trace/trace.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 2a22255..4ffff83 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -3752,7 +3752,7 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
>      int nr_pages = 1;
>      ssize_t written;
>      void *page1;
> -    void *page2;
> +    void *uninitialized_var(page2);
>      int offset;
>      int size;
>      int len;



       reply	other threads:[~2012-05-12  3:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CADeC0sNq41kGWw6JbASu6WE-SkTHihf9SnKCTaBTSyas4TJoMg@mail.gmail.com>
2012-05-12  3:08 ` Steven Rostedt [this message]
2012-05-12  3:27   ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1336792082.14207.262.camel@gandalf.stny.rr.com \
    --to=rostedt@goodmis.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=utroz@oakcoders.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®