linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4/4] Staging: rtl8712: osdep_intf: Improve RND4 macro for better debugging and safety
@ 2023-03-21 11:41 Inshal Khan
  2023-03-21 13:36 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: Inshal Khan @ 2023-03-21 11:41 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, linux-kernel

This commit modifies the RND4_UPPER macro in the osdep_intf module of
the rtl8712 driver to improve its safety and debugging capabilities.
The macro has been changed to use a temporary variable for the input
argument 'x', instead of directly using it in the macro expression.
This change helps to avoid potential issues with operator precedence
and unexpected side effects that could occur if 'x' was reused within
the macro.

Additionally, the new definition of the macro uses the 'typeof' operator
to determine the type of the input argument, which ensures that the macro
can handle any data type safely. The new definition also uses a block
expression to contain the macro code, allowing for better debugging
capabilities and cleaner code.

This change improves the safety and maintainability of the RND4 macro
and makes it more suitable for use in the Linux kernel.

Signed-off-by: Inshal Khan <kziaul123@gmail.com>
---
 drivers/staging/rtl8712/osdep_intf.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8712/osdep_intf.h b/drivers/staging/rtl8712/osdep_intf.h
index 95a21f380cd7..0e097b4a8670 100644
--- a/drivers/staging/rtl8712/osdep_intf.h
+++ b/drivers/staging/rtl8712/osdep_intf.h
@@ -18,8 +18,8 @@
 #include "drv_types.h"
 
 #define RND4(x)	({ \
-		typeof(x) _x = (x); \
-		(((_x) + 3) & ~3); \
+			typeof(x) _x = (x); \
+			(((_x) + 3) & ~3); \
 		})
 
 struct intf_priv {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 4/4] Staging: rtl8712: osdep_intf: Improve RND4 macro for better debugging and safety
  2023-03-21 11:41 [PATCH 4/4] Staging: rtl8712: osdep_intf: Improve RND4 macro for better debugging and safety Inshal Khan
@ 2023-03-21 13:36 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2023-03-21 13:36 UTC (permalink / raw)
  To: Inshal Khan; +Cc: gregkh, linux-staging, linux-kernel

On Tue, Mar 21, 2023 at 05:11:41PM +0530, Inshal Khan wrote:
>  drivers/staging/rtl8712/osdep_intf.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/rtl8712/osdep_intf.h b/drivers/staging/rtl8712/osdep_intf.h
> index 95a21f380cd7..0e097b4a8670 100644
> --- a/drivers/staging/rtl8712/osdep_intf.h
> +++ b/drivers/staging/rtl8712/osdep_intf.h
> @@ -18,8 +18,8 @@
>  #include "drv_types.h"
>  
>  #define RND4(x)	({ \
> -		typeof(x) _x = (x); \
> -		(((_x) + 3) & ~3); \
> +			typeof(x) _x = (x); \
> +			(((_x) + 3) & ~3); \

Just use normal kernel rounding macros and delete RND4().

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-21 14:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-21 11:41 [PATCH 4/4] Staging: rtl8712: osdep_intf: Improve RND4 macro for better debugging and safety Inshal Khan
2023-03-21 13:36 ` Dan Carpenter

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).