From: "George Spelvin" <linux@horizon.com>
To: tj@kernel.org
Cc: dm-devel@redhat.com, levinsasha928@gmail.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
linux-nfs@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [dm-devel] [PATCH v8 01/16] hashtable: introduce a small and naive hashtable
Date: 31 Oct 2012 05:10:18 -0400 [thread overview]
Message-ID: <20121031091018.24875.qmail@science.horizon.com> (raw)
Tejun Heo wrote:
>> +#define hash_min(val, bits) \
>> +({ \
>> + sizeof(val) <= 4 ? \
>> + hash_32(val, bits) : \
>> + hash_long(val, bits); \
>> +})
> Also, you probably want () around at least @val. In general,
> it's a good idea to add () around any macro argument to avoid nasty
> surprises.
Er... not in this case, you don't. If a macro argument is passed verbatim
as an argument to a function, it doesn't need additional parens.
That's because the one guarantee you have about a macro argument is
that it can't contain any (unquoted) commas, and there's nothing lower
precedence than the comma. So it's safe to delimit a macro argument
with *either* parens *or* a comma.
So you can go ahead and write:
#define hash_min(val, bits) \
(sizeof(val) <= 4 ? hash_32(val, bits) : hash_long(val, bits))
... which is easier to read, anyway.
reply other threads:[~2012-10-31 9:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20121031091018.24875.qmail@science.horizon.com \
--to=linux@horizon.com \
--cc=dm-devel@redhat.com \
--cc=levinsasha928@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nfs@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=tj@kernel.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 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).