Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2898878pxj; Mon, 17 May 2021 12:31:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNaFzFDpJqcNVZj8AodI8+Vid7jMQGTOjDZg8eb5Xn90Vpo8GI4f3X9XcmMl37R4xxV+VZ X-Received: by 2002:a17:906:b850:: with SMTP id ga16mr1556529ejb.161.1621279865153; Mon, 17 May 2021 12:31:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621279865; cv=none; d=google.com; s=arc-20160816; b=PnBf/qYlP6it7FyxXrXnXOEHhb10VdOPGM6lijZhP1hmTx3c0cnzDKHMUhTN9LmMPJ 1rtZwFuC89P544BC2//h6muQIX80fuHb4lVFeP5ftk5VVyzSo/nwg1YOFnVA9tawere3 l/Ko+gm49McoNKuIt9qkBSFcWgPK0GEcThQuoztAuy0e/k2YuwO2nxTelG8+cGN7VGCm O1es0NRCe3syIo77HCu+nd0j3eJBpm5JNMshL0peLdTPdEhTk30psYmxAuCGl7I5YbaH wY90+9+utqTgsYIOULkvNnzQp/7Aki812mDDemugGrupdx4EvwUs6Em9xmoDIXZRYvBo wzFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:date:message-id:subject:cc:to:from; bh=jybd5gNhH3hacUenyS9HSqUK0mAnwbQXNnjtNGosDV0=; b=sBYouOD7ADf4MB0Cfq3PnYWf//tJcNycyIVnMPqKsMkrSxPgkS5t8iP4ZR8YwkdttN RFerqEqTascAHLFdutxwqZamonFgE7o1IEhJMpr45rcFAglNqQUhs+n4P0iMm6R+Ne+s LdKc+brko0mA+t/MUq66Vr5B6A0iuJJKQJI+JbyKBp2YkNn/GOOn8c1/O1S6pfcNrgRB uEI1UDYQWlOA/T+BktODf9vC9KXz/aoT0ZIm+Gr4shz0jASK6AxBcKSjF+P0Gm3Sxdcx 7A6z6EfpGdi5jFMaMEawdsCjjFGl0B/tDrSpVDHSlCE14RanzgLbCbkiIY08GRkJdMrb ni6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jg28si14146107ejc.618.2021.05.17.12.30.40; Mon, 17 May 2021 12:31:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237306AbhEQNcj (ORCPT + 99 others); Mon, 17 May 2021 09:32:39 -0400 Received: from out30-54.freemail.mail.aliyun.com ([115.124.30.54]:54227 "EHLO out30-54.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236025AbhEQNci (ORCPT ); Mon, 17 May 2021 09:32:38 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R751e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=xianting.tian@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0UZA5KT9_1621258279; Received: from B-LB6YLVDL-0141.local(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0UZA5KT9_1621258279) by smtp.aliyun-inc.com(127.0.0.1); Mon, 17 May 2021 21:31:20 +0800 From: Xianting Tian To: mst@redhat.com, jasowang@redhat.com, davem@davemloft.net, kuba@kernel.org Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] virtio_net: Use BUG_ON instead of if condition followed by BUG Message-ID: <56270996-33a6-d71b-d935-452dad121df7@linux.alibaba.com> Date: Mon, 17 May 2021 21:31:19 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org BUG_ON() uses unlikely in if(), which can be optimized at compile time. Signed-off-by: Xianting Tian --- drivers/net/virtio_net.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index c921ebf3ae82..212d52204884 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -1646,10 +1646,9 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb) else hdr = skb_vnet_hdr(skb); - if (virtio_net_hdr_from_skb(skb, &hdr->hdr, + BUG_ON(virtio_net_hdr_from_skb(skb, &hdr->hdr, virtio_is_little_endian(vi->vdev), false, - 0)) - BUG(); + 0)); if (vi->mergeable_rx_bufs) hdr->num_buffers = 0; -- 2.17.1