aboutsummaryrefslogtreecommitdiff
path: root/net/batman-adv/hash.c
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2011-05-14 23:14:54 +0200
committerSven Eckelmann <sven@narfation.org>2011-05-30 07:39:33 +0200
commit704509b8d44886cebfbaff1a9813c35dfa986954 (patch)
tree7b353f1d4a33b31d55d2a85f8d70882ade1868ce /net/batman-adv/hash.c
parent958ca5985604a6f13387d32de489365df816558b (diff)
batman-adv: Calculate sizeof using variable insead of types
Documentation/CodingStyle recommends to use the form p = kmalloc(sizeof(*p), ...); to calculate the size of a struct and not the version where the struct name is spelled out to prevent bugs when the type of p changes. This also seems appropriate for manipulation of buffers when they are directly associated with p. Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net/batman-adv/hash.c')
-rw-r--r--net/batman-adv/hash.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/net/batman-adv/hash.c b/net/batman-adv/hash.c
index c5213d8f2cc..2a172505f51 100644
--- a/net/batman-adv/hash.c
+++ b/net/batman-adv/hash.c
@@ -46,15 +46,16 @@ struct hashtable_t *hash_new(int size)
{
struct hashtable_t *hash;
- hash = kmalloc(sizeof(struct hashtable_t), GFP_ATOMIC);
+ hash = kmalloc(sizeof(*hash), GFP_ATOMIC);
if (!hash)
return NULL;
- hash->table = kmalloc(sizeof(struct element_t *) * size, GFP_ATOMIC);
+ hash->table = kmalloc(sizeof(*hash->table) * size, GFP_ATOMIC);
if (!hash->table)
goto free_hash;
- hash->list_locks = kmalloc(sizeof(spinlock_t) * size, GFP_ATOMIC);
+ hash->list_locks = kmalloc(sizeof(*hash->list_locks) * size,
+ GFP_ATOMIC);
if (!hash->list_locks)
goto free_table;