LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] staging: rtl8723bs: remove unused BIT macros definitions
@ 2021-07-30 13:19 Fabio Aiuto
2021-07-30 13:23 ` Fabio Aiuto
0 siblings, 1 reply; 5+ messages in thread
From: Fabio Aiuto @ 2021-07-30 13:19 UTC (permalink / raw)
Cc: hdegoede, Larry.Finger, linux-staging, linux-kernel, David Sterba
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>
---
drivers/staging/rtl8723bs/include/osdep_service.h | 4 ----
drivers/staging/rtl8723bs/include/wifi.h | 8 --------
2 files changed, 12 deletions(-)
diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h b/drivers/staging/rtl8723bs/include/osdep_service.h
index b49838c7e457..bde415db4114 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service.h
@@ -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
diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h
index 0bd7b662b972..f03e26818d45 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -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
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: rtl8723bs: remove unused BIT macros definitions
2021-07-30 13:19 [PATCH] staging: rtl8723bs: remove unused BIT macros definitions Fabio Aiuto
@ 2021-07-30 13:23 ` Fabio Aiuto
0 siblings, 0 replies; 5+ messages in thread
From: Fabio Aiuto @ 2021-07-30 13:23 UTC (permalink / raw)
To: gregkh, hdegoede, Larry.Finger, linux-staging, linux-kernel,
David Sterba
Hi all,
sorry, I missed the To: field, ignore this one.
Thank you,
fabio
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: rtl8723bs: remove unused BIT macros definitions
2021-07-30 13:32 ` Greg KH
@ 2021-07-30 13:35 ` Fabio Aiuto
0 siblings, 0 replies; 5+ messages in thread
From: Fabio Aiuto @ 2021-07-30 13:35 UTC (permalink / raw)
To: Greg KH; +Cc: hdegoede, Larry.Finger, linux-staging, linux-kernel, David Sterba
Hello Greg,
On Fri, Jul 30, 2021 at 03:32:36PM +0200, Greg KH wrote:
> On Fri, Jul 30, 2021 at 03:21:03PM +0200, Fabio Aiuto wrote:
> > 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
> > ---
>
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: rtl8723bs: remove unused BIT macros definitions
2021-07-30 13:21 Fabio Aiuto
@ 2021-07-30 13:32 ` Greg KH
2021-07-30 13:35 ` Fabio Aiuto
0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2021-07-30 13:32 UTC (permalink / raw)
To: Fabio Aiuto
Cc: hdegoede, Larry.Finger, linux-staging, linux-kernel, David Sterba
On Fri, Jul 30, 2021 at 03:21:03PM +0200, Fabio Aiuto wrote:
> 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
> ---
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] staging: rtl8723bs: remove unused BIT macros definitions
@ 2021-07-30 13:21 Fabio Aiuto
2021-07-30 13:32 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: Fabio Aiuto @ 2021-07-30 13:21 UTC (permalink / raw)
To: gregkh; +Cc: hdegoede, Larry.Finger, linux-staging, linux-kernel, David Sterba
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>
---
drivers/staging/rtl8723bs/include/osdep_service.h | 4 ----
drivers/staging/rtl8723bs/include/wifi.h | 8 --------
2 files changed, 12 deletions(-)
diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h b/drivers/staging/rtl8723bs/include/osdep_service.h
index b49838c7e457..bde415db4114 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service.h
@@ -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
diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h
index 0bd7b662b972..f03e26818d45 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -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
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-07-30 13:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-30 13:19 [PATCH] staging: rtl8723bs: remove unused BIT macros definitions Fabio Aiuto
2021-07-30 13:23 ` Fabio Aiuto
2021-07-30 13:21 Fabio Aiuto
2021-07-30 13:32 ` Greg KH
2021-07-30 13:35 ` Fabio Aiuto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).