Re: [PATCH] drivers: staging: comedi: Fixed side effects from macro definition.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 17/02/2021 14:20, chakravarthikulkarni wrote:
Warning found by checkpatch.pl script.

Signed-off-by: chakravarthikulkarni <chakravarthikulkarni2021@xxxxxxxxx>
---
  drivers/staging/comedi/comedi.h | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/comedi.h b/drivers/staging/comedi/comedi.h
index b5d00a006dbb..b2af6a88d389 100644
--- a/drivers/staging/comedi/comedi.h
+++ b/drivers/staging/comedi/comedi.h
@@ -1103,9 +1103,12 @@ enum ni_common_signal_names {
/* *** END GLOBALLY-NAMED NI TERMINALS/SIGNALS *** */ -#define NI_USUAL_PFI_SELECT(x) (((x) < 10) ? (0x1 + (x)) : (0xb + (x)))
-#define NI_USUAL_RTSI_SELECT(x)	(((x) < 7) ? (0xb + (x)) : 0x1b)
-
+#define NI_USUAL_PFI_SELECT(x) \
+	({ typeof(x) _x = x; \
+	 (((_x) < 10) ? (0x1 + (_x)) : (0xb + (_x))); })
+#define NI_USUAL_RTSI_SELECT(x)	\
+	({ typeof(x) _x = x; \
+	 (((_x) < 7) ? (0xb + (_x)) : 0x1b); })
  /*
   * mode bits for NI general-purpose counters, set with
   * INSN_CONFIG_SET_COUNTER_MODE


I'd rather not do that because this is intended to be a userspace header. This change adds GCC extensions and prohibits the use of the macros in constant expressions.

--
-=( Ian Abbott <abbotti@xxxxxxxxx> || MEV Ltd. is a company  )=-
-=( registered in England & Wales.  Regd. number: 02862268.  )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux