linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Alison Schofield <alison.schofield@intel.com>
Cc: Julia Lawall <julia.lawall@inria.fr>,
	Menna Mahmoud <eng.mennamahmoud.mm@gmail.com>,
	outreachy@lists.linux.dev, lars@metafoo.de,
	Michael.Hennerich@analog.com, jic23@kernel.org,
	gregkh@linuxfoundation.org, linux-iio@vger.kernel.org,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: iio: meter: enclose Macros with complex values in parentheses
Date: Wed, 15 Mar 2023 07:19:47 +0300	[thread overview]
Message-ID: <ba15ff7a-8766-43db-be7c-f971bf6dc8d6@kili.mountain> (raw)
In-Reply-To: <ZBEQYp/z+C/JeR98@aschofie-mobl2>

On Tue, Mar 14, 2023 at 05:25:06PM -0700, Alison Schofield wrote:
> On Sun, Mar 12, 2023 at 03:25:37PM +0100, Julia Lawall wrote:
> > 
> > 
> > On Sun, 12 Mar 2023, Menna Mahmoud wrote:
> > 
> > >
> > > On ١٢/٣/٢٠٢٣ ١٦:١٢, Julia Lawall wrote:
> > > >
> > > > On Sun, 12 Mar 2023, Menna Mahmoud wrote:
> > > >
> > > > > enclose Macros with complex values in parentheses is especially useful
> > > > > in making macro definitions “safe” (so that they
> > > > > evaluate each operand exactly once).
> > > > enclose -> Enclose, and Macros -> macros
> > > >
> > > > I don't understand the above comment though.  How does adding parentheses
> > > > around the body of a macro cause the operands to be evaluated only once?
> > > > And the macros that you have changed don't have any operands.
> > > >
> > > > The value of adding parentheses is normally to ensure that the body of the
> > > > macro doesn't interact with the context in a weird way.  For example, you
> > > > could have
> > > >
> > > > #define ADD 3 + 4
> > > >
> > > > Then if you use your macro as 6 * ADD, you will end up evaluating
> > > > 6 * 3 + 4, ie 18 + 4, when you might have expected 6 * 7.  The issue is
> > > > that * has higher precedence than +.
> > >
> > >
> > > yes, I mean that but i couldn't explain it well, thanks for your feedback.
> > >
> > >
> > > >
> > > > But I don't think that such a problem can arise with a cast expression, so
> > > > parentheses around it should not be necessary.
> > >
> > >
> > > So, no need for this patch?
> > 
> > No, I don't think so.
> > 
> > julia
> 
> Looping in Dan C explicitly.
> 
> Can we revisit this one?  It actually leads to a checkpatch ERROR.
> So, anyone hoping to get an error free checkpatch run on this file,
> is out of luck.
> 
> Is this something that checkpatch can learn about and allow, or
> should we add the parens here, to dare I say, appease the checkpatch
> god ;)
> 

I think you wanted to CC Joe, not me?

I agree with Julia, but I also have slightly kind of given up resisting
on this one when people start adding unnecesary parentheses.

Fixing the COMPLEX_MACRO macro warning to ignore cast operations would
be a great idea for a small project.

regards,
dan carpenter

      reply	other threads:[~2023-03-15  4:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-12 13:33 [PATCH] staging: iio: meter: enclose Macros with complex values in parentheses Menna Mahmoud
2023-03-12 14:12 ` Julia Lawall
2023-03-12 14:23   ` Menna Mahmoud
2023-03-12 14:25     ` Julia Lawall
2023-03-15  0:25       ` Alison Schofield
2023-03-15  4:19         ` Dan Carpenter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ba15ff7a-8766-43db-be7c-f971bf6dc8d6@kili.mountain \
    --to=error27@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=alison.schofield@intel.com \
    --cc=eng.mennamahmoud.mm@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=julia.lawall@inria.fr \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=outreachy@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).