af_key: make use of BUG_ON macro
authorHariprasad Kelam <hariprasad.kelam@gmail.com>
Sat, 8 Jun 2019 09:00:50 +0000 (14:30 +0530)
committerDavid S. Miller <davem@davemloft.net>
Mon, 10 Jun 2019 02:56:42 +0000 (19:56 -0700)
fix below warnings reported by coccicheck

net/key/af_key.c:932:2-5: WARNING: Use BUG_ON instead of if condition
followed by BUG.
net/key/af_key.c:948:2-5: WARNING: Use BUG_ON instead of if condition
followed by BUG.

Signed-off-by: Hariprasad Kelam <hariprasad.kelam@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/key/af_key.c

index a50dd6f34b917c2609be28b634f6f90506a0f8a5..39b3d95094eb2fd4666097f4aa1ca2412a122005 100644 (file)
@@ -928,8 +928,7 @@ static struct sk_buff *__pfkey_xfrm_state2msg(const struct xfrm_state *x,
                pfkey_sockaddr_fill(&x->props.saddr, 0,
                                    (struct sockaddr *) (addr + 1),
                                    x->props.family);
-       if (!addr->sadb_address_prefixlen)
-               BUG();
+       BUG_ON(!addr->sadb_address_prefixlen);
 
        /* dst address */
        addr = skb_put(skb, sizeof(struct sadb_address) + sockaddr_size);
@@ -944,8 +943,7 @@ static struct sk_buff *__pfkey_xfrm_state2msg(const struct xfrm_state *x,
                pfkey_sockaddr_fill(&x->id.daddr, 0,
                                    (struct sockaddr *) (addr + 1),
                                    x->props.family);
-       if (!addr->sadb_address_prefixlen)
-               BUG();
+       BUG_ON(!addr->sadb_address_prefixlen);
 
        if (!xfrm_addr_equal(&x->sel.saddr, &x->props.saddr,
                             x->props.family)) {