From mboxrd@z Thu Jan 1 00:00:00 1970 From: zhong jiang 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 Message-ID: <5B9783ED.4080908@huawei.com> References: <1536590282-23899-1-git-send-email-zhongjiang@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: , , , , , To: Sergei Shtylyov Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org 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 >> --- >> 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 > > . >