2007-02-20 20:02:39

by Michael Büsch

[permalink] [raw]
Subject: [PATCH] rt2x00: Fix max_rssi values signedness bug

char is not signed on all architectures.
This fixes a compiletime warning and bug on PPC.

Signed-off-by: Michael Buesch <[email protected]>


Index: bu3sch-wireless-dev/drivers/net/wireless/d80211/rt2x00/rt2500pci.c
===================================================================
--- bu3sch-wireless-dev.orig/drivers/net/wireless/d80211/rt2x00/rt2500pci.c 2007-02-20 20:35:17.000000000 +0100
+++ bu3sch-wireless-dev/drivers/net/wireless/d80211/rt2x00/rt2500pci.c 2007-02-20 20:58:50.000000000 +0100
@@ -2630,7 +2630,7 @@ static int rt2500pci_init_eeprom(struct
rt2x00_eeprom_read(rt2x00dev, EEPROM_CALIBRATE_OFFSET, &eeprom);
rt2x00dev->hw->max_rssi =
rt2x00_get_field16(eeprom, EEPROM_CALIBRATE_OFFSET_RSSI);
- if (rt2x00dev->hw->max_rssi == 0x00 || rt2x00dev->hw->max_rssi == (char)0xff)
+ if (rt2x00dev->hw->max_rssi == 0x00 || rt2x00dev->hw->max_rssi == (s8)0xff)
rt2x00dev->hw->max_rssi = MAX_RX_SSI;
rt2x00dev->hw->max_noise = -110;

Index: bu3sch-wireless-dev/drivers/net/wireless/d80211/rt2x00/rt2500usb.c
===================================================================
--- bu3sch-wireless-dev.orig/drivers/net/wireless/d80211/rt2x00/rt2500usb.c 2007-02-20 20:54:20.000000000 +0100
+++ bu3sch-wireless-dev/drivers/net/wireless/d80211/rt2x00/rt2500usb.c 2007-02-20 20:59:23.000000000 +0100
@@ -2474,7 +2474,7 @@ static int rt2500usb_init_eeprom(struct
rt2x00_eeprom_read(rt2x00dev, EEPROM_CALIBRATE_OFFSET, &eeprom);
rt2x00dev->hw->max_rssi =
rt2x00_get_field16(eeprom, EEPROM_CALIBRATE_OFFSET_RSSI);
- if (rt2x00dev->hw->max_rssi == 0x00 || rt2x00dev->hw->max_rssi == (char)0xff)
+ if (rt2x00dev->hw->max_rssi == 0x00 || rt2x00dev->hw->max_rssi == (s8)0xff)
rt2x00dev->hw->max_rssi = MAX_RX_SSI;
rt2x00dev->hw->max_noise = -110;


--
Greetings Michael.


2007-02-21 01:25:51

by Michael Wu

[permalink] [raw]
Subject: Re: [PATCH] rt2x00: Fix max_rssi values signedness bug

On Tuesday 20 February 2007 20:18, Pavel Roskin wrote:
> > /* Maximum values for various statistics.
> > * Leave at 0 to indicate no support. Use negative numbers for dBm. */
> > char max_rssi;
> > char max_signal;
> > char max_noise;
>
> So, there will be no dBm on PowerPC. I think those fields should be
> "signed char".
Like in the patch Michael Buesch posted right before this one?

-Michael Wu


Attachments:
(No filename) (402.00 B)
(No filename) (189.00 B)
Download all attachments

2007-02-21 01:18:56

by Pavel Roskin

[permalink] [raw]
Subject: Re: [PATCH] rt2x00: Fix max_rssi values signedness bug

On Tue, 2007-02-20 at 21:02 +0100, Michael Buesch wrote:
> char is not signed on all architectures.
> This fixes a compiletime warning and bug on PPC.

Then we have a bigger problem. Please see include/net/d80211.h:

> /* Maximum values for various statistics.
> * Leave at 0 to indicate no support. Use negative numbers for dBm. */
> char max_rssi;
> char max_signal;
> char max_noise;

So, there will be no dBm on PowerPC. I think those fields should be
"signed char".

--
Regards,
Pavel Roskin


2007-02-21 01:48:03

by Pavel Roskin

[permalink] [raw]
Subject: Re: [PATCH] rt2x00: Fix max_rssi values signedness bug

On Tue, 2007-02-20 at 20:25 -0500, Michael Wu wrote:
> On Tuesday 20 February 2007 20:18, Pavel Roskin wrote:
> > So, there will be no dBm on PowerPC. I think those fields should be
> > "signed char".
> Like in the patch Michael Buesch posted right before this one?

Yes. Sorry for the noise.

--
Regards,
Pavel Roskin