diff mbox

[4/9,net-next] ipv6: replace if/BUG by BUG_ON

Message ID 1427749998-28464-4-git-send-email-fabf@skynet.be
State Awaiting Upstream
Delegated to: Pablo Neira
Headers show

Commit Message

Fabian Frederick March 30, 2015, 9:13 p.m. UTC
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 net/ipv6/addrconf.c                     | 3 +--
 net/ipv6/esp6.c                         | 3 +--
 net/ipv6/netfilter/nf_conntrack_reasm.c | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

Comments

Hideaki Yoshifuji March 31, 2015, 3:50 a.m. UTC | #1
Hi,

Fabian Frederick wrote:
> Signed-off-by: Fabian Frederick <fabf@skynet.be>
> ---
>  net/ipv6/addrconf.c                     | 3 +--
>  net/ipv6/esp6.c                         | 3 +--
>  net/ipv6/netfilter/nf_conntrack_reasm.c | 3 +--
>  3 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index 2660263..e205918 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -4805,8 +4805,7 @@ static int inet6_set_link_af(struct net_device *dev, const struct nlattr *nla)
>  	if (!idev)
>  		return -EAFNOSUPPORT;
>  
> -	if (nla_parse_nested(tb, IFLA_INET6_MAX, nla, NULL) < 0)
> -		BUG();
> +	BUG_ON(nla_parse_nested(tb, IFLA_INET6_MAX, nla, NULL) < 0);
>  

NACK, I do not prefer using BUG_ON() with side effects.

--yoshfuji

>  	if (tb[IFLA_INET6_TOKEN]) {
>  		err = inet6_set_iftoken(idev, nla_data(tb[IFLA_INET6_TOKEN]));
> diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
> index e48f2c7..9e51b69 100644
> --- a/net/ipv6/esp6.c
> +++ b/net/ipv6/esp6.c
> @@ -280,8 +280,7 @@ static int esp_input_done2(struct sk_buff *skb, int err)
>  	if (unlikely(err))
>  		goto out;
>  
> -	if (skb_copy_bits(skb, skb->len - alen - 2, nexthdr, 2))
> -		BUG();
> +	BUG_ON(skb_copy_bits(skb, skb->len - alen - 2, nexthdr, 2));
>  
>  	err = -EINVAL;
>  	padlen = nexthdr[0];
> diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
> index 6f187c8..cea1a4a 100644
> --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
> +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
> @@ -538,8 +538,7 @@ find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff)
>  			pr_debug("too short\n");
>  			return -1;
>  		}
> -		if (skb_copy_bits(skb, start, &hdr, sizeof(hdr)))
> -			BUG();
> +		BUG_ON(skb_copy_bits(skb, start, &hdr, sizeof(hdr)));
>  		if (nexthdr == NEXTHDR_AUTH)
>  			hdrlen = (hdr.hdrlen+2)<<2;
>  		else
>
David Miller March 31, 2015, 3:17 p.m. UTC | #2
From: YOSHIFUJI Hideaki <hideaki.yoshifuji@miraclelinux.com>
Date: Tue, 31 Mar 2015 12:50:27 +0900

> Hi,
> 
> Fabian Frederick wrote:
>> Signed-off-by: Fabian Frederick <fabf@skynet.be>
>> ---
>>  net/ipv6/addrconf.c                     | 3 +--
>>  net/ipv6/esp6.c                         | 3 +--
>>  net/ipv6/netfilter/nf_conntrack_reasm.c | 3 +--
>>  3 files changed, 3 insertions(+), 6 deletions(-)
>> 
>> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
>> index 2660263..e205918 100644
>> --- a/net/ipv6/addrconf.c
>> +++ b/net/ipv6/addrconf.c
>> @@ -4805,8 +4805,7 @@ static int inet6_set_link_af(struct net_device *dev, const struct nlattr *nla)
>>  	if (!idev)
>>  		return -EAFNOSUPPORT;
>>  
>> -	if (nla_parse_nested(tb, IFLA_INET6_MAX, nla, NULL) < 0)
>> -		BUG();
>> +	BUG_ON(nla_parse_nested(tb, IFLA_INET6_MAX, nla, NULL) < 0);
>>  
> 
> NACK, I do not prefer using BUG_ON() with side effects.

