* [PATCH] drivers: staging: comedi: Fixed side effects from macro definition.
@ 2021-02-17 14:20 chakravarthikulkarni
2021-02-18 10:13 ` Ian Abbott
0 siblings, 1 reply; 3+ messages in thread
From: chakravarthikulkarni @ 2021-02-17 14:20 UTC (permalink / raw)
Cc: chakravarthikulkarni2021, Ian Abbott, H Hartley Sweeten,
Greg Kroah-Hartman, Ethan Edwards, devel, linux-kernel
Warning found by checkpatch.pl script.
Signed-off-by: chakravarthikulkarni <chakravarthikulkarni2021@gmail.com>
---
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
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers: staging: comedi: Fixed side effects from macro definition.
2021-02-17 14:20 [PATCH] drivers: staging: comedi: Fixed side effects from macro definition chakravarthikulkarni
@ 2021-02-18 10:13 ` Ian Abbott
[not found] ` <CAEwrQWZEXYJDsTDiOAZLOr5jLXXyuZamwqRMquCyBdYPa8anow@mail.gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Ian Abbott @ 2021-02-18 10:13 UTC (permalink / raw)
To: chakravarthikulkarni
Cc: H Hartley Sweeten, Greg Kroah-Hartman, Ethan Edwards, devel,
linux-kernel
On 17/02/2021 14:20, chakravarthikulkarni wrote:
> Warning found by checkpatch.pl script.
>
> Signed-off-by: chakravarthikulkarni <chakravarthikulkarni2021@gmail.com>
> ---
> 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@mev.co.uk> || 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 )=-
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers: staging: comedi: Fixed side effects from macro definition.
[not found] ` <CAEwrQWZEXYJDsTDiOAZLOr5jLXXyuZamwqRMquCyBdYPa8anow@mail.gmail.com>
@ 2021-02-24 7:30 ` Greg Kroah-Hartman
0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2021-02-24 7:30 UTC (permalink / raw)
To: chakravarthi Kulkarni
Cc: Ian Abbott, H Hartley Sweeten, Ethan Edwards, devel, linux-kernel
A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
A: No.
Q: Should I include quotations after my reply?
http://daringfireball.net/2007/07/on_top
On Wed, Feb 24, 2021 at 12:47:26PM +0530, chakravarthi Kulkarni wrote:
> Hi,
>
> I tested it will unit test cases it looks fine.
> int x = 10;
> NI_USUAL_PFI_SELECT(x++)
>
> will not have side effects as it is taken care using local variable in
> macro.
You ignored what Ian said about why this change was not ok :(
It's long deleted from my review queue, sorry.
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-24 7:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-17 14:20 [PATCH] drivers: staging: comedi: Fixed side effects from macro definition chakravarthikulkarni
2021-02-18 10:13 ` Ian Abbott
[not found] ` <CAEwrQWZEXYJDsTDiOAZLOr5jLXXyuZamwqRMquCyBdYPa8anow@mail.gmail.com>
2021-02-24 7:30 ` 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;
as well as URLs for NNTP newsgroup(s).