[PATCH 4/4] Staging: rtl8712: osdep_intf: Improve RND4 macro for better debugging and safety

From: Inshal Khan
Date: Tue Mar 21 2023 - 07:41:53 EST


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@xxxxxxxxx>
---
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