* [PATCH] drivers/ata/libata-eh.c: fix unused variable warning
@ 2010-04-21 14:07 Fang Wenqi
2010-04-21 14:24 ` Alan Cox
2010-04-23 1:54 ` Jeff Garzik
0 siblings, 2 replies; 13+ messages in thread
From: Fang Wenqi @ 2010-04-21 14:07 UTC (permalink / raw)
To: jgarzik, linux-ide; +Cc: antonf, anton.fang
CC drivers/ata/libata-eh.o
drivers/ata/libata-eh.c: In function ‘ata_eh_analyze_ncq_error’:
drivers/ata/libata-eh.c:1642: warning: ‘tf.flags’ may be used uninitialized in this function
Signed-off-by: Fang Wenqi <antonf@turbolinux.com.cn>
---
drivers/ata/libata-eh.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 9f6cfac..125ec25 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -1601,7 +1601,7 @@ void ata_eh_analyze_ncq_error(struct ata_link *link)
struct ata_eh_context *ehc = &link->eh_context;
struct ata_device *dev = link->device;
struct ata_queued_cmd *qc;
- struct ata_taskfile tf;
+ struct ata_taskfile uninitialized_var(tf);
int tag, rc;
/* if frozen, we can't do much */
--
1.6.6.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] drivers/ata/libata-eh.c: fix unused variable warning
2010-04-21 14:07 [PATCH] drivers/ata/libata-eh.c: fix unused variable warning Fang Wenqi
@ 2010-04-21 14:24 ` Alan Cox
2010-04-21 14:57 ` Fang Wenqi
2010-04-23 1:54 ` Jeff Garzik
1 sibling, 1 reply; 13+ messages in thread
From: Alan Cox @ 2010-04-21 14:24 UTC (permalink / raw)
To: Fang Wenqi; +Cc: jgarzik, linux-ide, antonf
On Wed, 21 Apr 2010 22:07:26 +0800
Fang Wenqi <anton.fang@gmail.com> wrote:
> CC drivers/ata/libata-eh.o
> drivers/ata/libata-eh.c: In function ‘ata_eh_analyze_ncq_error’:
> drivers/ata/libata-eh.c:1642: warning: ‘tf.flags’ may be used uninitialized in this function
Which compiler are you using. gcc 4.4.3 seems to have no trouble working
this out correctly and issues no warning ?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] drivers/ata/libata-eh.c: fix unused variable warning
2010-04-21 14:24 ` Alan Cox
@ 2010-04-21 14:57 ` Fang Wenqi
2010-04-22 1:23 ` Fang Wenqi
0 siblings, 1 reply; 13+ messages in thread
From: Fang Wenqi @ 2010-04-21 14:57 UTC (permalink / raw)
To: Alan Cox; +Cc: jgarzik, linux-ide, antonf
I'm using gcc 4.4.3 on Fedora 12:
$ gcc -v
Using built-in specs.
Target: i686-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared
--enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi
--enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile
--enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch=i686
--build=i686-redhat-linux
Thread model: posix
gcc version 4.4.3 20100127 (Red Hat 4.4.3-4) (GCC)
On 04/21/2010 10:24 PM, Alan Cox wrote:
> On Wed, 21 Apr 2010 22:07:26 +0800
> Fang Wenqi<anton.fang@gmail.com> wrote:
>
>> CC drivers/ata/libata-eh.o
>> drivers/ata/libata-eh.c: In function ‘ata_eh_analyze_ncq_error’:
>> drivers/ata/libata-eh.c:1642: warning: ‘tf.flags’ may be used uninitialized in this function
>
> Which compiler are you using. gcc 4.4.3 seems to have no trouble working
> this out correctly and issues no warning ?
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] drivers/ata/libata-eh.c: fix unused variable warning
2010-04-21 14:57 ` Fang Wenqi
@ 2010-04-22 1:23 ` Fang Wenqi
2010-04-23 6:30 ` Tejun Heo
0 siblings, 1 reply; 13+ messages in thread
From: Fang Wenqi @ 2010-04-22 1:23 UTC (permalink / raw)
To: jgarzik, linux-ide; +Cc: Alan Cox, antonf
Sorry that the title should be:
"fix uninitialized variable warning"
not
"fix unused variable warning"
Need I re-send the patch mail ?
On 04/21/2010 10:57 PM, Fang Wenqi wrote:
>
> I'm using gcc 4.4.3 on Fedora 12:
>
> $ gcc -v
> Using built-in specs.
> Target: i686-redhat-linux
> Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
> --infodir=/usr/share/info
> --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap
> --enable-shared --enable-threads=posix --enable-checking=release
> --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
> --enable-gnu-unique-object
> --enable-languages=c,c++,objc,obj-c++,java,fortran,ada
> --enable-java-awt=gtk --disable-dssi --enable-plugin
> --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
> --enable-libgcj-multifile --enable-java-maintainer-mode
> --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
> --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic
> --with-arch=i686 --build=i686-redhat-linux
> Thread model: posix
> gcc version 4.4.3 20100127 (Red Hat 4.4.3-4) (GCC)
>
>
> On 04/21/2010 10:24 PM, Alan Cox wrote:
>> On Wed, 21 Apr 2010 22:07:26 +0800
>> Fang Wenqi<anton.fang@gmail.com> wrote:
>>
>>> CC drivers/ata/libata-eh.o
>>> drivers/ata/libata-eh.c: In function ‘ata_eh_analyze_ncq_error’:
>>> drivers/ata/libata-eh.c:1642: warning: ‘tf.flags’ may be used
>>> uninitialized in this function
>>
>> Which compiler are you using. gcc 4.4.3 seems to have no trouble working
>> this out correctly and issues no warning ?
>>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] drivers/ata/libata-eh.c: fix unused variable warning
2010-04-21 14:07 [PATCH] drivers/ata/libata-eh.c: fix unused variable warning Fang Wenqi
2010-04-21 14:24 ` Alan Cox
@ 2010-04-23 1:54 ` Jeff Garzik
1 sibling, 0 replies; 13+ messages in thread
From: Jeff Garzik @ 2010-04-23 1:54 UTC (permalink / raw)
To: Fang Wenqi; +Cc: jgarzik, linux-ide, antonf
On 04/21/2010 10:07 AM, Fang Wenqi wrote:
> CC drivers/ata/libata-eh.o
> drivers/ata/libata-eh.c: In function ‘ata_eh_analyze_ncq_error’:
> drivers/ata/libata-eh.c:1642: warning: ‘tf.flags’ may be used uninitialized in this function
>
> Signed-off-by: Fang Wenqi<antonf@turbolinux.com.cn>
> ---
> drivers/ata/libata-eh.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
> index 9f6cfac..125ec25 100644
> --- a/drivers/ata/libata-eh.c
> +++ b/drivers/ata/libata-eh.c
> @@ -1601,7 +1601,7 @@ void ata_eh_analyze_ncq_error(struct ata_link *link)
> struct ata_eh_context *ehc =&link->eh_context;
> struct ata_device *dev = link->device;
> struct ata_queued_cmd *qc;
> - struct ata_taskfile tf;
> + struct ata_taskfile uninitialized_var(tf);
> int tag, rc;
NAK - the warning reflects an actual bug.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] drivers/ata/libata-eh.c: fix unused variable warning
2010-04-22 1:23 ` Fang Wenqi
@ 2010-04-23 6:30 ` Tejun Heo
2010-04-23 6:43 ` Jeff Garzik
2010-04-23 6:48 ` Fang Wenqi
0 siblings, 2 replies; 13+ messages in thread
From: Tejun Heo @ 2010-04-23 6:30 UTC (permalink / raw)
To: Fang Wenqi; +Cc: jgarzik, linux-ide, Alan Cox, antonf
On 04/22/2010 03:23 AM, Fang Wenqi wrote:
> Sorry that the title should be:
> "fix uninitialized variable warning"
>
> not
> "fix unused variable warning"
>
> Need I re-send the patch mail ?
Yes, please do so. gcc 4.4.1 generates a spurious warning on it too.
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] drivers/ata/libata-eh.c: fix unused variable warning
2010-04-23 6:30 ` Tejun Heo
@ 2010-04-23 6:43 ` Jeff Garzik
2010-04-23 7:01 ` Tejun Heo
2010-04-23 6:48 ` Fang Wenqi
1 sibling, 1 reply; 13+ messages in thread
From: Jeff Garzik @ 2010-04-23 6:43 UTC (permalink / raw)
To: Tejun Heo; +Cc: Fang Wenqi, linux-ide, Alan Cox, antonf
On Fri, Apr 23, 2010 at 08:30:28AM +0200, Tejun Heo wrote:
> On 04/22/2010 03:23 AM, Fang Wenqi wrote:
> > Sorry that the title should be:
> > "fix uninitialized variable warning"
> >
> > not
> > "fix unused variable warning"
> >
> > Need I re-send the patch mail ?
>
> Yes, please do so. gcc 4.4.1 generates a spurious warning on it too.
>
> Acked-by: Tejun Heo <tj@kernel.org>
It's not a spurious warning. The code failed to fully initialize all
fields of the ata_taskfile structure, prior to copying the ata_taskfile
structure into qc->result_tf.
Jeff
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] drivers/ata/libata-eh.c: fix unused variable warning
2010-04-23 6:30 ` Tejun Heo
2010-04-23 6:43 ` Jeff Garzik
@ 2010-04-23 6:48 ` Fang Wenqi
1 sibling, 0 replies; 13+ messages in thread
From: Fang Wenqi @ 2010-04-23 6:48 UTC (permalink / raw)
To: Tejun Heo; +Cc: Fang Wenqi, jgarzik, linux-ide, Alan Cox
On 04/23/2010 02:30 PM, Tejun Heo wrote:
> On 04/22/2010 03:23 AM, Fang Wenqi wrote:
>> Sorry that the title should be:
>> "fix uninitialized variable warning"
>>
>> not
>> "fix unused variable warning"
>>
>> Need I re-send the patch mail ?
>
> Yes, please do so. gcc 4.4.1 generates a spurious warning on it too.
The same warning message as I met ?
>
> Acked-by: Tejun Heo<tj@kernel.org>
>
> Thanks.
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] drivers/ata/libata-eh.c: fix unused variable warning
2010-04-23 6:43 ` Jeff Garzik
@ 2010-04-23 7:01 ` Tejun Heo
2010-04-23 13:52 ` Jeff Garzik
0 siblings, 1 reply; 13+ messages in thread
From: Tejun Heo @ 2010-04-23 7:01 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Fang Wenqi, linux-ide, Alan Cox, antonf
Hello, Jeff.
On 04/23/2010 08:43 AM, Jeff Garzik wrote:
> On Fri, Apr 23, 2010 at 08:30:28AM +0200, Tejun Heo wrote:
>> On 04/22/2010 03:23 AM, Fang Wenqi wrote:
>>> Sorry that the title should be:
>>> "fix uninitialized variable warning"
>>>
>>> not
>>> "fix unused variable warning"
>>>
>>> Need I re-send the patch mail ?
>>
>> Yes, please do so. gcc 4.4.1 generates a spurious warning on it too.
>>
>> Acked-by: Tejun Heo <tj@kernel.org>
>
> It's not a spurious warning. The code failed to fully initialize all
> fields of the ata_taskfile structure, prior to copying the ata_taskfile
> structure into qc->result_tf.
Hmmmm.... right, I've always thought it was gcc not noticing the
structure is being initialized in ata_eh_read_log_10h() but it
actually is noticing much more, so something like the following is
more appropriate?
Subject: libata: fully initialize @tf in ata_eh_read_log_10h()
ata_eh_read_log_10h() filled @tf only partially. It didn't cause any
correctness issues but triggered spruious uninitialized variable
warning. Do ata_tf_init() before filling in @tf.
Signed-off-by: Tejun Heo <tj@kernel.org>
---
drivers/ata/libata-eh.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 9f6cfac..fa7e902 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -1434,6 +1434,7 @@ static int ata_eh_read_log_10h(struct ata_device *dev,
*tag = buf[0] & 0x1f;
+ ata_tf_init(dev, tf);
tf->command = buf[2];
tf->feature = buf[3];
tf->lbal = buf[4];
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] drivers/ata/libata-eh.c: fix unused variable warning
2010-04-23 7:01 ` Tejun Heo
@ 2010-04-23 13:52 ` Jeff Garzik
2010-04-23 14:02 ` Tejun Heo
2010-04-23 14:07 ` Sergei Shtylyov
0 siblings, 2 replies; 13+ messages in thread
From: Jeff Garzik @ 2010-04-23 13:52 UTC (permalink / raw)
To: Tejun Heo; +Cc: Jeff Garzik, Fang Wenqi, linux-ide, Alan Cox, antonf
On 04/23/2010 03:01 AM, Tejun Heo wrote:
> Hello, Jeff.
>
> On 04/23/2010 08:43 AM, Jeff Garzik wrote:
>> On Fri, Apr 23, 2010 at 08:30:28AM +0200, Tejun Heo wrote:
>>> On 04/22/2010 03:23 AM, Fang Wenqi wrote:
>>>> Sorry that the title should be:
>>>> "fix uninitialized variable warning"
>>>>
>>>> not
>>>> "fix unused variable warning"
>>>>
>>>> Need I re-send the patch mail ?
>>>
>>> Yes, please do so. gcc 4.4.1 generates a spurious warning on it too.
>>>
>>> Acked-by: Tejun Heo<tj@kernel.org>
>>
>> It's not a spurious warning. The code failed to fully initialize all
>> fields of the ata_taskfile structure, prior to copying the ata_taskfile
>> structure into qc->result_tf.
>
> Hmmmm.... right, I've always thought it was gcc not noticing the
> structure is being initialized in ata_eh_read_log_10h() but it
> actually is noticing much more, so something like the following is
> more appropriate?
>
> Subject: libata: fully initialize @tf in ata_eh_read_log_10h()
>
> ata_eh_read_log_10h() filled @tf only partially. It didn't cause any
> correctness issues but triggered spruious uninitialized variable
> warning. Do ata_tf_init() before filling in @tf.
>
> Signed-off-by: Tejun Heo<tj@kernel.org>
Sorry, I should have also pointed out that a fix went upstream to Linus
in the last batch of fixes...
Jeff
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] drivers/ata/libata-eh.c: fix unused variable warning
2010-04-23 13:52 ` Jeff Garzik
@ 2010-04-23 14:02 ` Tejun Heo
2010-04-23 14:07 ` Sergei Shtylyov
1 sibling, 0 replies; 13+ messages in thread
From: Tejun Heo @ 2010-04-23 14:02 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Jeff Garzik, Fang Wenqi, linux-ide, Alan Cox, antonf
On 04/23/2010 03:52 PM, Jeff Garzik wrote:
> Sorry, I should have also pointed out that a fix went upstream to Linus
> in the last batch of fixes...
Oh, as long as the annoying warning goes away, there's nothing to be
sorry about. :-)
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] drivers/ata/libata-eh.c: fix unused variable warning
2010-04-23 13:52 ` Jeff Garzik
2010-04-23 14:02 ` Tejun Heo
@ 2010-04-23 14:07 ` Sergei Shtylyov
2010-04-23 14:18 ` Jeff Garzik
1 sibling, 1 reply; 13+ messages in thread
From: Sergei Shtylyov @ 2010-04-23 14:07 UTC (permalink / raw)
To: Jeff Garzik
Cc: Tejun Heo, Jeff Garzik, Fang Wenqi, linux-ide, Alan Cox, antonf
Hello.
Jeff Garzik wrote:
>>>>> Sorry that the title should be:
>>>>> "fix uninitialized variable warning"
>>>>>
>>>>> not
>>>>> "fix unused variable warning"
>>>>>
>>>>> Need I re-send the patch mail ?
>>>>
>>>> Yes, please do so. gcc 4.4.1 generates a spurious warning on it too.
>>>>
>>>> Acked-by: Tejun Heo<tj@kernel.org>
>>>
>>> It's not a spurious warning. The code failed to fully initialize all
>>> fields of the ata_taskfile structure, prior to copying the ata_taskfile
>>> structure into qc->result_tf.
>>
>> Hmmmm.... right, I've always thought it was gcc not noticing the
>> structure is being initialized in ata_eh_read_log_10h() but it
>> actually is noticing much more, so something like the following is
>> more appropriate?
>>
>> Subject: libata: fully initialize @tf in ata_eh_read_log_10h()
>>
>> ata_eh_read_log_10h() filled @tf only partially. It didn't cause any
>> correctness issues but triggered spruious uninitialized variable
>> warning. Do ata_tf_init() before filling in @tf.
>>
>> Signed-off-by: Tejun Heo<tj@kernel.org>
>
> Sorry, I should have also pointed out that a fix went upstream to
> Linus in the last batch of fixes...
I thought Tejun was fixing a different function, no?
> Jeff
MBR, Sergei
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] drivers/ata/libata-eh.c: fix unused variable warning
2010-04-23 14:07 ` Sergei Shtylyov
@ 2010-04-23 14:18 ` Jeff Garzik
0 siblings, 0 replies; 13+ messages in thread
From: Jeff Garzik @ 2010-04-23 14:18 UTC (permalink / raw)
To: Sergei Shtylyov
Cc: Tejun Heo, Jeff Garzik, Fang Wenqi, linux-ide, Alan Cox, antonf
On 04/23/2010 10:07 AM, Sergei Shtylyov wrote:
> Hello.
>
> Jeff Garzik wrote:
>
>>>>>> Sorry that the title should be:
>>>>>> "fix uninitialized variable warning"
>>>>>>
>>>>>> not
>>>>>> "fix unused variable warning"
>>>>>>
>>>>>> Need I re-send the patch mail ?
>>>>>
>>>>> Yes, please do so. gcc 4.4.1 generates a spurious warning on it too.
>>>>>
>>>>> Acked-by: Tejun Heo<tj@kernel.org>
>>>>
>>>> It's not a spurious warning. The code failed to fully initialize all
>>>> fields of the ata_taskfile structure, prior to copying the ata_taskfile
>>>> structure into qc->result_tf.
>>>
>>> Hmmmm.... right, I've always thought it was gcc not noticing the
>>> structure is being initialized in ata_eh_read_log_10h() but it
>>> actually is noticing much more, so something like the following is
>>> more appropriate?
>>>
>>> Subject: libata: fully initialize @tf in ata_eh_read_log_10h()
>>>
>>> ata_eh_read_log_10h() filled @tf only partially. It didn't cause any
>>> correctness issues but triggered spruious uninitialized variable
>>> warning. Do ata_tf_init() before filling in @tf.
>>>
>>> Signed-off-by: Tejun Heo<tj@kernel.org>
>>
>> Sorry, I should have also pointed out that a fix went upstream to
>> Linus in the last batch of fixes...
>
> I thought Tejun was fixing a different function, no?
Tejun put the fix in the callee; I put the fix in the caller, who
instantiated the automatic variable. Either way, the same region of
memory gets initialized.
Jeff
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2010-04-23 14:18 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-21 14:07 [PATCH] drivers/ata/libata-eh.c: fix unused variable warning Fang Wenqi
2010-04-21 14:24 ` Alan Cox
2010-04-21 14:57 ` Fang Wenqi
2010-04-22 1:23 ` Fang Wenqi
2010-04-23 6:30 ` Tejun Heo
2010-04-23 6:43 ` Jeff Garzik
2010-04-23 7:01 ` Tejun Heo
2010-04-23 13:52 ` Jeff Garzik
2010-04-23 14:02 ` Tejun Heo
2010-04-23 14:07 ` Sergei Shtylyov
2010-04-23 14:18 ` Jeff Garzik
2010-04-23 6:48 ` Fang Wenqi
2010-04-23 1:54 ` Jeff Garzik
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.