diff options
author | Sven Eckelmann <sven@narfation.org> | 2011-05-14 17:14:54 -0400 |
---|---|---|
committer | Sven Eckelmann <sven@narfation.org> | 2011-05-30 01:39:33 -0400 |
commit | 704509b8d44886cebfbaff1a9813c35dfa986954 (patch) | |
tree | 7b353f1d4a33b31d55d2a85f8d70882ade1868ce /net/batman-adv/hash.c | |
parent | 958ca5985604a6f13387d32de489365df816558b (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.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/net/batman-adv/hash.c b/net/batman-adv/hash.c index c5213d8f2cca..2a172505f513 100644 --- a/net/batman-adv/hash.c +++ b/net/batman-adv/hash.c | |||
@@ -46,15 +46,16 @@ struct hashtable_t *hash_new(int size) | |||
46 | { | 46 | { |
47 | struct hashtable_t *hash; | 47 | struct hashtable_t *hash; |
48 | 48 | ||
49 | hash = kmalloc(sizeof(struct hashtable_t), GFP_ATOMIC); | 49 | hash = kmalloc(sizeof(*hash), GFP_ATOMIC); |
50 | if (!hash) | 50 | if (!hash) |
51 | return NULL; | 51 | return NULL; |
52 | 52 | ||
53 | hash->table = kmalloc(sizeof(struct element_t *) * size, GFP_ATOMIC); | 53 | hash->table = kmalloc(sizeof(*hash->table) * size, GFP_ATOMIC); |
54 | if (!hash->table) | 54 | if (!hash->table) |
55 | goto free_hash; | 55 | goto free_hash; |
56 | 56 | ||
57 | hash->list_locks = kmalloc(sizeof(spinlock_t) * size, GFP_ATOMIC); | 57 | hash->list_locks = kmalloc(sizeof(*hash->list_locks) * size, |
58 | GFP_ATOMIC); | ||
58 | if (!hash->list_locks) | 59 | if (!hash->list_locks) |
59 | goto free_table; | 60 | goto free_table; |
60 | 61 | ||