lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20121031091018.24875.qmail@science.horizon.com>
Date:	31 Oct 2012 05:10:18 -0400
From:	"George Spelvin" <linux@...izon.com>
To:	tj@...nel.org
Cc:	dm-devel@...hat.com, levinsasha928@...il.com,
	linux-kernel@...r.kernel.org, linux-mm@...ck.org,
	linux-nfs@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [dm-devel] [PATCH v8 01/16] hashtable: introduce a small and naive hashtable

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.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