Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2427376yba; Thu, 25 Apr 2019 16:38:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+1OG1gEnRfabb4ACWG5MCeDjsYSf7j/xN+oJtv/8i1PUhBPGE/b0u4OPi1TjwG0JAZ2kF X-Received: by 2002:a63:1558:: with SMTP id 24mr21415667pgv.126.1556235483304; Thu, 25 Apr 2019 16:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556235483; cv=none; d=google.com; s=arc-20160816; b=XKb32VCJLtbwR5kGs5uwINKOPLa0Mlq/XKqsq0/VazZwg0Sna8c2C9B8u1NICxh01G nfQhLO2mY/jpvu22QGhAJqOU9tN7Zsg1tVmbOeqv0TeJCpk26iDir9zp7CpzpPMIF+6c J96I13NiB7DiRg5JFrBo4lQfnA0BE48gKvJ4D4rmbWO2Hn9kNvvXbeOHe7q5yY7e3uQF waE0UtpPiu++s1ied3DnyAzxgTDp5PP0hIixH9kDzTbTSRFI5FSpkDeB7PeURXjGYE8o Gy7Iu1IFSLxrjD4vYrhyXUwiethvi6ivmjREVEwm1Y0AJlQaRp8xrvpv9Xp7fbBX1wSh A8pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=hzyf0v4+qorHObxQJIarsmYBRGRmN6zpccuNNSL44OU=; b=j7FTzDSuoYZL6cVkc9Geet+xueILsOS9fV/0RiXqckijnT12JXusGRHK4oGJeMh0kE S0MsQJI/8B/AMcaP/z3kC9hFSiMkv2UKrgjwYz7KdwzPZZxNtb8gFjrM8JU/xuO7vatF XphIuDIMTCBqymvU+Ahq1+5pHm59TiosXKViXekpZliw4aNUIbCIsnZqi1MhtHB2zO/e j18fxNT80CV2VWWI9p71vYPjuvbXblwnT1DvMzKIhhoFrEPm9e/hQCCXHzkoeG1QVVt6 ePg11TCxGHwPIZjzuCCavfLwegYvLh7vC9ATQPk/IGJl3jHEDhT73aTggEv/cILAsbV7 W9MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=VVf3dTts; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h20si21803835pgv.352.2019.04.25.16.37.39; Thu, 25 Apr 2019 16:38:03 -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; dkim=pass header.i=@broadcom.com header.s=google header.b=VVf3dTts; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730579AbfDYSdQ (ORCPT + 99 others); Thu, 25 Apr 2019 14:33:16 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:45238 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726674AbfDYSdQ (ORCPT ); Thu, 25 Apr 2019 14:33:16 -0400 Received: by mail-yw1-f67.google.com with SMTP id r139so245732ywe.12 for ; Thu, 25 Apr 2019 11:33:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hzyf0v4+qorHObxQJIarsmYBRGRmN6zpccuNNSL44OU=; b=VVf3dTtsKaAfXBPBmVkoppyV2gw2xq6TYANFWb+6Vq5JFwilh3+tFe1/CG3OPPJkP6 ruIfynbny0jjANfyWol12KMILx292VUx3a6BYRhTqG+Gh25Je6Zgv+QQyd7YelJCgYrM 892XfsDOzraUvmp/rYU4O3fkw0CMCmp8mhbuM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hzyf0v4+qorHObxQJIarsmYBRGRmN6zpccuNNSL44OU=; b=EXJk7zIYEKzBq3lpDJ430MzIY/6JIl/qsrragPxmRgwbPTbRPwAxWo1zkJ17NShxkm 0abeHslKRBKxA2cPi240dsbEl++6L4mEDAFT7XzG8kDgtfbxvHmhwXgbju/7/53QX1A4 cL+lxYTscyvHAyFbG9Dtq7IS1oTmOaqHXF+3f4mb5xf4K7XNMHDQHSOhRaaQzr28fVaJ DCQh3CN0JD/nV0RVJ2udbPbJkMvuuAxxBmUBnezksdr1d7XvLT0+tGnLkgYAiP8v6sC4 hPOXbkOrShCkuEPe2Xud/IY1LGYhEpuu4sKnybFCGBN1ZXB3221I35SiTKcdwu7+TL+K azMA== X-Gm-Message-State: APjAAAXe0FJchwgbYq96OJMY1wdUEWMosDfpDqyiG/y/mdlXIyrs5nHC KONwdhi0w//agxn9H38D0kEU/rHzDY9NtZYT9P2p2w== X-Received: by 2002:a81:7009:: with SMTP id l9mr32009686ywc.306.1556217195233; Thu, 25 Apr 2019 11:33:15 -0700 (PDT) MIME-Version: 1.0 References: <20190308005735.GA4122@archlinux-ryzen> <20190320190849.GB28744@archlinux-ryzen> <20190425181411.GB4507@archlinux-i9> In-Reply-To: <20190425181411.GB4507@archlinux-i9> From: Michael Chan Date: Thu, 25 Apr 2019 11:33:04 -0700 Message-ID: Subject: Re: -Wsometimes-uninitialized Clang warning in drivers/net/ethernet/broadcom/bnxt/bnxt.c To: Nathan Chancellor Cc: Arnd Bergmann , Nick Desaulniers , "David S. Miller" , Networking , LKML , clang-built-linux@googlegroups.com, Eddie Wai , "jeffrey.huang@broadcom.com" , "prashant.sreedharan@broadcom.com" , "michael.chan@broadcom.com" , Vasundhara Volam Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 25, 2019 at 11:14 AM Nathan Chancellor wrote: > > Hi Arnd, > > On Fri, Mar 22, 2019 at 03:32:50PM +0100, Arnd Bergmann wrote: > > On Wed, Mar 20, 2019 at 9:41 PM 'Nick Desaulniers' via Clang Built > > Linux wrote: > > > > > > + Broadcom folks from commit c0c050c58d84 ("bnxt_en: New Broadcom > > > ethernet driver."). Looks like Michael wrote and is still maintaining > > > the driver. > > > > > > On Wed, Mar 20, 2019 at 12:08 PM Nathan Chancellor > > > wrote: > > > > > > > > On Thu, Mar 07, 2019 at 05:57:35PM -0700, Nathan Chancellor wrote: > > > > > Hi all, > > > > > > > > > > We are trying to get Clang's -Wsometimes-uninitialized turned on for the > > > > > kernel as it can catch some bugs that GCC can't. This warning came up: > > > > > > > > > > drivers/net/ethernet/broadcom/bnxt/bnxt.c:1612:6: warning: variable 'len' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] > > > > > if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L2_ERRORS) { > > > > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > > drivers/net/ethernet/broadcom/bnxt/bnxt.c:1703:19: note: uninitialized use occurs here > > > > > cpr->rx_bytes += len; > > > > > ^~~ > > > > > drivers/net/ethernet/broadcom/bnxt/bnxt.c:1612:2: note: remove the 'if' if its condition is always false > > > > > if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L2_ERRORS) { > > > > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > > drivers/net/ethernet/broadcom/bnxt/bnxt.c:1540:18: note: initialize the variable 'len' to silence this warning > > > > > unsigned int len; > > > > > ^ > > > > > = 0 > > > > > 1 warning generated. > > > > > > > > > > It seems like the logical change to make is this; however, I am not sure > > > > > if this has any other unintended consequences since this is a rather > > > > > dense function. I would much appreciate your input, especially if there > > > > > is a better way to fix it. > > > > > > I agree that `goto next_rx_no_prod_no_len` appears to be most correct; > > > though I don't understand why this function is a mix of early return > > > codes, vs setting rc then updating *raw_cons. The alternative is > > > probably zero initializing len, but I'm not sure whether *raw_cons > > > should be updated in that case or not. Thanks for bringing this up > > > and the patch. Sorry for the delay in review. Can folks at Broadcom > > > please clarify? Sorry, I somehow missed this email earlier. "goto next_rx_no_prod_no_len" is the most correct fix. The "cpr->rx_bytes += len" logic was added about a year ago when we added the DIM (Dynamic Interrupt Moderation) support and we missed fixing this goto. I can prepare and send the patch later today. Thanks.