summaryrefslogtreecommitdiffstats
path: root/net/batman-adv/send.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/send.c
parent958ca5985604a6f13387d32de489365df816558b (diff)
downloadlinux-704509b8d44886cebfbaff1a9813c35dfa986954.tar.bz2
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/send.c')
-rw-r--r--net/batman-adv/send.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index 9a20ba9e056f..d0cfa95e3037 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -73,7 +73,7 @@ int send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface,
}
/* push to the ethernet header. */
- if (my_skb_head_push(skb, sizeof(struct ethhdr)) < 0)
+ if (my_skb_head_push(skb, sizeof(*ethhdr)) < 0)
goto send_skb_err;
skb_reset_mac_header(skb);
@@ -144,7 +144,7 @@ static void send_packet_to_if(struct forw_packet *forw_packet,
hard_iface->net_dev->name,
hard_iface->net_dev->dev_addr);
- buff_pos += sizeof(struct batman_packet) +
+ buff_pos += sizeof(*batman_packet) +
(batman_packet->num_tt * ETH_ALEN);
packet_num++;
batman_packet = (struct batman_packet *)
@@ -220,19 +220,18 @@ static void rebuild_batman_packet(struct bat_priv *bat_priv,
unsigned char *new_buff;
struct batman_packet *batman_packet;
- new_len = sizeof(struct batman_packet) +
- (bat_priv->num_local_tt * ETH_ALEN);
+ new_len = sizeof(*batman_packet) + (bat_priv->num_local_tt * ETH_ALEN);
new_buff = kmalloc(new_len, GFP_ATOMIC);
/* keep old buffer if kmalloc should fail */
if (new_buff) {
memcpy(new_buff, hard_iface->packet_buff,
- sizeof(struct batman_packet));
+ sizeof(*batman_packet));
batman_packet = (struct batman_packet *)new_buff;
batman_packet->num_tt = tt_local_fill_buffer(bat_priv,
- new_buff + sizeof(struct batman_packet),
- new_len - sizeof(struct batman_packet));
+ new_buff + sizeof(*batman_packet),
+ new_len - sizeof(*batman_packet));
kfree(hard_iface->packet_buff);
hard_iface->packet_buff = new_buff;
@@ -368,7 +367,7 @@ void schedule_forward_packet(struct orig_node *orig_node,
send_time = forward_send_time();
add_bat_packet_to_list(bat_priv,
(unsigned char *)batman_packet,
- sizeof(struct batman_packet) + tt_buff_len,
+ sizeof(*batman_packet) + tt_buff_len,
if_incoming, 0, send_time);
}
@@ -424,7 +423,7 @@ int add_bcast_packet_to_list(struct bat_priv *bat_priv,
if (!primary_if)
goto out_and_inc;
- forw_packet = kmalloc(sizeof(struct forw_packet), GFP_ATOMIC);
+ forw_packet = kmalloc(sizeof(*forw_packet), GFP_ATOMIC);
if (!forw_packet)
goto out_and_inc;