* [PATCH] Trace: initialize variable to clear warning
@ 2012-02-28 9:09 Zhengwang Ruan
2012-02-28 10:27 ` Borislav Petkov
2012-02-28 14:16 ` Steven Rostedt
0 siblings, 2 replies; 7+ messages in thread
From: Zhengwang Ruan @ 2012-02-28 9:09 UTC (permalink / raw)
To: rostedt, fweisbec, mingo; +Cc: linux-kernel, kernel-janitors
GCC warns that 'page2' is used without being initialized previously before
being used, this is to clear it.
Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.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 a3f1bc5..47376ba 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3694,7 +3694,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;
--
1.6.0.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] Trace: initialize variable to clear warning
2012-02-28 9:09 [PATCH] Trace: initialize variable to clear warning Zhengwang Ruan
@ 2012-02-28 10:27 ` Borislav Petkov
2012-02-28 14:16 ` Steven Rostedt
1 sibling, 0 replies; 7+ messages in thread
From: Borislav Petkov @ 2012-02-28 10:27 UTC (permalink / raw)
To: Zhengwang Ruan; +Cc: rostedt, fweisbec, mingo, linux-kernel, kernel-janitors
On Tue, Feb 28, 2012 at 05:09:34PM +0800, Zhengwang Ruan wrote:
> GCC warns that 'page2' is used without being initialized previously before
> being used, this is to clear it.
>
> Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.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 a3f1bc5..47376ba 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -3694,7 +3694,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;
We had this already - gcc 4.5 warns incorrectly about this, you should
upgrade to 4.6: http://marc.info/?l=linux-kernel&m=132083844427859
--
Regards/Gruss,
Boris.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Trace: initialize variable to clear warning
2012-02-28 9:09 [PATCH] Trace: initialize variable to clear warning Zhengwang Ruan
2012-02-28 10:27 ` Borislav Petkov
@ 2012-02-28 14:16 ` Steven Rostedt
2012-02-29 22:40 ` Valdis.Kletnieks
1 sibling, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2012-02-28 14:16 UTC (permalink / raw)
To: Zhengwang Ruan; +Cc: fweisbec, mingo, linux-kernel, kernel-janitors
On Tue, 2012-02-28 at 17:09 +0800, Zhengwang Ruan wrote:
> GCC warns that 'page2' is used without being initialized previously before
> being used, this is to clear it.
>
This is a bug in gcc that's fixed in 4.6 and beyond. I don't want to
remove this warning because it will hide a real bug if page2 really does
become uninitialized. If 4.6 gives a warning here, then I'll fix it.
Note, we can't just initialize it here either, because it is initialized
in the code, and if it gets used later without that initialization then
it will break. No default will work.
Thanks,
-- Steve
> Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.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 a3f1bc5..47376ba 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -3694,7 +3694,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;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Trace: initialize variable to clear warning
2012-02-28 14:16 ` Steven Rostedt
@ 2012-02-29 22:40 ` Valdis.Kletnieks
2012-03-01 1:09 ` Steven Rostedt
0 siblings, 1 reply; 7+ messages in thread
From: Valdis.Kletnieks @ 2012-02-29 22:40 UTC (permalink / raw)
To: Steven Rostedt
Cc: Zhengwang Ruan, fweisbec, mingo, linux-kernel, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 477 bytes --]
On Tue, 28 Feb 2012 09:16:31 EST, Steven Rostedt said:
> This is a bug in gcc that's fixed in 4.6 and beyond. I don't want to
> remove this warning because it will hide a real bug if page2 really does
> become uninitialized. If 4.6 gives a warning here, then I'll fix it.
> > - void *page2;
> > + void *uninitialized_var(page2);
How would you feel about this?
- void *page2;
+ void *page2; /* gcc 4.5 bug causes incorrect "uninitialized" warning */
or something similar?
[-- Attachment #2: Type: application/pgp-signature, Size: 865 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Trace: initialize variable to clear warning
2012-02-29 22:40 ` Valdis.Kletnieks
@ 2012-03-01 1:09 ` Steven Rostedt
2012-03-01 2:08 ` Zhengwang Ruan
0 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2012-03-01 1:09 UTC (permalink / raw)
To: Valdis.Kletnieks
Cc: Zhengwang Ruan, fweisbec, mingo, linux-kernel, kernel-janitors
On Wed, 2012-02-29 at 17:40 -0500, Valdis.Kletnieks@vt.edu wrote:
> On Tue, 28 Feb 2012 09:16:31 EST, Steven Rostedt said:
>
> > This is a bug in gcc that's fixed in 4.6 and beyond. I don't want to
> > remove this warning because it will hide a real bug if page2 really does
> > become uninitialized. If 4.6 gives a warning here, then I'll fix it.
>
> > > - void *page2;
> > > + void *uninitialized_var(page2);
>
> How would you feel about this?
>
> - void *page2;
> + void *page2; /* gcc 4.5 bug causes incorrect "uninitialized" warning */
>
> or something similar?
/* if you get a warning here, upgrade your gcc to 4.6 */
-- Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Trace: initialize variable to clear warning
2012-03-01 1:09 ` Steven Rostedt
@ 2012-03-01 2:08 ` Zhengwang Ruan
2012-03-01 2:23 ` Valdis.Kletnieks
0 siblings, 1 reply; 7+ messages in thread
From: Zhengwang Ruan @ 2012-03-01 2:08 UTC (permalink / raw)
To: Steven Rostedt
Cc: Valdis.Kletnieks, fweisbec, mingo, linux-kernel, kernel-janitors
-------- Original Message --------
From: Steven Rostedt
Sent: 2012年02月29日 星期三 20时09分18秒
To: Valdis.Kletnieks
Subject: Re: [PATCH] Trace: initialize variable to clear warning
> On Wed, 2012-02-29 at 17:40 -0500, Valdis.Kletnieks@vt.edu wrote:
>> On Tue, 28 Feb 2012 09:16:31 EST, Steven Rostedt said:
>>
>>> This is a bug in gcc that's fixed in 4.6 and beyond. I don't want to
>>> remove this warning because it will hide a real bug if page2 really does
>>> become uninitialized. If 4.6 gives a warning here, then I'll fix it.
>>>> - void *page2;
>>>> + void *uninitialized_var(page2);
>> How would you feel about this?
>>
>> - void *page2;
>> + void *page2; /* gcc 4.5 bug causes incorrect "uninitialized" warning */
>>
>> or something similar?
> /* if you get a warning here, upgrade your gcc to 4.6 */
>
OK, I will resend this patch.
Thanks,
-Zhengwang
> -- Steve
>
>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Trace: initialize variable to clear warning
2012-03-01 2:08 ` Zhengwang Ruan
@ 2012-03-01 2:23 ` Valdis.Kletnieks
0 siblings, 0 replies; 7+ messages in thread
From: Valdis.Kletnieks @ 2012-03-01 2:23 UTC (permalink / raw)
To: Zhengwang Ruan
Cc: Steven Rostedt, fweisbec, mingo, linux-kernel, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 272 bytes --]
On Thu, 01 Mar 2012 10:08:56 +0800, Zhengwang Ruan said:
> > /* if you get a warning here, upgrade your gcc to 4.6 */
> >
>
> OK, I will resend this patch.
For the version with Steven's suggested comment:
Acked-By: Valdis Kletnieks <valdis.kletnieks@vt.edu>
[-- Attachment #2: Type: application/pgp-signature, Size: 865 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-03-01 2:23 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-28 9:09 [PATCH] Trace: initialize variable to clear warning Zhengwang Ruan
2012-02-28 10:27 ` Borislav Petkov
2012-02-28 14:16 ` Steven Rostedt
2012-02-29 22:40 ` Valdis.Kletnieks
2012-03-01 1:09 ` Steven Rostedt
2012-03-01 2:08 ` Zhengwang Ruan
2012-03-01 2:23 ` Valdis.Kletnieks
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox