From patchwork Mon Mar 25 12:49:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 161092 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3926941jan; Mon, 25 Mar 2019 05:49:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCh5ixxkBlRFwldybtd4HFH2rkc2zTO37+m0n3QoEt8xo514zd7pCcLyKl4jlwsviiIrhy X-Received: by 2002:a17:902:bf05:: with SMTP id bi5mr24203524plb.252.1553518188810; Mon, 25 Mar 2019 05:49:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553518188; cv=none; d=google.com; s=arc-20160816; b=tImMcIJf4k5z4optgff+jD9fffW3qr+LQ4e8T80dMXuD2fMbiYUjGkW3iMWBWLQSJF JIxdXftNhmVwon9Z8n8cqAhkUe+mK/npllKT23XJzwgzTYHqILQ4iQipqkzzkN/L3SZu GO/V/Do/jfuSwRDzUq0Seym0lREzzojlK84b8/+rLkIPvjekGR0lFcCuTBcUkyVzSDGU FS88TbdpKKj/HT8bacUw6aVonvo8HZ06+JKSDph7jrb2Q2L6YQAnUWIfNwKGVo0qwLLq JhnFI2OPj5/UTNOF2Lds33FOIAvLBpFXd7EBKEay4Uuo53Rt4osHeJuemjNxE9LYGxzu GVng== 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:mime-version :message-id:date:subject:cc:to:from; bh=qC7lj73R0rDS/hLuQkTn+8SCzJswBvB6fFqdVUn5yn4=; b=m9eSUZZxCHYwec9uTNSHw0SqfBD7kEoDpjCCGIb2NERDvfBcqzfwrqgnaWxEUT7h5Z kMxOLKByV0hiSzNtS4tlWMQHklktJpGJGANlhQsJliHkFwzXsGCeEJ21F32cFfmlPPwv Bh2MCARReHpmxD5Blf7asDc4itMRIfhLpa0H73WiQ2wrz+j1PIhWYfiOgFBYqYxKPz/c 0qMBpYLVGiU0RWkgNEU5qXBtM8j4ntH3ILMuCpSqYhVvhAkSk+mplQwMIIMNz5PteBZt AN+NCqtY6oVsijaVkFXxN0gWUVkF/H0nnfM2LTBpXkvRphMFfg1R1amR4NVfz5JXDsyQ NE3g== 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 e1si13685379pgm.45.2019.03.25.05.49.48; Mon, 25 Mar 2019 05:49:48 -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 S1731362AbfCYMtr (ORCPT + 31 others); Mon, 25 Mar 2019 08:49:47 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:43679 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731088AbfCYMtq (ORCPT ); Mon, 25 Mar 2019 08:49:46 -0400 Received: from wuerfel.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.129]) with ESMTPA (Nemesis) id 1MYNW6-1hUvqI2maA-00VPkJ; Mon, 25 Mar 2019 13:49:32 +0100 From: Arnd Bergmann To: Vishal Kulkarni , "David S. Miller" Cc: clang-built-linux@googlegroups.com, Nick Desaulniers , Nathan Chancellor , Arnd Bergmann , Ganesh Goudar , Casey Leedom , Rahul Lakkireddy , Arjun Vynipadath , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] chelsio: use BUG() instead of BUG_ON(1) Date: Mon, 25 Mar 2019 13:49:16 +0100 Message-Id: <20190325124930.1435409-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:PNTkGRuCd5wNhzroBHRqUL0XYRFAORHUb1U4ZwjFcxgkNSiS2LB rVcKnQH4LVKiDbYxw1e/7Gsd/nC5I7tg5SUjRhlZqqvd0tzPLSOHbuscZeG/yx/lvKueyjo rr3nGP2YXQnh6kayprJ+1hf8G2P4wMw8gdMhY5GWHN/HdXKuz7tCo+6vok8eNrC4y/g6HS2 PDs7QpBijpHhAxgmF5f7g== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:7DwBwJLjbCI=:4ROudwibWg1irKYwbIhP98 LUlgwQTKvCWSigbJOJ+h7n9vHGnhOSeF4ZirJvw+7DF9TvuDPpIMI+P5dZE0G/+EQ/1XdsFbi YFXcyLkH6HsCAIlb6Q9sq3H7ihDRulq6c1U8qYcbkzs9GbedMQn+Oge4AmssPDNeMSoSujYwl x2SssNGAb1jfiOdwT8qrG5SiaWu1QA4epTAxf8ovDPesMBI0opUuCRbOUnsg7rPsPr85pha8r FV/1G70/ywa/iIX/OTMi1D8Nu06ubkyfRDb47RH/nTpHgE+rGfh7+MbVT1EC99IARBoXr2DAO H+mRR3QKCVsXzyoTXniwGJAxNMlGODcrqvFIwEDZLZDTanIxwhIuRf1eeemxqAUMNVCmRkAZU ncNN3+DVuUNRePOyC2YXpRarHlVk44LlNcagdrnsMF0LOfo3PzHSPowaDIBV6LscOm0uCAg0e gYFHevJdHjLokyglFo+ixbbVZ3N1ZF4/pqWXzbLemkOetmPz0uw8c2agNEbjCn01cja4JGGI7 7pjzfb5D6V4jQ6uspYjXlRgABV5EwQ7AxmDavPilBS9DTUSJQ7aKStnk6NhamE+f0VK8nozpI CJMgIPWxCT+DEZqSG0qa0v8QVs7kEZBjLn2DJsaLyZ8FynUAerRTewTQ9j/42D3Zt5Z2SRNtr yasIDn02M7HHTKcBOHLuIx5kWJBDrhCAU1KycO1esZ1fA5uyRmq7jEwGZdKf/eMJ6JWl4luoK 3Izktbv7a/rGdF7/OUPtFd2Yt8nZUIIFezZ+bQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org clang warns about possible bugs in a dead code branch after BUG_ON(1) when CONFIG_PROFILE_ALL_BRANCHES is enabled: drivers/net/ethernet/chelsio/cxgb4/sge.c:479:3: error: variable 'buf_size' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] BUG_ON(1); ^~~~~~~~~ include/asm-generic/bug.h:61:36: note: expanded from macro 'BUG_ON' #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0) ^~~~~~~~~~~~~~~~~~~ include/linux/compiler.h:48:23: note: expanded from macro 'unlikely' # define unlikely(x) (__branch_check__(x, 0, __builtin_constant_p(x))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/ethernet/chelsio/cxgb4/sge.c:482:9: note: uninitialized use occurs here return buf_size; ^~~~~~~~ drivers/net/ethernet/chelsio/cxgb4/sge.c:479:3: note: remove the 'if' if its condition is always true BUG_ON(1); ^ include/asm-generic/bug.h:61:32: note: expanded from macro 'BUG_ON' #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0) ^ drivers/net/ethernet/chelsio/cxgb4/sge.c:459:14: note: initialize the variable 'buf_size' to silence this warning int buf_size; ^ = 0 Use BUG() here to create simpler code that clang understands correctly. Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 2 +- drivers/net/ethernet/chelsio/cxgb4/sge.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- 2.20.0 Reviewed-by: Nick Desaulniers diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c index 3130b43bba52..02959035ed3f 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c @@ -2620,7 +2620,7 @@ static inline struct port_info *ethqset2pinfo(struct adapter *adap, int qset) } /* should never happen! */ - BUG_ON(1); + BUG(); return NULL; } diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c index 88773ca58e6b..b3da81e90132 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c @@ -476,7 +476,7 @@ static inline int get_buf_size(struct adapter *adapter, break; default: - BUG_ON(1); + BUG(); } return buf_size;