Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3787507imm; Tue, 11 Sep 2018 01:59:54 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdae3hEiZ/m9gIh/W0k/yQUM1i4PV9PqofM0oJ41tKW8DHK5NlIts23IHoio2bhDwBmyOy/1 X-Received: by 2002:a63:1618:: with SMTP id w24-v6mr27631973pgl.43.1536656394177; Tue, 11 Sep 2018 01:59:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536656394; cv=none; d=google.com; s=arc-20160816; b=a7LU3AOJlxfs2yPqpVjVc1amqJ3Vg+M7kyoivBIxUrSxYuOiwXz7OIKzdyJWnlwDHX 6nnVof2Rv/TKgDQ+yKXYUD+v4rBYTH6eZ00HX/jjRNz+DqLK+Zy/9zsGmm5ofCCuYhI1 gG9VJk5SW20qKMlR5VCwokLtR/wzTiAczvv5mFJKYLYzJp6rIgI+A5PpO7sW9MVpZU8s wrEKki58FJwcAtFZ4I2rfPF9jAsf07NPaMR0P73oG/KYQ06NP6Qs+C6LNqZHQDHYEbTX E3SeCG+r4oqdWs+fYTvCS48Ie8Giyv+5rPvgzlWx3NNEXYQqO3DlXo3uTLP6j57LS8WY 8L7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :references:subject:cc:to:mime-version:user-agent:from:date :message-id; bh=9wyxHkKWSre4YqbfT47KwjdUFyd+Izk2QCUtnNoAhWs=; b=SpcFMas7T8A89G4oiEg6fttmjGfzascJU0JQPgV2cM6l1uA3dh1VC3r36jSWvm72wv JTX7cHG9sjsIu5gAUb1bom+XXAV5N6xWyPVkZ2RPDpN9EHwEkBdplOsIZUovozo52X9P 9qsb2tfLsskVc+o1ILWsEeXp9wBGmQAE7LOO/9UqzqIGATXxIZhjk1GVApHjvNG7aC24 drusH/iu9VXOlezfHhi9SfdRl1ZoQBqVzAFqEW25g3IrCA+pfZkkOhVszBJxNW153RPN ZuB2E1Kn9fCLHlOBbZpsZvgnT4iTBkF+2C1j52V08xwDeXleWA3roEzZkh9l+UDeWOql TRKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5-v6si20613077pgc.210.2018.09.11.01.59.38; Tue, 11 Sep 2018 01:59:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726617AbeIKN5x (ORCPT + 99 others); Tue, 11 Sep 2018 09:57:53 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:40923 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726488AbeIKN5w (ORCPT ); Tue, 11 Sep 2018 09:57:52 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 896C75D99C99E; Tue, 11 Sep 2018 16:59:29 +0800 (CST) Received: from [127.0.0.1] (10.177.29.68) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.399.0; Tue, 11 Sep 2018 16:59:26 +0800 Message-ID: <5B9783ED.4080908@huawei.com> Date: Tue, 11 Sep 2018 16:59:25 +0800 From: zhong jiang User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Sergei Shtylyov CC: , , , , , Subject: Re: [PATCH] net: ipv4: Use BUG_ON directly instead of a if condition followed by BUG References: <1536590282-23899-1-git-send-email-zhongjiang@huawei.com> In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.29.68] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 > > . >