All of lore.kernel.org
 help / color / mirror / Atom feed
From: zhong jiang <zhongjiang@huawei.com>
To: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc: <davem@davemloft.net>, <edumazet@google.com>,
	<kuznet@ms2.inr.ac.ru>, <yoshfuji@linux-ipv6.org>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] net: ipv4: Use BUG_ON directly instead of a if condition followed by BUG
Date: Tue, 11 Sep 2018 16:59:25 +0800	[thread overview]
Message-ID: <5B9783ED.4080908@huawei.com> (raw)
In-Reply-To: <a000b5a4-2907-70f9-70ed-7e1c6a797876@cogentembedded.com>

On 2018/9/11 16:51, Sergei Shtylyov wrote:
> On 9/10/2018 5:38 PM, zhong jiang wrote:
>
>> The if condition can be removed if we use BUG_ON directly.
>> The issule is detected with the help of Coccinelle.
>
>   Issue?
>
>>
>> Signed-off-by: zhong jiang <zhongjiang@huawei.com>
>> ---
>>   net/ipv4/tcp_input.c | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
>> index 62508a2..893bde3 100644
>> --- a/net/ipv4/tcp_input.c
>> +++ b/net/ipv4/tcp_input.c
>> @@ -4934,8 +4934,8 @@ void tcp_rbtree_insert(struct rb_root *root, struct sk_buff *skb)
>>               BUG_ON(offset < 0);
>>               if (size > 0) {
>>                   size = min(copy, size);
>> -                if (skb_copy_bits(skb, offset, skb_put(nskb, size), size))
>> -                    BUG();
>> +                BUG(skb_copy_bits(skb, offset,
>
>    You said BUG_ON()?
 Yep. Do you think that it is worthing to do

 Thanks,
zhong jiang
>
>> +                          skb_put(nskb, size), size));
>>                   TCP_SKB_CB(nskb)->end_seq += size;
>>                   copy -= size;
>>                   start += size;
>> @@ -5327,8 +5327,8 @@ static void tcp_urg(struct sock *sk, struct sk_buff *skb, const struct tcphdr *t
>>           /* Is the urgent pointer pointing into this packet? */
>>           if (ptr < skb->len) {
>>               u8 tmp;
>> -            if (skb_copy_bits(skb, ptr, &tmp, 1))
>> -                BUG();
>> +
>> +            BUG(skb_copy_bits(skb, ptr, &tmp, 1));
>
>    Likewise.
>
> [...]
>
> MBR, Sergei
>
> .
>



  reply	other threads:[~2018-09-11  8:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-10 14:38 [PATCH] net: ipv4: Use BUG_ON directly instead of a if condition followed by BUG zhong jiang
2018-09-10 15:39 ` Jiri Benc
2018-09-11  1:12   ` zhong jiang
2018-09-10 20:23 ` kbuild test robot
2018-09-10 21:20 ` kbuild test robot
2018-09-11  8:51 ` Sergei Shtylyov
2018-09-11  8:59   ` zhong jiang [this message]
2018-09-11  9:11     ` Sergei Shtylyov
2018-09-11  9:19       ` zhong jiang
2018-09-11  9:33         ` Sergei Shtylyov
2018-09-12  6:54 ` David Miller
2018-09-12 13:25   ` zhong jiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5B9783ED.4080908@huawei.com \
    --to=zhongjiang@huawei.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.