Re: [PATCH v8 01/16] hashtable: introduce a small and naive hashtable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel


[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux