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

login
register
mail settings
Submitter Tejun Heo
Date April 23, 2010, 7:01 a.m.
Message ID <4BD145B0.8080102@kernel.org>
Download mbox | patch
Permalink /patch/50791/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Tejun Heo - April 23, 2010, 7:01 a.m.
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(+)

--
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:52 p.m.
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




--
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, 2:02 p.m.
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.
Sergei Shtylyov - April 23, 2010, 2:07 p.m.
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

--
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, 2:18 p.m.
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



--
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..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];