All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: "Mihai Donțu" <mihai.dontu@gmail.com>, "Jan Beulich" <JBeulich@suse.com>
Cc: Wei Liu <wei.liu2@citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Don Slutz <don.slutz@gmail.com>, Don Slutz <dslutz@verizon.com>,
	xen-devel@lists.xen.org, Keir Fraser <keir@xen.org>
Subject: Re: [PATCH 1/4] hvmloader: Fixup pci_write* macros
Date: Mon, 15 Jun 2015 18:14:52 +0100	[thread overview]
Message-ID: <557F080C.5040606@citrix.com> (raw)
In-Reply-To: <20150615190939.6238e731@mdontu-l.dsd.bitdefender.biz>

On 15/06/15 17:09, Mihai Donțu wrote:
> On Mon, 15 Jun 2015 16:23:13 +0100 Jan Beulich wrote:
>>>>> On 15.06.15 at 16:35, <andrew.cooper3@citrix.com> wrote:
>>> On 15/06/15 15:30, Don Slutz wrote:
>>>> On 06/15/15 10:19, Andrew Cooper wrote:
>>>>> Furthermore, what about devfn or reg?
>>>>>
>>>> devfn and reg do not need the bracketing since they are just passed,
>>>> but I have no issue with adding the extra brackets.
>>> Macros, under all circumstances, should have all of their parameters
>>> bracketed for safety.
>> No, as this harms readability:
>>
>> #define macro(x) function((x))
>>
>> would completely pointlessly be having an extra set of parentheses.
>> And
>>
>> #define macro(x, y) function(x, y)
>>
>> is just the logical extension to that: There is nothing the expressions
>> passed as arguments could contain to require parenthesization, as
>> there's no operator of precedence lower than comma (and if either
>> argument contains a comma expression, it needs to be
>> parenthesized at the invocation site anyway).
> I think parenthesis are just long term guards against classic surprises
> such as:
>
> #define macro(x) function(x * 2)
> ...
> macro(N + 3)
>
> You could treat this case separately though, but people often go for the
> "good practice".
>

Personally, I would go a step further and suggest that if a macro is not
doing {string,token}isation, or deliberately playing with local state,
it should be a static inline function instead (although I do appear to
be in the minority with this view).

This way, the compiler is able to provide far more coherent error
messages and spot type errors, both of which reduce the number of errors
which can accidentally be introduced.  Furthermore, the compiler is also
able to ignore the 'inline' if it decides it knows better, which
generally results in more efficient code.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2015-06-15 17:14 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-15 14:15 [PATCH 0/4] Add PCI to PCI bridge support to Xen Don Slutz
2015-06-15 14:15 ` [PATCH 1/4] hvmloader: Fixup pci_write* macros Don Slutz
2015-06-15 14:19   ` Andrew Cooper
2015-06-15 14:30     ` Don Slutz
2015-06-15 14:35       ` Andrew Cooper
2015-06-15 15:23         ` Jan Beulich
2015-06-15 16:09           ` Mihai Donțu
2015-06-15 17:14             ` Andrew Cooper [this message]
2015-06-16  7:39               ` Jan Beulich
2015-06-16  7:36             ` Jan Beulich
2015-06-15 14:36       ` Jan Beulich
2015-06-15 14:32     ` Jan Beulich
2015-06-15 14:15 ` [PATCH 2/4] hvmloader: Add support for PCI to PCI bridge Don Slutz
2015-06-15 14:26   ` Andrew Cooper
2015-06-15 14:56     ` Lars Kurth
2015-06-15 14:58     ` George Dunlap
2015-06-15 17:24       ` Don Slutz
2015-06-15 15:56     ` Don Slutz
2015-06-15 14:15 ` [PATCH 3/4] Allow vif= to specify PCI address for each nic Don Slutz
2015-06-15 15:54   ` Wei Liu
2015-06-15 17:45     ` Don Slutz
2015-06-16 10:32       ` Wei Liu
2015-06-16 15:23         ` Don Slutz
2015-06-16 16:14           ` Wei Liu
2015-06-16 19:02             ` Don Slutz
2015-06-16 20:08               ` Wei Liu
2015-06-15 14:15 ` [PATCH 4/4] Allow disk= to specify their emulated bus address Don Slutz

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=557F080C.5040606@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=don.slutz@gmail.com \
    --cc=dslutz@verizon.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=keir@xen.org \
    --cc=mihai.dontu@gmail.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.