Agreed, I do not like these changes at all and will not be
applying them.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Fabian Frederick April 3, 2015, 8:02 p.m. UTC | #3
> On 31 March 2015 at 17:17 David Miller <davem@davemloft.net> wrote:
>
>
> From: YOSHIFUJI Hideaki <hideaki.yoshifuji@miraclelinux.com>
> Date: Tue, 31 Mar 2015 12:50:27 +0900
>
> > Hi,
> >
> > Fabian Frederick wrote:
> >> Signed-off-by: Fabian Frederick <fabf@skynet.be>
> >> ---
> >>  net/ipv6/addrconf.c                     | 3 +--
> >>  net/ipv6/esp6.c                         | 3 +--
> >>  net/ipv6/netfilter/nf_conntrack_reasm.c | 3 +--
> >>  3 files changed, 3 insertions(+), 6 deletions(-)
> >>
> >> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> >> index 2660263..e205918 100644
> >> --- a/net/ipv6/addrconf.c
> >> +++ b/net/ipv6/addrconf.c
> >> @@ -4805,8 +4805,7 @@ static int inet6_set_link_af(struct net_device *dev,
> >> const struct nlattr *nla)
> >>    if (!idev)
> >>            return -EAFNOSUPPORT;
> >> 
> >> -  if (nla_parse_nested(tb, IFLA_INET6_MAX, nla, NULL) < 0)
> >> -          BUG();
> >> +  BUG_ON(nla_parse_nested(tb, IFLA_INET6_MAX, nla, NULL) < 0);
> >> 
> >
> > NACK, I do not prefer using BUG_ON() with side effects.
>
> Agreed, I do not like these changes at all and will not be
> applying them.

I guess patches like these should be reverted then ?

e3f0b86b996d
"ipv6: Use BUG_ON"

8242fc33925c
"net: ipv6: Use BUG_ON"

Some existing BUG_ON() as well ? ; eg second one in net/decnet/dn_rules.c:
void __init dn_fib_rules_init(void)
{
        dn_fib_rules_ops =
                fib_rules_register(&dn_fib_rules_ops_template, &init_net);
        BUG_ON(IS_ERR(dn_fib_rules_ops));
        BUG_ON(fib_default_rule_add(dn_fib_rules_ops, 0x7fff,
                                    RT_TABLE_MAIN, 0));
}

Regards,
Fabian
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 2660263..e205918 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -4805,8 +4805,7 @@  static int inet6_set_link_af(struct net_device *dev, const struct nlattr *nla)
 	if (!idev)
 		return -EAFNOSUPPORT;
 
-	if (nla_parse_nested(tb, IFLA_INET6_MAX, nla, NULL) < 0)
-		BUG();
+	BUG_ON(nla_parse_nested(tb, IFLA_INET6_MAX, nla, NULL) < 0);
 
 	if (tb[IFLA_INET6_TOKEN]) {
 		err = inet6_set_iftoken(idev, nla_data(tb[IFLA_INET6_TOKEN]));
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index e48f2c7..9e51b69 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -280,8 +280,7 @@  static int esp_input_done2(struct sk_buff *skb, int err)
 	if (unlikely(err))
 		goto out;
 
-	if (skb_copy_bits(skb, skb->len - alen - 2, nexthdr, 2))
-		BUG();
+	BUG_ON(skb_copy_bits(skb, skb->len - alen - 2, nexthdr, 2));
 
 	err = -EINVAL;
 	padlen = nexthdr[0];
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index 6f187c8..cea1a4a 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -538,8 +538,7 @@  find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff)
 			pr_debug("too short\n");
 			return -1;
 		}
-		if (skb_copy_bits(skb, start, &hdr, sizeof(hdr)))
-			BUG();
+		BUG_ON(skb_copy_bits(skb, start, &hdr, sizeof(hdr)));
 		if (nexthdr == NEXTHDR_AUTH)
 			hdrlen = (hdr.hdrlen+2)<<2;
 		else