diff mbox series

ata: pata_cs5535: Fix W=1 warnings

Message ID 1656335540-50293-1-git-send-email-john.garry@huawei.com
State New
Headers show
Series ata: pata_cs5535: Fix W=1 warnings | expand

Commit Message

John Garry June 27, 2022, 1:12 p.m. UTC
x86_64 allmodconfig build with W=1 gives these warnings:

drivers/ata/pata_cs5535.c: In function ‘cs5535_set_piomode’:
drivers/ata/pata_cs5535.c:93:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
  u32 reg, dummy;
           ^~~~~
drivers/ata/pata_cs5535.c: In function ‘cs5535_set_dmamode’:
drivers/ata/pata_cs5535.c:132:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
  u32 reg, dummy;
           ^~~~~
cc1: all warnings being treated as errors

Mark variables 'dummy' as "maybe unused" to satisfy when rdmsr() is
stubbed, which is the same as what we already do in pata_cs5536.c .

Signed-off-by: John Garry <john.garry@huawei.com>

Comments

Damien Le Moal June 28, 2022, 8:59 a.m. UTC | #1
On 6/27/22 22:12, John Garry wrote:
> x86_64 allmodconfig build with W=1 gives these warnings:
> 
> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_piomode’:
> drivers/ata/pata_cs5535.c:93:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>   u32 reg, dummy;
>            ^~~~~
> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_dmamode’:
> drivers/ata/pata_cs5535.c:132:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>   u32 reg, dummy;
>            ^~~~~
> cc1: all warnings being treated as errors
> 
> Mark variables 'dummy' as "maybe unused" to satisfy when rdmsr() is
> stubbed, which is the same as what we already do in pata_cs5536.c .
> 
> Signed-off-by: John Garry <john.garry@huawei.com>

Looks good, but I wonder why I am not getting this warning. I always do
W=1 and C=1 builds. I tried allmodconfig now and I am not getting the
warning...

> 
> diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c
> index 6725931f3c35..c2c3238ff84b 100644
> --- a/drivers/ata/pata_cs5535.c
> +++ b/drivers/ata/pata_cs5535.c
> @@ -90,7 +90,7 @@ static void cs5535_set_piomode(struct ata_port *ap, struct ata_device *adev)
>  	static const u16 pio_cmd_timings[5] = {
>  		0xF7F4, 0x53F3, 0x13F1, 0x5131, 0x1131
>  	};
> -	u32 reg, dummy;
> +	u32 reg, __maybe_unused dummy;
>  	struct ata_device *pair = ata_dev_pair(adev);
>  
>  	int mode = adev->pio_mode - XFER_PIO_0;
> @@ -129,7 +129,7 @@ static void cs5535_set_dmamode(struct ata_port *ap, struct ata_device *adev)
>  	static const u32 mwdma_timings[3] = {
>  		0x7F0FFFF3, 0x7F035352, 0x7F024241
>  	};
> -	u32 reg, dummy;
> +	u32 reg, __maybe_unused dummy;
>  	int mode = adev->dma_mode;
>  
>  	rdmsr(ATAC_CH0D0_DMA + 2 * adev->devno, reg, dummy);
John Garry June 28, 2022, 9:27 a.m. UTC | #2
On 28/06/2022 09:59, Damien Le Moal wrote:
> On 6/27/22 22:12, John Garry wrote:
>> x86_64 allmodconfig build with W=1 gives these warnings:
>>
>> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_piomode’:
>> drivers/ata/pata_cs5535.c:93:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>>    u32 reg, dummy;
>>             ^~~~~
>> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_dmamode’:
>> drivers/ata/pata_cs5535.c:132:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>>    u32 reg, dummy;
>>             ^~~~~
>> cc1: all warnings being treated as errors
>>
>> Mark variables 'dummy' as "maybe unused" to satisfy when rdmsr() is
>> stubbed, which is the same as what we already do in pata_cs5536.c .
>>
>> Signed-off-by: John Garry <john.garry@huawei.com>
> 
> Looks good, but I wonder why I am not getting this warning. I always do
> W=1 and C=1 builds. I tried allmodconfig now and I am not getting the
> warning...

eh, I'm not sure why. It's the only driver in drivers/ata/ which gives 
such a problem.

I'm using gcc 9:
gcc version 9.3.1 20200406 [revision 
6db837a5288ee3ca5ec504fbd5a765817e556ac2] (SUSE Linux)

Then I cross-compiled from my arm64 machine (to x86) and still got it:
john@ubuntu:~/kernel-dev$ /usr/bin/x86_64-linux-gnu-gcc --version
x86_64-linux-gnu-gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

