aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/soft-interface.c
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2011-05-14 17:14:54 -0400
committerSven Eckelmann <sven@narfation.org>2011-05-30 01:39:33 -0400
commit704509b8d44886cebfbaff1a9813c35dfa986954 (patch)
tree7b353f1d4a33b31d55d2a85f8d70882ade1868ce /net/batman-adv/soft-interface.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/soft-interface.c')
-rw-r--r--net/batman-adv/soft-interface.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 1bec3a0f9721..cead606008a1 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -123,8 +123,7 @@ static struct softif_neigh_vid *softif_neigh_vid_get(struct bat_priv *bat_priv,
123 goto out; 123 goto out;
124 } 124 }
125 125
126 softif_neigh_vid = kzalloc(sizeof(struct softif_neigh_vid), 126 softif_neigh_vid = kzalloc(sizeof(*softif_neigh_vid), GFP_ATOMIC);
127 GFP_ATOMIC);
128 if (!softif_neigh_vid) 127 if (!softif_neigh_vid)
129 goto out; 128 goto out;
130 129
@@ -170,7 +169,7 @@ static struct softif_neigh *softif_neigh_get(struct bat_priv *bat_priv,
170 goto unlock; 169 goto unlock;
171 } 170 }
172 171
173 softif_neigh = kzalloc(sizeof(struct softif_neigh), GFP_ATOMIC); 172 softif_neigh = kzalloc(sizeof(*softif_neigh), GFP_ATOMIC);
174 if (!softif_neigh) 173 if (!softif_neigh)
175 goto unlock; 174 goto unlock;
176 175
@@ -611,7 +610,7 @@ int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
611 if (!primary_if) 610 if (!primary_if)
612 goto dropped; 611 goto dropped;
613 612
614 if (my_skb_head_push(skb, sizeof(struct bcast_packet)) < 0) 613 if (my_skb_head_push(skb, sizeof(*bcast_packet)) < 0)
615 goto dropped; 614 goto dropped;
616 615
617 bcast_packet = (struct bcast_packet *)skb->data; 616 bcast_packet = (struct bcast_packet *)skb->data;
@@ -790,7 +789,7 @@ static void interface_setup(struct net_device *dev)
790 789
791 SET_ETHTOOL_OPS(dev, &bat_ethtool_ops); 790 SET_ETHTOOL_OPS(dev, &bat_ethtool_ops);
792 791
793 memset(priv, 0, sizeof(struct bat_priv)); 792 memset(priv, 0, sizeof(*priv));
794} 793}
795 794
796struct net_device *softif_create(const char *name) 795struct net_device *softif_create(const char *name)
@@ -799,8 +798,7 @@ struct net_device *softif_create(const char *name)
799 struct bat_priv *bat_priv; 798 struct bat_priv *bat_priv;
800 int ret; 799 int ret;
801 800
802 soft_iface = alloc_netdev(sizeof(struct bat_priv) , name, 801 soft_iface = alloc_netdev(sizeof(*bat_priv), name, interface_setup);
803 interface_setup);
804 802
805 if (!soft_iface) { 803 if (!soft_iface) {
806 pr_err("Unable to allocate the batman interface: %s\n", name); 804 pr_err("Unable to allocate the batman interface: %s\n", name);