[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <504DDAAB.7090001@gmail.com>
Date: Mon, 10 Sep 2012 14:18:51 +0200
From: Sasha Levin <levinsasha928@...il.com>
To: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
CC: torvalds@...ux-foundation.org, tj@...nel.org,
linux-kernel@...r.kernel.org, rostedt@...dmis.org,
ebiederm@...ssion.com, josh@...htriplett.org,
David.Laight@...LAB.COM, palves@...hat.com, rmallon@...il.com,
bfields@...ldses.org
Subject: Re: [PATCH v4] hashtable: introduce a small and naive hashtable
On 09/10/2012 04:48 AM, Mathieu Desnoyers wrote:
> * Sasha Levin (levinsasha928@...il.com) wrote:
>> +#define hash_init(hashtable) \
>> +({ \
>> + int __i; \
>> + \
>> + for (__i = 0; __i < HASH_BITS(hashtable); __i++) \
>> + INIT_HLIST_HEAD(hashtable + __i); \
>
> I suspect that hashtable will be a pointer, and you use the "+" operator
> to do an offset on this pointer. Any thought on using:
>
> INIT_HLIST_HEAD(&hashtable[__i]);
>
> instead ? It would provide the same result, but would ensure that the
> user is indeed passing a pointer, and not an integer.
It also looks nicer :)
> Also, why isn't it a static inline ? I'm probably missing something. If
> there is a reason why it needs to stay a #define, please document it in
> the comment.
It's a define because it needs to get the size of the hashtable.
I'll document that.
Thanks,
Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists