Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2885314imm; Mon, 10 Sep 2018 07:52:26 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYIopyite8AcBbmNL2l0BtSx3JVQec/G440eNvnwgvpjBGFilVScJw9EYkcQOQzU6XepiuW X-Received: by 2002:a63:31c2:: with SMTP id x185-v6mr23162924pgx.373.1536591146797; Mon, 10 Sep 2018 07:52:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536591146; cv=none; d=google.com; s=arc-20160816; b=0HFLm2Lrb11ybE/8Nf30wJrzFaS+XgEV4iat360svAxvXIiCd203+TKW6GC2AOU0QE /eaI+bWfRFST4Fr8iA0e+YjowvedvRtY8N4upwLfX6v+v5dJscT2qup7TQh15TT1ALm9 zo7hEd0dzOx4jWpWbzmcdC0OSkdVfMhdfxd/DrRHj9vqpFrhD+oVQiT6KYVXfREQnXyU p5rvHJXUip4pCxBIhhEMcSSsoLGZcMsTcgL2fK1sOvQffOcbfUztQ/J3Cpcc9rSd4U/L VBXCbA4Qm805hyRBILSevcpZRMGhjIJdZah1wUcShzjRmCNAzAxmVwrVJcS6soxuT+s9 7ggw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=z5wd2NobysPqQWCk+eSKX7vU2in0yE6TOXq/PkDPkJA=; b=Fgsuxq8XKeKl8+RnEUkbWiXx+2IAPZUaJJQFj/Lku+rPTdTyxGnccGL96dTAC8prIe lSRjlz+h7/2ZH+g6S9tRsVXy5lBUe3HcEYHaIx7pdJw2AVP01bialf3OZoOH9YVGx1M2 zuWaRNU9AZRdzySb9YXjZvAfaXiAO+1iyDiJVwd82D0nfZz1FciDxgT+74Wpqob1i9Dj iW6b+egVfnRFLjfVVQZ4BeaFIaW2lH1YmZL2xQzEENuW7v+5uTmWKQCnN//0mjaz1Rvz omf7GB8llMH0Cjejqe2HD/r5yjvLAGDFZ/ob+gkqhsJwZgE00dztehQi+uY1O3VFa9jq F4tQ== 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 p14-v6si6277303plo.363.2018.09.10.07.52.11; Mon, 10 Sep 2018 07:52:26 -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 S1728839AbeIJTot (ORCPT + 99 others); Mon, 10 Sep 2018 15:44:49 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:33011 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728410AbeIJTot (ORCPT ); Mon, 10 Sep 2018 15:44:49 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id EF1FCD8621E7E; Mon, 10 Sep 2018 22:50:15 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.399.0; Mon, 10 Sep 2018 22:50:16 +0800 From: zhong jiang To: , CC: , , , Subject: [PATCH] net: ipv4: Use BUG_ON directly instead of a if condition followed by BUG Date: Mon, 10 Sep 2018 22:38:02 +0800 Message-ID: <1536590282-23899-1-git-send-email-zhongjiang@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The if condition can be removed if we use BUG_ON directly. The issule is detected with the help of Coccinelle. 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, + 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)); tp->urg_data = TCP_URG_VALID | tmp; if (!sock_flag(sk, SOCK_DEAD)) sk->sk_data_ready(sk); -- 1.7.12.4