Patchwork drivers/ata/libata-eh.c: fix unused variable warning

login
register
mail settings
Submitter Fang Wenqi
Date April 21, 2010, 2:07 p.m.
Message ID <1271858846-1706-1-git-send-email-antonf@turbolinux.com.cn>
Download mbox | patch
Permalink /patch/50659/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Fang Wenqi - April 21, 2010, 2:07 p.m.
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(-)
Alan Cox - April 21, 2010, 2:24 p.m.
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 ?
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Fang Wenqi - April 21, 2010, 2:57 p.m.
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 ?
>

--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Fang Wenqi - April 22, 2010, 1:23 a.m.
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 ?
>>
>

--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jeff Garzik - April 23, 2010, 1:54 a.m.
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.


--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tejun Heo - April 23, 2010, 6:30 a.m.
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.
Jeff Garzik - April 23, 2010, 6:43 a.m.
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



--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Fang Wenqi - April 23, 2010, 6:48 a.m.
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.
>
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

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 */