2011-08-18 13:40:21

by Dan Carpenter

[permalink] [raw]
Subject: [patch -next] bcma: signedness bug in bcma_get_next_core()

The u32 would never be less than zero so the error handling would
break. I changed it to int.

Signed-off-by: Dan Carpenter <[email protected]>

diff --git a/drivers/bcma/scan.c b/drivers/bcma/scan.c
index 0ea390f..1361d8d 100644
--- a/drivers/bcma/scan.c
+++ b/drivers/bcma/scan.c
@@ -281,7 +281,7 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,

/* get & parse master ports */
for (i = 0; i < ports[0]; i++) {
- u32 mst_port_d = bcma_erom_get_mst_port(bus, eromptr);
+ int mst_port_d = bcma_erom_get_mst_port(bus, eromptr);
if (mst_port_d < 0)
return -EILSEQ;
}


2011-08-20 12:23:57

by Rafał Miłecki

[permalink] [raw]
Subject: Re: [patch -next] bcma: signedness bug in bcma_get_next_core()

W dniu 18 sierpnia 2011 15:38 użytkownik Dan Carpenter
<[email protected]> napisał:
> The u32 would never be less than zero so the error handling would
> break.  I changed it to int.

In declaration we use s32:
static s32 bcma_erom_get_mst_port(struct bcma_bus *bus, u32 **eromptr);

Doesn't it sound better to use s32 instead of int?

--
Rafał

2011-08-20 13:31:54

by Rafał Miłecki

[permalink] [raw]
Subject: Re: [patch -next] bcma: signedness bug in bcma_get_next_core()

W dniu 20 sierpnia 2011 14:59 użytkownik walter harms <[email protected]> napisał:
>
>
> Am 20.08.2011 14:23, schrieb Rafał Miłecki:
>> W dniu 18 sierpnia 2011 15:38 użytkownik Dan Carpenter
>> <[email protected]> napisał:
>>> The u32 would never be less than zero so the error handling would
>>> break.  I changed it to int.
>>
>> In declaration we use s32:
>> static s32 bcma_erom_get_mst_port(struct bcma_bus *bus, u32 **eromptr);
>>
>> Doesn't it sound better to use s32 instead of int?
>>
>
> aktualy int sounds better that s32 for me.

Will you care to replace function return type as well?

--
Rafał

2011-08-24 10:01:12

by Rafał Miłecki

[permalink] [raw]
Subject: Re: [patch -next] bcma: signedness bug in bcma_get_next_core()

W dniu 23 sierpnia 2011 21:13 użytkownik Dan Carpenter
<[email protected]> napisał:
> On Sat, Aug 20, 2011 at 02:23:56PM +0200, Rafał Miłecki wrote:
>> W dniu 18 sierpnia 2011 15:38 użytkownik Dan Carpenter
>> <[email protected]> napisał:
>> > The u32 would never be less than zero so the error handling would
>> > break.  I changed it to int.
>>
>> In declaration we use s32:
>> static s32 bcma_erom_get_mst_port(struct bcma_bus *bus, u32 **eromptr);
>>
>> Doesn't it sound better to use s32 instead of int?
>>
>
> I don't know.  I think I'm going to trust the original author on this
> one.  I'll send you a v2 that uses s32.

Dan, I asked you to use int in both: call and function declaration.
I'm the author of that code, and I don't have anything against
modifying that :)

I think int is used much more often that s32 for errors.

--
Rafał

2011-08-24 10:20:50

by Dan Carpenter

[permalink] [raw]
Subject: Re: [patch -next] bcma: signedness bug in bcma_get_next_core()

On Wed, Aug 24, 2011 at 12:01:11PM +0200, Rafał Miłecki wrote:
> Dan, I asked you to use int in both: call and function declaration.
> I'm the author of that code, and I don't have anything against
> modifying that :)
>
> I think int is used much more often that s32 for errors.
>

No problem. Should I make bcma_erom_get_mst_port() return 0 on
success while I'm at it?

regards,
dan carpenter


2011-08-23 19:17:57

by Dan Carpenter

[permalink] [raw]
Subject: [patch -next v2] bcma: signedness bug in bcma_get_next_core()

The u32 would never be less than zero so the error handling would
break. I changed it to s32 to match how bcma_erom_get_mst_port() is
declared.

Signed-off-by: Dan Carpenter <[email protected]>
---
v2: the first version used "int" instead of "s32".

diff --git a/drivers/bcma/scan.c b/drivers/bcma/scan.c
index 0ea390f..cad9948 100644
--- a/drivers/bcma/scan.c
+++ b/drivers/bcma/scan.c
@@ -281,7 +281,7 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,

/* get & parse master ports */
for (i = 0; i < ports[0]; i++) {
- u32 mst_port_d = bcma_erom_get_mst_port(bus, eromptr);
+ s32 mst_port_d = bcma_erom_get_mst_port(bus, eromptr);
if (mst_port_d < 0)
return -EILSEQ;
}

2011-08-20 12:59:39

by walter harms

[permalink] [raw]
Subject: Re: [patch -next] bcma: signedness bug in bcma_get_next_core()



Am 20.08.2011 14:23, schrieb Rafał Miłecki:
> W dniu 18 sierpnia 2011 15:38 użytkownik Dan Carpenter
> <[email protected]> napisał:
>> The u32 would never be less than zero so the error handling would
>> break. I changed it to int.
>
> In declaration we use s32:
> static s32 bcma_erom_get_mst_port(struct bcma_bus *bus, u32 **eromptr);
>
> Doesn't it sound better to use s32 instead of int?
>

aktualy int sounds better that s32 for me.

re,
wh

2011-08-23 19:15:39

by Dan Carpenter

[permalink] [raw]
Subject: Re: [patch -next] bcma: signedness bug in bcma_get_next_core()

On Sat, Aug 20, 2011 at 02:23:56PM +0200, Rafał Miłecki wrote:
> W dniu 18 sierpnia 2011 15:38 użytkownik Dan Carpenter
> <[email protected]> napisał:
> > The u32 would never be less than zero so the error handling would
> > break.  I changed it to int.
>
> In declaration we use s32:
> static s32 bcma_erom_get_mst_port(struct bcma_bus *bus, u32 **eromptr);
>
> Doesn't it sound better to use s32 instead of int?
>

I don't know. I think I'm going to trust the original author on this
one. I'll send you a v2 that uses s32.

regards,
dan carpenter