> 
>>
>> diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c
>> index 6725931f3c35..c2c3238ff84b 100644
>> --- a/drivers/ata/pata_cs5535.c
>> +++ b/drivers/ata/pata_cs5535.c
>> @@ -90,7 +90,7 @@ static void cs5535_set_piomode(struct ata_port *ap, struct ata_device *adev)
>>   	static const u16 pio_cmd_timings[5] = {
>>   		0xF7F4, 0x53F3, 0x13F1, 0x5131, 0x1131
>>   	};
>> -	u32 reg, dummy;
>> +	u32 reg, __maybe_unused dummy;
>>   	struct ata_device *pair = ata_dev_pair(adev);
>>   
>>   	int mode = adev->pio_mode - XFER_PIO_0;
>> @@ -129,7 +129,7 @@ static void cs5535_set_dmamode(struct ata_port *ap, struct ata_device *adev)
>>   	static const u32 mwdma_timings[3] = {
>>   		0x7F0FFFF3, 0x7F035352, 0x7F024241
>>   	};
>> -	u32 reg, dummy;
>> +	u32 reg, __maybe_unused dummy;
>>   	int mode = adev->dma_mode;
>>   
>>   	rdmsr(ATAC_CH0D0_DMA + 2 * adev->devno, reg, dummy);
> 
>
Sergey Shtylyov June 28, 2022, 10:05 a.m. UTC | #3
Hello!

On 6/28/22 11:59 AM, Damien Le Moal wrote:
[...]
>> x86_64 allmodconfig build with W=1 gives these warnings:
>>
>> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_piomode’:
>> drivers/ata/pata_cs5535.c:93:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>>   u32 reg, dummy;
>>            ^~~~~
>> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_dmamode’:
>> drivers/ata/pata_cs5535.c:132:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>>   u32 reg, dummy;
>>            ^~~~~
>> cc1: all warnings being treated as errors
>>
>> Mark variables 'dummy' as "maybe unused" to satisfy when rdmsr() is
>> stubbed, which is the same as what we already do in pata_cs5536.c .
>>
>> Signed-off-by: John Garry <john.garry@huawei.com>


Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>

> Looks good, but I wonder why I am not getting this warning. I always do
> W=1 and C=1 builds. I tried allmodconfig now and I am not getting the
> warning...

   I can confirm the (fatal) warnings with RedHat gcc 10.3.1... but somehow they only
occur on x86_64 with allmodconfig indeed (which is strange)...

[...]

MBR, Sergey
Sergey Shtylyov June 28, 2022, 6:39 p.m. UTC | #4
On 6/28/22 1:05 PM, Sergey Shtylyov wrote:
[...]
>>> x86_64 allmodconfig build with W=1 gives these warnings:
>>>
>>> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_piomode’:
>>> drivers/ata/pata_cs5535.c:93:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>>>   u32 reg, dummy;
>>>            ^~~~~
>>> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_dmamode’:
>>> drivers/ata/pata_cs5535.c:132:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>>>   u32 reg, dummy;
>>>            ^~~~~
>>> cc1: all warnings being treated as errors
>>>
>>> Mark variables 'dummy' as "maybe unused" to satisfy when rdmsr() is
>>> stubbed, which is the same as what we already do in pata_cs5536.c .

   Wait, what do you mean by "stubbed", the version in <asm/paravirt.h>?

>>>
>>> Signed-off-by: John Garry <john.garry@huawei.com>
> 
> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>

[...]

MBR, Sergey
Damien Le Moal June 29, 2022, 1:14 a.m. UTC | #5
On 6/28/22 19:05, Sergey Shtylyov wrote:
> Hello!
> 
> On 6/28/22 11:59 AM, Damien Le Moal wrote:
> [...]
>>> x86_64 allmodconfig build with W=1 gives these warnings:
>>>
>>> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_piomode’:
>>> drivers/ata/pata_cs5535.c:93:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>>>   u32 reg, dummy;
>>>            ^~~~~
>>> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_dmamode’:
>>> drivers/ata/pata_cs5535.c:132:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>>>   u32 reg, dummy;
>>>            ^~~~~
>>> cc1: all warnings being treated as errors
>>>
>>> Mark variables 'dummy' as "maybe unused" to satisfy when rdmsr() is
>>> stubbed, which is the same as what we already do in pata_cs5536.c .
>>>
>>> Signed-off-by: John Garry <john.garry@huawei.com>
> 
> 
> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> 
>> Looks good, but I wonder why I am not getting this warning. I always do
>> W=1 and C=1 builds. I tried allmodconfig now and I am not getting the
>> warning...
> 
>    I can confirm the (fatal) warnings with RedHat gcc 10.3.1... but somehow they only
> occur on x86_64 with allmodconfig indeed (which is strange)...

