* Re: [dm-devel] [PATCH v8 01/16] hashtable: introduce a small and naive hashtable
@ 2012-10-31 9:10 George Spelvin
0 siblings, 0 replies; only message in thread
From: George Spelvin @ 2012-10-31 9:10 UTC (permalink / raw)
To: tj; +Cc: dm-devel, levinsasha928, linux-kernel, linux-mm, linux-nfs,
netdev
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.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-10-31 9:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-31 9:10 [dm-devel] [PATCH v8 01/16] hashtable: introduce a small and naive hashtable George Spelvin
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).