linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Inshal Khan <kziaul123@gmail.com>
To: gregkh@linuxfoundation.org
Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] Staging: rtl8712: osdep_intf: Improve RND4 macro for better debugging and safety
Date: Tue, 21 Mar 2023 17:11:41 +0530	[thread overview]
Message-ID: <ZBmX9cjTRNhwt2zA@mehmed-HP-Pavilion-Laptop-15-eh2xxx> (raw)

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


             reply	other threads:[~2023-03-21 11:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-21 11:41 Inshal Khan [this message]
2023-03-21 13:36 ` [PATCH 4/4] Staging: rtl8712: osdep_intf: Improve RND4 macro for better debugging and safety Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZBmX9cjTRNhwt2zA@mehmed-HP-Pavilion-Laptop-15-eh2xxx \
    --to=kziaul123@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).