Compiling on x86_64 with allmodconfig with gcc 12 and sparse-0.6.4-2
(Fedora 36) does not give the warning... Weird.

> 
> [...]
> 
> MBR, Sergey
>
Damien Le Moal June 29, 2022, 1:51 a.m. UTC | #6
On 6/27/22 22:12, John Garry wrote:
> x86_64 allmodconfig build with W=1 gives these warnings:
> 
> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_piomode’:
> drivers/ata/pata_cs5535.c:93:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>   u32 reg, dummy;
>            ^~~~~
> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_dmamode’:
> drivers/ata/pata_cs5535.c:132:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>   u32 reg, dummy;
>            ^~~~~
> cc1: all warnings being treated as errors
> 
> Mark variables 'dummy' as "maybe unused" to satisfy when rdmsr() is
> stubbed, which is the same as what we already do in pata_cs5536.c .
> 
> Signed-off-by: John Garry <john.garry@huawei.com>

Applied to for-5.20. Thanks !

> 
> diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c
> index 6725931f3c35..c2c3238ff84b 100644
> --- a/drivers/ata/pata_cs5535.c
> +++ b/drivers/ata/pata_cs5535.c
> @@ -90,7 +90,7 @@ static void cs5535_set_piomode(struct ata_port *ap, struct ata_device *adev)
>  	static const u16 pio_cmd_timings[5] = {
>  		0xF7F4, 0x53F3, 0x13F1, 0x5131, 0x1131
>  	};
> -	u32 reg, dummy;
> +	u32 reg, __maybe_unused dummy;
>  	struct ata_device *pair = ata_dev_pair(adev);
>  
>  	int mode = adev->pio_mode - XFER_PIO_0;
> @@ -129,7 +129,7 @@ static void cs5535_set_dmamode(struct ata_port *ap, struct ata_device *adev)
>  	static const u32 mwdma_timings[3] = {
>  		0x7F0FFFF3, 0x7F035352, 0x7F024241
>  	};
> -	u32 reg, dummy;
> +	u32 reg, __maybe_unused dummy;
>  	int mode = adev->dma_mode;
>  
>  	rdmsr(ATAC_CH0D0_DMA + 2 * adev->devno, reg, dummy);
John Garry June 29, 2022, 7:41 a.m. UTC | #7
On 28/06/2022 19:39, Sergey Shtylyov wrote:
> On 6/28/22 1:05 PM, Sergey Shtylyov wrote:
> [...]
>>>> x86_64 allmodconfig build with W=1 gives these warnings:
>>>>
>>>> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_piomode’:
>>>> drivers/ata/pata_cs5535.c:93:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>>>>    u32 reg, dummy;
>>>>             ^~~~~
>>>> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_dmamode’:
>>>> drivers/ata/pata_cs5535.c:132:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>>>>    u32 reg, dummy;
>>>>             ^~~~~
>>>> cc1: all warnings being treated as errors
>>>>
>>>> Mark variables 'dummy' as "maybe unused" to satisfy when rdmsr() is
>>>> stubbed, which is the same as what we already do in pata_cs5536.c .
> 
>     Wait, what do you mean by "stubbed", the version in <asm/paravirt.h>?

Ah, this mentioning of stubbed is wrong on my part. I was distracted by 
the stub in pata_cs5536.c - that's what my text editor showed me for the 
defintion of rdmsr()

Hi Damien,

I see that you applied this patch. If it has not been pushed can we hand 
edit the commit message or I can send a v2? Or maybe we can live with it...

Thanks,
John

> 
>>>>
>>>> Signed-off-by: John Garry <john.garry@huawei.com>
>>
>> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> 
> [...]
> 
> MBR, Sergey
> .
Damien Le Moal June 29, 2022, 8:24 a.m. UTC | #8
On 6/29/22 16:41, John Garry wrote:
> On 28/06/2022 19:39, Sergey Shtylyov wrote:
>> On 6/28/22 1:05 PM, Sergey Shtylyov wrote:
>> [...]
>>>>> x86_64 allmodconfig build with W=1 gives these warnings:
>>>>>
>>>>> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_piomode’:
>>>>> drivers/ata/pata_cs5535.c:93:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>>>>>    u32 reg, dummy;
>>>>>             ^~~~~
>>>>> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_dmamode’:
>>>>> drivers/ata/pata_cs5535.c:132:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>>>>>    u32 reg, dummy;
>>>>>             ^~~~~
>>>>> cc1: all warnings being treated as errors
>>>>>
>>>>> Mark variables 'dummy' as "maybe unused" to satisfy when rdmsr() is
>>>>> stubbed, which is the same as what we already do in pata_cs5536.c .
>>
>>     Wait, what do you mean by "stubbed", the version in <asm/paravirt.h>?
> 
> Ah, this mentioning of stubbed is wrong on my part. I was distracted by 
> the stub in pata_cs5536.c - that's what my text editor showed me for the 
> defintion of rdmsr()
> 
> Hi Damien,
> 
> I see that you applied this patch. If it has not been pushed can we hand 
> edit the commit message or I can send a v2? Or maybe we can live with it...

