2021-04-09 13:58:44

by angkery

[permalink] [raw]
Subject: [PATCH] pata_ipx4xx_cf: Fix unsigned comparison with less than zero

From: Junlin Yang <[email protected]>

The return from the call to platform_get_irq() is int, it can be
a negative error code, however this is being assigned to an unsigned
int variable 'irq', so making 'irq' an int, and change the position to
keep the code format.

./drivers/ata/pata_ixp4xx_cf.c:168:5-8:
WARNING: Unsigned expression compared with zero: irq > 0

Signed-off-by: Junlin Yang <[email protected]>
---
drivers/ata/pata_ixp4xx_cf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
index abc0e87..43215a4 100644
--- a/drivers/ata/pata_ixp4xx_cf.c
+++ b/drivers/ata/pata_ixp4xx_cf.c
@@ -135,12 +135,12 @@ static void ixp4xx_setup_port(struct ata_port *ap,

static int ixp4xx_pata_probe(struct platform_device *pdev)
{
- unsigned int irq;
struct resource *cs0, *cs1;
struct ata_host *host;
struct ata_port *ap;
struct ixp4xx_pata_data *data = dev_get_platdata(&pdev->dev);
int ret;
+ int irq;

cs0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
cs1 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
--
1.9.1



2021-04-09 14:04:05

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH] pata_ipx4xx_cf: Fix unsigned comparison with less than zero

On 4/9/21 7:54 AM, angkery wrote:
> From: Junlin Yang <[email protected]>
>
> The return from the call to platform_get_irq() is int, it can be
> a negative error code, however this is being assigned to an unsigned
> int variable 'irq', so making 'irq' an int, and change the position to
> keep the code format.
>
> ./drivers/ata/pata_ixp4xx_cf.c:168:5-8:
> WARNING: Unsigned expression compared with zero: irq > 0

Applied, thanks.

--
Jens Axboe

2021-04-09 16:50:36

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH] pata_ipx4xx_cf: Fix unsigned comparison with less than zero

On 4/9/21 4:54 PM, angkery wrote:

> From: Junlin Yang <[email protected]>
>
> The return from the call to platform_get_irq() is int, it can be
> a negative error code, however this is being assigned to an unsigned
> int variable 'irq', so making 'irq' an int, and change the position to
> keep the code format.
>
> ./drivers/ata/pata_ixp4xx_cf.c:168:5-8:
> WARNING: Unsigned expression compared with zero: irq > 0

I'd understand < 0... but > 0? What tool warned about this issue?

> Signed-off-by: Junlin Yang <[email protected]>
> ---
> drivers/ata/pata_ixp4xx_cf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
> index abc0e87..43215a4 100644
> --- a/drivers/ata/pata_ixp4xx_cf.c
> +++ b/drivers/ata/pata_ixp4xx_cf.c
> @@ -135,12 +135,12 @@ static void ixp4xx_setup_port(struct ata_port *ap,
>
> static int ixp4xx_pata_probe(struct platform_device *pdev)
> {
> - unsigned int irq;

Oops, not sure how I missed that. :-/
Thanks for fixing my overlook. :-)

[...]

MBR, Sergei

2021-04-09 17:04:53

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH] pata_ipx4xx_cf: Fix unsigned comparison with less than zero

On 4/9/21 7:49 PM, Sergei Shtylyov wrote:

>> From: Junlin Yang <[email protected]>
>>
>> The return from the call to platform_get_irq() is int, it can be
>> a negative error code, however this is being assigned to an unsigned
>> int variable 'irq', so making 'irq' an int, and change the position to
>> keep the code format.
>>
>> ./drivers/ata/pata_ixp4xx_cf.c:168:5-8:
>> WARNING: Unsigned expression compared with zero: irq > 0
>
> I'd understand < 0... but > 0? What tool warned about this issue?
>
>> Signed-off-by: Junlin Yang <[email protected]>
>> ---
>> drivers/ata/pata_ixp4xx_cf.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
>> index abc0e87..43215a4 100644
>> --- a/drivers/ata/pata_ixp4xx_cf.c
>> +++ b/drivers/ata/pata_ixp4xx_cf.c
>> @@ -135,12 +135,12 @@ static void ixp4xx_setup_port(struct ata_port *ap,
>>
>> static int ixp4xx_pata_probe(struct platform_device *pdev)
>> {
>> - unsigned int irq;
>
> Oops, not sure how I missed that. :-/
> Thanks for fixing my overlook. :-)

Forgot to add my

Reviewed-by: Sergei Shtylyov <[email protected]>

> [...]

MBR, Sergei

2021-04-09 23:41:52

by angkery

[permalink] [raw]
Subject: Re: [PATCH] pata_ipx4xx_cf: Fix unsigned comparison with less than zero

On Fri, 9 Apr 2021 20:02:56 +0300
Sergei Shtylyov <[email protected]> wrote:

> On 4/9/21 7:49 PM, Sergei Shtylyov wrote:
>
> >> From: Junlin Yang <[email protected]>
> >>
> >> The return from the call to platform_get_irq() is int, it can be
> >> a negative error code, however this is being assigned to an
> >> unsigned int variable 'irq', so making 'irq' an int, and change
> >> the position to keep the code format.
> >>
> >> ./drivers/ata/pata_ixp4xx_cf.c:168:5-8:
> >> WARNING: Unsigned expression compared with zero: irq > 0
> >
> > I'd understand < 0... but > 0? What tool warned about this issue?
> >
> > > yes, by coccicheck, i will update commits information.
> >
> >> Signed-off-by: Junlin Yang <[email protected]>
> >> ---
> >> drivers/ata/pata_ixp4xx_cf.c | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/ata/pata_ixp4xx_cf.c
> >> b/drivers/ata/pata_ixp4xx_cf.c index abc0e87..43215a4 100644
> >> --- a/drivers/ata/pata_ixp4xx_cf.c
> >> +++ b/drivers/ata/pata_ixp4xx_cf.c
> >> @@ -135,12 +135,12 @@ static void ixp4xx_setup_port(struct
> >> ata_port *ap,
> >> static int ixp4xx_pata_probe(struct platform_device *pdev)
> >> {
> >> - unsigned int irq;
> >
> > Oops, not sure how I missed that. :-/
> > Thanks for fixing my overlook. :-)
>
> Forgot to add my
>
> Reviewed-by: Sergei Shtylyov <[email protected]>
>
> > [...]
>
> MBR, Sergei


2021-04-10 08:47:45

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH] pata_ipx4xx_cf: Fix unsigned comparison with less than zero

On 10.04.2021 2:38, angkery wrote:
> On Fri, 9 Apr 2021 20:02:56 +0300
> Sergei Shtylyov <[email protected]> wrote:
>
>> On 4/9/21 7:49 PM, Sergei Shtylyov wrote:
>>
>>>> From: Junlin Yang <[email protected]>
>>>>
>>>> The return from the call to platform_get_irq() is int, it can be
>>>> a negative error code, however this is being assigned to an
>>>> unsigned int variable 'irq', so making 'irq' an int, and change
>>>> the position to keep the code format.
>>>>
>>>> ./drivers/ata/pata_ixp4xx_cf.c:168:5-8:
>>>> WARNING: Unsigned expression compared with zero: irq > 0
>>>
>>> I'd understand < 0... but > 0? What tool warned about this issue?
>>>
>>>> yes, by coccicheck, i will update commits information.

Thanks!
Yet, looking at your subject, the above should read irq < 0, not > 0.

>>>> Signed-off-by: Junlin Yang <[email protected]>