Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp797605ybh; Sat, 18 Jul 2020 22:34:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzO7DX/zdALyEIfPiq4ly2bHT0vEVNXN4eqFqCKCL8ubmcy3naIXI8e+q7cEnS6LyuRUmNu X-Received: by 2002:a17:906:4f82:: with SMTP id o2mr15907585eju.424.1595136897870; Sat, 18 Jul 2020 22:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595136897; cv=none; d=google.com; s=arc-20160816; b=j5EnOQLMDMJ33dkluOJ4nHIjKfbzpF6u1rfkAA/G91VkpjiReXVPNyS1FZTh5qIYKR yfHB52Mt9BGAEigUEPi0QNY/3cY1PLBGOx8rQT5a8VsmZclSeMiRD7G/TH3tSMCLJA9g unskifLLG+wjoSbVwKqjDfp9HTzJH7gzkGglxy/Y4/v0ZrnbzdKfBse/oRIBKSJvem04 mx7VRGrtx0UdYksxS+T8z74C92/z5GKlUgriL79Zy+FDIskNRYGgCFlSXa76fYxSo147 h1+iZI7zjxw5tJFGQbRQiEwJ7+XfjDeMZcSpGdwcSgB/zKrrpZ7utcKRM7cnF3iq26Ie gc8w== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=E5HM9ZU5YJ7wzVn+qfhyQD/VktLrurnWVxK8lMqOFUI=; b=g/n1sEGqmxRjbdAh4iqDx9PmofzCjI4eKqJ6tnqD4IdsXbL40eOa2mYsxVZ3cf7Sok DkjN5mGymcIl1t/qdbwr9CPuGXe4NnMpI01a85N/nJKXoMfpW/73NJBXbbmaxz/KtJKP bTpVasGUTfu7d+s5zUbSdUNVF2+Omxb13iWUHSOTMpWAN00qBfXRbaOCPJC+xNmmDFc2 qc3mXtl8nE5pzUt13RVYfzJxwn42i3LssBn8GSfad34MgOdqj7GZ/X0OSZATTEH02e9k BKQkvcdvaceARecdulao7VS8f9x51IPxsKjSTvDt3jKfsTFHScKAhwtTeA7+yqT3NALU jaQg== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r23si8212890eja.287.2020.07.18.22.34.31; Sat, 18 Jul 2020 22:34:57 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726225AbgGSFeR (ORCPT + 99 others); Sun, 19 Jul 2020 01:34:17 -0400 Received: from mga17.intel.com ([192.55.52.151]:36650 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725783AbgGSFeQ (ORCPT ); Sun, 19 Jul 2020 01:34:16 -0400 IronPort-SDR: SKTYMHO07hzyfJ5TiMoBf+t7p7CoRGY/e+fAhxhY6QeRokTQypCGrRhtdByGuQpXN2ZXSexRC7 HsiJ/xu0cbFQ== X-IronPort-AV: E=McAfee;i="6000,8403,9686"; a="129865719" X-IronPort-AV: E=Sophos;i="5.75,369,1589266800"; d="scan'208";a="129865719" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2020 22:34:15 -0700 IronPort-SDR: FXW1Ac7iCitpqkwhFvTSn54O81Pc62W1bjCaB9G8zwy97xDiluuZbiRJb2PRtHwllONbbVj6kR IbZFJPomRm6g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,369,1589266800"; d="scan'208";a="269858023" Received: from sneftin-mobl.ger.corp.intel.com (HELO [10.249.88.79]) ([10.249.88.79]) by fmsmga007.fm.intel.com with ESMTP; 18 Jul 2020 22:34:13 -0700 Subject: Re: [Intel-wired-lan] [PATCH] igc: Do not use link uninitialized in igc_check_for_copper_link To: Nathan Chancellor Cc: Jeff Kirsher , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, intel-wired-lan@lists.osuosl.org, Jakub Kicinski , "David S. Miller" , "Lifshits, Vitaly" , "Nguyen, Anthony L" , "Neftin, Sasha" References: <20200716044934.152364-1-natechancellor@gmail.com> <20200717021235.GA4098394@ubuntu-n2-xlarge-x86> From: "Neftin, Sasha" Message-ID: <96131050-57e4-934a-3d9a-a285f234e633@intel.com> Date: Sun, 19 Jul 2020 08:34:12 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200717021235.GA4098394@ubuntu-n2-xlarge-x86> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/17/2020 05:12, Nathan Chancellor wrote: > On Thu, Jul 16, 2020 at 07:29:03PM +0300, Neftin, Sasha wrote: >> On 7/16/2020 07:49, Nathan Chancellor wrote: >>> Clang warns: >>> >> Hello Nathan, >> Thanks for tracking our code.Please, look at https://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200709073416.14126-1-sasha.neftin@intel.com/ >> - I hope this patch already address this Clang warns - please, let me know. > > I have not explicitly tested it but it seems obvious that it will. Let's > go with that. > Good Nathan, let's go with my https://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200709073416.14126-1-sasha.neftin@intel.com/ and let me know if warning still generated. Thanks, Sasha > Cheers, > Nathan > >>> drivers/net/ethernet/intel/igc/igc_mac.c:374:6: warning: variable 'link' >>> is used uninitialized whenever 'if' condition is true >>> [-Wsometimes-uninitialized] >>> if (!mac->get_link_status) { >>> ^~~~~~~~~~~~~~~~~~~~~ >>> drivers/net/ethernet/intel/igc/igc_mac.c:424:33: note: uninitialized use >>> occurs here >>> ret_val = igc_set_ltr_i225(hw, link); >>> ^~~~ >>> drivers/net/ethernet/intel/igc/igc_mac.c:374:2: note: remove the 'if' if >>> its condition is always false >>> if (!mac->get_link_status) { >>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> drivers/net/ethernet/intel/igc/igc_mac.c:367:11: note: initialize the >>> variable 'link' to silence this warning >>> bool link; >>> ^ >>> = 0 >>> 1 warning generated. >>> >>> It is not wrong, link is only uninitialized after this through >>> igc_phy_has_link. Presumably, if we skip the majority of this function >>> when get_link_status is false, we should skip calling igc_set_ltr_i225 >>> as well. Just directly return 0 in this case, rather than bothering with >>> adding another label or initializing link in the if statement. >>> >>> Fixes: 707abf069548 ("igc: Add initial LTR support") >>> Link: https://github.com/ClangBuiltLinux/linux/issues/1095 >>> Signed-off-by: Nathan Chancellor >>> --- >>> drivers/net/ethernet/intel/igc/igc_mac.c | 6 ++---- >>> 1 file changed, 2 insertions(+), 4 deletions(-) >>> >>> diff --git a/drivers/net/ethernet/intel/igc/igc_mac.c b/drivers/net/ethernet/intel/igc/igc_mac.c >>> index b47e7b0a6398..26e3c56a4a8b 100644 >>> --- a/drivers/net/ethernet/intel/igc/igc_mac.c >>> +++ b/drivers/net/ethernet/intel/igc/igc_mac.c >>> @@ -371,10 +371,8 @@ s32 igc_check_for_copper_link(struct igc_hw *hw) >>> * get_link_status flag is set upon receiving a Link Status >>> * Change or Rx Sequence Error interrupt. >>> */ >>> - if (!mac->get_link_status) { >>> - ret_val = 0; >>> - goto out; >>> - } >>> + if (!mac->get_link_status) >>> + return 0; >>> /* First we want to see if the MII Status Register reports >>> * link. If so, then we want to get the current speed/duplex >>> >>> base-commit: ca0e494af5edb59002665bf12871e94b4163a257 >>> >> Thanks, >> Sasha