Skip to contentSkip to conversation

rt2x00: Fix max_rssi values signedness bug

PATCH In review Michael Buesch 3 participants 4 messages Feb 20, 2007 – Feb 21, 2007 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rt2x00: Fix max_rssi values signedness bug

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

drivers/net/wireless/d80211/rt2x00/rt2500pci.c +1 -1
Index: bu3sch-wireless-dev/drivers/net/wireless/d80211/rt2x00/rt2500pci.c
===================================================================
@@ -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;
 
drivers/net/wireless/d80211/rt2x00/rt2500usb.c +1 -1
Index: bu3sch-wireless-dev/drivers/net/wireless/d80211/rt2x00/rt2500usb.c
===================================================================
@@ -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;
 
Signature · 1 line
Greetings Michael.
#1 lore raw
Quoted 2 lines · Michael Buesch

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:

Quoted 5 lines

/* 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".

Signature · 2 lines
Regards,
Pavel Roskin
#2 lore raw
Quoted 8 lines · Pavel Roskin
Quoted 5 lines

/* 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

#3 lore raw
Quoted 4 lines · Michael Wu
Quoted 2 lines · Pavel Roskin

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.

Signature · 2 lines
Regards,
Pavel Roskin