staging: rtl8723bs: cast EEPROM_DEFAULT_DIFF to s8
PATCH 1/1 staging: rtl8723bs: cast EEPROM_DEFAULT_DIFF to s8
EEPROM_DEFAULT_DIFF is defined as the bare integer literal 0xFE
(254) but is only ever assigned into s8 (signed char) fields used to store signed TX power calibration offsets. The implicit truncation to -2 is intentional. BW20/BW40/CCK/OFDM_Diff fields elsewhere in the same file already sign-extend 4-bit values into 8-bit signed offsets by hand, so -2 is consistent with that existing pattern but the untyped macro doesn't communicate this, and triggers -Wconversion at every one of its 8 use sites in rtl8723b_hal_init.c.
Cast the macro to s8 at its definition so the sign truncation is explicit and documented in one place instead of relying on implicit conversion at each call site.
No functional change.
--- drivers/staging/rtl8723bs/include/hal_pg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/include/hal_pg.h +1 -1
@@ -40,7 +40,7 @@#define EEPROM_RF_BT_SETTING_8723B 0xC3#define EEPROM_VERSION_8723B 0xC4#define EEPROM_CustomID_8723B 0xC5 -#define EEPROM_DEFAULT_DIFF 0XFE +#define EEPROM_DEFAULT_DIFF ((s8)0XFE)/* RTL8723BS */ #define EEPROM_MAC_ADDR_8723BS 0x11A
Signature · 1 line
2.55.0
Quoted 4 lines · Ivy Lopez
EEPROM_DEFAULT_DIFFis defined as the bare integer literal0xFE
(254) but is only ever assigned into s8 (signed char) fields used to store signed TX power calibration offsets. The implicit truncation to -2 is intentional.
Just change it to:
#define EEPROM_DEFAULT_DIFF -2
regards,
dan carpenter
PATCH v2 1/1 staging: rtl8723bs: define EEPROM_DEFAULT_DIFF as -2 directly
In reply to Ivy LopezEEPROM_DEFAULT_DIFF is defined as the bare integer literal 0xFE
(254) but is only ever assigned into s8 (signed char) fields used to store signed TX power calibration offsets. The value -2 is the intended default offset; expressing it as -2 directly instead of 0xFE avoids relying on implicit truncation of an unsigned-looking hex literal into a signed field.
No functional change.
---
v2: express the value as -2 directly instead of casting 0xFE to s8,
per Dan Carpenter's suggestion
--- drivers/staging/rtl8723bs/include/hal_pg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/include/hal_pg.h +1 -1
@@ -40,7 +40,7 @@#define EEPROM_RF_BT_SETTING_8723B 0xC3#define EEPROM_VERSION_8723B 0xC4#define EEPROM_CustomID_8723B 0xC5 -#define EEPROM_DEFAULT_DIFF 0XFE +#define EEPROM_DEFAULT_DIFF -2/* RTL8723BS */ #define EEPROM_MAC_ADDR_8723BS 0x11A
Signature · 1 line
2.55.0
Greg Kroah-Hartman
maintainerRe: [PATCH v2] staging: rtl8723bs: define EEPROM_DEFAULT_DIFF as -2 directly
Quoted 34 lines · Ivy Lopez
EEPROM_DEFAULT_DIFFis defined as the bare integer literal0xFE
(254) but is only ever assigned into s8 (signed char) fields used to store signed TX power calibration offsets. The value -2 is the intended default offset; expressing it as -2 directly instead of0xFEavoids relying on implicit truncation of an unsigned-looking hex literal into a signed field.No functional change.
Signed-off-by Ivy Lopez <[email protected]>---
v2: express the value as -2 directly instead of casting0xFEto s8,
per Dan Carpenter's suggestion--- drivers/staging/rtl8723bs/include/hal_pg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/rtl8723bs/include/hal_pg.h +1
-1@@ -40,7 +40,7 @@#define EEPROM_RF_BT_SETTING_8723B 0xC3#define EEPROM_VERSION_8723B 0xC4#define EEPROM_CustomID_8723B 0xC5 -#define EEPROM_DEFAULT_DIFF 0XFE +#define EEPROM_DEFAULT_DIFF -2/* RTL8723BS */ #define EEPROM_MAC_ADDR_8723BS 0x11ASignature · 1 line
2.55.0
Does not apply against the staging-testing branch, please rebase and resend.
thanks,
greg k-h
PATCH v3 1/1 staging: rtl8723bs: define EEPROM_DEFAULT_DIFF as -2 directly
In reply to Ivy LopezEEPROM_DEFAULT_DIFF is defined as the bare integer literal 0xFE
(254) but is only ever assigned into s8 (signed char) fields used to store signed TX power calibration offsets. The value -2 is the intended default offset; expressing it as -2 directly instead of 0xFE avoids relying on implicit truncation of an unsigned-looking hex literal into a signed field.
No functional change.
---
v2: express the value as -2 directly instead of casting 0xFE to s8,
per Dan Carpenter's suggestion
v3: rebase against staging-testing
--- drivers/staging/rtl8723bs/include/hal_pg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/include/hal_pg.h +1 -1
@@ -38,7 +38,7 @@#define EEPROM_RF_BOARD_OPTION_8723B 0xC1#define EEPROM_RF_BT_SETTING_8723B 0xC3 -#define EEPROM_DEFAULT_DIFF 0XFE +#define EEPROM_DEFAULT_DIFF -2/* RTL8723BS */ #define EEPROM_MAC_ADDR_8723BS 0x11A
Signature · 1 line
2.55.0