Send me an updated commit message and I will amend.

> 
> Thanks,
> John
> 
>>
>>>>>
>>>>> Signed-off-by: John Garry <john.garry@huawei.com>
>>>
>>> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
>>
>> [...]
>>
>> MBR, Sergey
>> .
>
Sergey Shtylyov June 29, 2022, 1:32 p.m. UTC | #9
On 6/29/22 4:51 AM, Damien Le Moal wrote:

>> x86_64 allmodconfig build with W=1 gives these warnings:
>>
>> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_piomode’:
>> drivers/ata/pata_cs5535.c:93:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>>   u32 reg, dummy;
>>            ^~~~~
>> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_dmamode’:
>> drivers/ata/pata_cs5535.c:132:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>>   u32 reg, dummy;
>>            ^~~~~
>> cc1: all warnings being treated as errors
>>
>> Mark variables 'dummy' as "maybe unused" to satisfy when rdmsr() is
>> stubbed, which is the same as what we already do in pata_cs5536.c .
>>
>> Signed-off-by: John Garry <john.garry@huawei.com>
> 
> Applied to for-5.20. Thanks !

   Why not to 5.19? The warnings are fatal as can be seen from the commit log...

MBR, Sergey
Damien Le Moal June 29, 2022, 11:03 p.m. UTC | #10
On 6/29/22 22:32, Sergey Shtylyov wrote:
> On 6/29/22 4:51 AM, Damien Le Moal wrote:
> 
>>> x86_64 allmodconfig build with W=1 gives these warnings:
>>>
>>> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_piomode’:
>>> drivers/ata/pata_cs5535.c:93:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>>>   u32 reg, dummy;
>>>            ^~~~~
>>> drivers/ata/pata_cs5535.c: In function ‘cs5535_set_dmamode’:
>>> drivers/ata/pata_cs5535.c:132:11: error: variable ‘dummy’ set but not used [-Werror=unused-but-set-variable]
>>>   u32 reg, dummy;
>>>            ^~~~~
>>> cc1: all warnings being treated as errors
>>>
>>> Mark variables 'dummy' as "maybe unused" to satisfy when rdmsr() is
>>> stubbed, which is the same as what we already do in pata_cs5536.c .
>>>
>>> Signed-off-by: John Garry <john.garry@huawei.com>
>>
>> Applied to for-5.20. Thanks !
> 
>    Why not to 5.19? The warnings are fatal as can be seen from the commit log...

This is only a compile warning and nobody complained, not even the 0-day
bot/linux-next builds, and for years... Most definitely not an urgent fix.

But yeah, sure, can do 5.19 fixes too.

> 
> MBR, Sergey
>
diff mbox series

Patch

diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c
index 6725931f3c35..c2c3238ff84b 100644
--- a/drivers/ata/pata_cs5535.c
+++ b/drivers/ata/pata_cs5535.c
@@ -90,7 +90,7 @@  static void cs5535_set_piomode(struct ata_port *ap, struct ata_device *adev)
 	static const u16 pio_cmd_timings[5] = {
 		0xF7F4, 0x53F3, 0x13F1, 0x5131, 0x1131
 	};
-	u32 reg, dummy;
+	u32 reg, __maybe_unused dummy;
 	struct ata_device *pair = ata_dev_pair(adev);
 
 	int mode = adev->pio_mode - XFER_PIO_0;
@@ -129,7 +129,7 @@  static void cs5535_set_dmamode(struct ata_port *ap, struct ata_device *adev)
 	static const u32 mwdma_timings[3] = {
 		0x7F0FFFF3, 0x7F035352, 0x7F024241
 	};
-	u32 reg, dummy;
+	u32 reg, __maybe_unused dummy;
 	int mode = adev->dma_mode;
 
 	rdmsr(ATAC_CH0D0_DMA + 2 * adev->devno, reg, dummy);