Skip to contentSkip to conversation

staging: rtl8723bs: remove unused BIT macros definitions

PATCH Superseded Fabio Aiuto 2 participants 3 messages Jul 30, 2021 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8723bs: remove unused BIT macros definitions

BIT(x) macro used all over the driver is defined in include/vsdo/bit.h as

- #define BIT(nr) (UL(1) << (nr))

which is safer than the local BIT macros declared. Local macros shift a signed integer which brings unespected results. For example:

(unsigned long)(1 << 31) => 0xffffffff80000000

shift.c:

int main() {
        printf("%lx\n", (unsigned long)(1 << 31));
        printf("%lx\n", (unsigned long)(1U << 31));
        return 0;
}

---

$ ./shift
ffffffff80000000
80000000
---

So just remove redundant, less safe macro declarations.

---
 drivers/staging/rtl8723bs/include/osdep_service.h | 4 ----
 drivers/staging/rtl8723bs/include/wifi.h          | 8 --------
 2 files changed, 12 deletions(-)
drivers/staging/rtl8723bs/include/osdep_service.h +0 -4
index b49838c7e457..bde415db4114 100644
@@ -14,10 +14,6 @@
 
 #include <osdep_service_linux.h>
 
-#ifndef BIT
-	#define BIT(x)	(1 << (x))
-#endif
-
 #define BIT0	0x00000001
 #define BIT1	0x00000002
 #define BIT2	0x00000004
drivers/staging/rtl8723bs/include/wifi.h +0 -8
index 0bd7b662b972..f03e26818d45 100644
@@ -7,14 +7,6 @@
 #ifndef _WIFI_H_
 #define _WIFI_H_
 
-
-#ifdef BIT
-/* error	"BIT define occurred earlier elsewhere!\n" */
-#undef BIT
-#endif
-#define BIT(x)	(1 << (x))
-
-
 #define WLAN_ETHHDR_LEN		14
 #define WLAN_ETHADDR_LEN	6
 #define WLAN_IEEE_OUI_LEN	3
Signature · 1 line
2.20.1
maintainer
#1 lore raw
Quoted 18 lines · Fabio Aiuto

BIT(x) macro used all over the driver is defined in include/vsdo/bit.h as

- #define BIT(nr) (UL(1) << (nr))

which is safer than the local BIT macros declared. Local macros shift a signed integer which brings unespected results. For example:

(unsigned long)(1 << 31) => 0xffffffff80000000

shift.c:

int main() {
        printf("%lx\n", (unsigned long)(1 << 31));
        printf("%lx\n", (unsigned long)(1U << 31));
        return 0;
}
Quoted 6 lines

---

$ ./shift
ffffffff80000000
80000000
---

Don't put "---" in a changelog text, otherwise the signed-off-by will be cut off. Can you resend it with that changed to something else like "---------------" or anything else?

thanks,

greg k-h

#2 lore raw

Hello Greg,

Quoted 26 lines · Greg KH
Quoted 18 lines · Fabio Aiuto

BIT(x) macro used all over the driver is defined in include/vsdo/bit.h as

- #define BIT(nr) (UL(1) << (nr))

which is safer than the local BIT macros declared. Local macros shift a signed integer which brings unespected results. For example:

(unsigned long)(1 << 31) => 0xffffffff80000000

shift.c:

int main() {
        printf("%lx\n", (unsigned long)(1 << 31));
        printf("%lx\n", (unsigned long)(1U << 31));
        return 0;
}
Quoted 6 lines

---

$ ./shift
ffffffff80000000
80000000
---
Quoted 7 lines

Don't put "---" in a changelog text, otherwise the signed-off-by will be cut off. Can you resend it with that changed to something else like "---------------" or anything else?

thanks,

greg k-h

sure I'm about to send a v2,

thank you,

fabio