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/gateway_client.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/gateway_client.c')
-rw-r--r-- | net/batman-adv/gateway_client.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index e9c7eb1a1f9d..a44dff3efb7f 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c | |||
@@ -273,7 +273,7 @@ static void gw_node_add(struct bat_priv *bat_priv, | |||
273 | struct gw_node *gw_node; | 273 | struct gw_node *gw_node; |
274 | int down, up; | 274 | int down, up; |
275 | 275 | ||
276 | gw_node = kzalloc(sizeof(struct gw_node), GFP_ATOMIC); | 276 | gw_node = kzalloc(sizeof(*gw_node), GFP_ATOMIC); |
277 | if (!gw_node) | 277 | if (!gw_node) |
278 | return; | 278 | return; |
279 | 279 | ||
@@ -508,7 +508,7 @@ int gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb) | |||
508 | /* check for ip header */ | 508 | /* check for ip header */ |
509 | switch (ntohs(ethhdr->h_proto)) { | 509 | switch (ntohs(ethhdr->h_proto)) { |
510 | case ETH_P_IP: | 510 | case ETH_P_IP: |
511 | if (!pskb_may_pull(skb, header_len + sizeof(struct iphdr))) | 511 | if (!pskb_may_pull(skb, header_len + sizeof(*iphdr))) |
512 | return 0; | 512 | return 0; |
513 | iphdr = (struct iphdr *)(skb->data + header_len); | 513 | iphdr = (struct iphdr *)(skb->data + header_len); |
514 | header_len += iphdr->ihl * 4; | 514 | header_len += iphdr->ihl * 4; |
@@ -519,10 +519,10 @@ int gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb) | |||
519 | 519 | ||
520 | break; | 520 | break; |
521 | case ETH_P_IPV6: | 521 | case ETH_P_IPV6: |
522 | if (!pskb_may_pull(skb, header_len + sizeof(struct ipv6hdr))) | 522 | if (!pskb_may_pull(skb, header_len + sizeof(*ipv6hdr))) |
523 | return 0; | 523 | return 0; |
524 | ipv6hdr = (struct ipv6hdr *)(skb->data + header_len); | 524 | ipv6hdr = (struct ipv6hdr *)(skb->data + header_len); |
525 | header_len += sizeof(struct ipv6hdr); | 525 | header_len += sizeof(*ipv6hdr); |
526 | 526 | ||
527 | /* check for udp header */ | 527 | /* check for udp header */ |
528 | if (ipv6hdr->nexthdr != IPPROTO_UDP) | 528 | if (ipv6hdr->nexthdr != IPPROTO_UDP) |
@@ -533,10 +533,10 @@ int gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb) | |||
533 | return 0; | 533 | return 0; |
534 | } | 534 | } |
535 | 535 | ||
536 | if (!pskb_may_pull(skb, header_len + sizeof(struct udphdr))) | 536 | if (!pskb_may_pull(skb, header_len + sizeof(*udphdr))) |
537 | return 0; | 537 | return 0; |
538 | udphdr = (struct udphdr *)(skb->data + header_len); | 538 | udphdr = (struct udphdr *)(skb->data + header_len); |
539 | header_len += sizeof(struct udphdr); | 539 | header_len += sizeof(*udphdr); |
540 | 540 | ||
541 | /* check for bootp port */ | 541 | /* check for bootp port */ |
542 | if ((ntohs(ethhdr->h_proto) == ETH_P_IP) && | 542 | if ((ntohs(ethhdr->h_proto) == ETH_P_IP) && |