[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.2.21.1911051053560.11074@ninjahub.org>
Date: Tue, 5 Nov 2019 11:00:44 +0000 (GMT)
From: Jules Irenge <jbi.octave@...il.com>
To: Ian Abbott <abbotti@....co.uk>
cc: Jules Irenge <jbi.octave@...il.com>,
outreachy-kernel@...glegroups.com, gregkh@...uxfoundation.org,
devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
hsweeten@...ionengravers.com
Subject: Re: [PATCH v2] staging: comedi: rewrite macro function with GNU
extension typeof
On Mon, 4 Nov 2019, Ian Abbott wrote:
> On 04/11/2019 16:33, Jules Irenge wrote:
> > Rewrite macro function with the GNU extension typeof
> > to remove a possible side-effects of MACRO argument reuse "x".
> > - Problem could rise if arguments have different types
> > and different use though.
> >
> > Signed-off-by: Jules Irenge <jbi.octave@...il.com>
> > ---
> > v1 - had no full commit log message, with changes not intended to be in the
> > patch
> > v2 - remove some changes not intended to be in this driver
> > include note of a potential problem
> > drivers/staging/comedi/comedi.h | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/staging/comedi/comedi.h
> > b/drivers/staging/comedi/comedi.h
> > index 09a940066c0e..a57691a2e8d8 100644
> > --- a/drivers/staging/comedi/comedi.h
> > +++ b/drivers/staging/comedi/comedi.h
> > @@ -1103,8 +1103,10 @@ 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
> >
>
> I wasn't sure about this the first time around due to the use of GNU
> extensions in uapi header files, but I see there are a few, rare instances of
> this GNU extension elsewhere in other uapi headers (mainly in netfilter
> stuff), so I guess it's OK. However, it does mean that user code that uses
> these macros will no longer compile unless GNU extensions are enabled.
>
> Does anyone know any "best practices" regarding use of GNU extensions in user
> header files under Linux?
>
> --
> -=( Ian Abbott <abbotti@....co.uk> || Web: www.mev.co.uk )=-
> -=( MEV Ltd. is a company registered in England & Wales. )=-
> -=( Registered number: 02862268. Registered address: )=-
> -=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=-
>
>
Apology, I misinterpreted the comments and send a second
version without thinking much.
Please discard it unless you wish to try out.
Any way thanks for the feedback, I really appreciate I find it educative.
Kind regards,
Jules
Powered by blists - more mailing lists