staging: rtl8723bs: remove unused BIT macros definitions
authorFabio Aiuto <fabioaiuto83@gmail.com>
Fri, 30 Jul 2021 13:40:48 +0000 (15:40 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 30 Jul 2021 14:06:32 +0000 (16:06 +0200)
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.

Suggested-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Fabio Aiuto <fabioaiuto83@gmail.com>
Link: https://lore.kernel.org/r/20210730134048.8736-1-fabioaiuto83@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723bs/include/osdep_service.h
drivers/staging/rtl8723bs/include/wifi.h

index b49838c7e457d4b49c57a0cf158228c2b14970e0..bde415db41145a2180d186d9200e96b4f86923df 100644 (file)
 
 #include <osdep_service_linux.h>
 
-#ifndef BIT
-       #define BIT(x)  (1 << (x))
-#endif
-
 #define BIT0   0x00000001
 #define BIT1   0x00000002
 #define BIT2   0x00000004
index 0bd7b662b9727a920f72cd14164d0c312e33df3f..f03e26818d45a1097348ae46fbd84eb69deb6be7 100644 (file)
@@ -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