mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] staging: pi433: pi433_if.c Fix SET_CHECKED style issues
@ 2017-11-30 21:40 Nguyen Phan Quang Minh
  2017-12-01 14:23 ` Dan Carpenter
  2017-12-03  0:09 ` [PATCHv2] staging: pi433: pi433_if.c remove SET_CHECKED macro Nguyen Phan Quang Minh
  0 siblings, 2 replies; 5+ messages in thread
From: Nguyen Phan Quang Minh @ 2017-11-30 21:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel, linux-kernel

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@gmail.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

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

end of thread, other threads:[~2017-12-06 15:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-30 21:40 [PATCH] staging: pi433: pi433_if.c Fix SET_CHECKED style issues Nguyen Phan Quang Minh
2017-12-01 14:23 ` Dan Carpenter
2017-12-01 14:26   ` Dan Carpenter
2017-12-03  0:09 ` [PATCHv2] staging: pi433: pi433_if.c remove SET_CHECKED macro Nguyen Phan Quang Minh
2017-12-06 15:19   ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome