From b080db585384b9f037e015c0c28d1ad33be41dfc Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 16 Jun 2017 14:29:19 +0200 Subject: networking: convert many more places to skb_put_zero() There were many places that my previous spatch didn't find, as pointed out by yuan linyu in various patches. The following spatch found many more and also removes the now unnecessary casts: @@ identifier p, p2; expression len; expression skb; type t, t2; @@ ( -p = skb_put(skb, len); +p = skb_put_zero(skb, len); | -p = (t)skb_put(skb, len); +p = skb_put_zero(skb, len); ) ... when != p ( p2 = (t2)p; -memset(p2, 0, len); | -memset(p, 0, len); ) @@ type t, t2; identifier p, p2; expression skb; @@ t *p; ... ( -p = skb_put(skb, sizeof(t)); +p = skb_put_zero(skb, sizeof(t)); | -p = (t *)skb_put(skb, sizeof(t)); +p = skb_put_zero(skb, sizeof(t)); ) ... when != p ( p2 = (t2)p; -memset(p2, 0, sizeof(*p)); | -memset(p, 0, sizeof(*p)); ) @@ expression skb, len; @@ -memset(skb_put(skb, len), 0, len); +skb_put_zero(skb, len); Apply it to the tree (with one manual fixup to keep the comment in vxlan.c, which spatch removed.) Signed-off-by: Johannes Berg Signed-off-by: David S. Miller --- net/qrtr/qrtr.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'net/qrtr/qrtr.c') diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index c7a5d861906b..825f97671591 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -285,8 +285,7 @@ static struct sk_buff *qrtr_alloc_resume_tx(u32 src_node, if (!skb) return NULL; - buf = (__le32 *)skb_put(skb, pkt_len); - memset(buf, 0, pkt_len); + buf = skb_put_zero(skb, pkt_len); buf[0] = cpu_to_le32(QRTR_TYPE_RESUME_TX); buf[1] = cpu_to_le32(src_node); buf[2] = cpu_to_le32(port); @@ -306,8 +305,7 @@ static struct sk_buff *qrtr_alloc_local_bye(u32 src_node) if (!skb) return NULL; - buf = (__le32 *)skb_put(skb, pkt_len); - memset(buf, 0, pkt_len); + buf = skb_put_zero(skb, pkt_len); buf[0] = cpu_to_le32(QRTR_TYPE_BYE); return skb; @@ -324,8 +322,7 @@ static struct sk_buff *qrtr_alloc_del_client(struct sockaddr_qrtr *sq) if (!skb) return NULL; - buf = (__le32 *)skb_put(skb, pkt_len); - memset(buf, 0, pkt_len); + buf = skb_put_zero(skb, pkt_len); buf[0] = cpu_to_le32(QRTR_TYPE_DEL_CLIENT); buf[1] = cpu_to_le32(sq->sq_node); buf[2] = cpu_to_le32(sq->sq_port); -- cgit v1.2.3