[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171130214014.GA4405@minhnpqrs-antergos>
Date: Thu, 30 Nov 2017 22:40:14 +0100
From: Nguyen Phan Quang Minh <minhnpq16@...il.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org
Subject: [PATCH] staging: pi433: pi433_if.c Fix SET_CHECKED style issues
Fix checkpatch warning and add result holder variable to reduce overhead
since the macro is called on functions.
Signed-off-by: Nguyen Phan Quang Minh <minhnpq16@...il.com>
---
Since SET_CHECKED has a return statement, I'm very tempted to straight
up remove it and do the checking inline. But the macro is used a lot
(~60 times), I think it might hurt the readability of the code.
drivers/staging/pi433/pi433_if.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 3404cb9722c9..77ab2986b985 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -122,9 +122,12 @@ struct pi433_instance {
/*-------------------------------------------------------------------------*/
/* macro for checked access of registers of radio module */
-#define SET_CHECKED(retval) \
- if (retval < 0) \
- return retval;
+#define SET_CHECKED(func) \
+ do { \
+ int retval = func; \
+ if (retval < 0) \
+ return retval; \
+ } while (0)
/*-------------------------------------------------------------------------*/
--
2.15.1
Powered by blists - more mailing lists