Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5470094imb; Thu, 7 Mar 2019 16:58:19 -0800 (PST) X-Google-Smtp-Source: APXvYqwv/7ie+njz5oWXZIUr+MsA2By0I2M6ySPx/kJ1PeGcOaK2ovI6Yyj6w+KbEr9QOmp9FaDC X-Received: by 2002:a17:902:74cb:: with SMTP id f11mr16174180plt.180.1552006699121; Thu, 07 Mar 2019 16:58:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552006699; cv=none; d=google.com; s=arc-20160816; b=0LmqKZ/UMYz5yv8iYL5wDZ1/5SjypwkuUvpK3Wl/zNG0DIlKLExWV528TB8GtDfO/1 hFd8tS97ApnMn8rQKteNdQjLQYc4MmIu3qKLJODYFTQtN35aE0rRQBpANV6tWbQmbEcF cnLm/NBJ52IGiE+CWFgB65HwmL5g65x2R9ZhADGMqpXsWwnuVe1quOkysdFZcr/WHlPJ 8oFmF123EVlp6hyZkDYMfgsZqStayM+FfRyHR8xA6qHdbuhXYdDCx5kKGcVZ7XQn71mN hN6rf/ACxpHosioRp+8KiWFJ9lxdcjcmFa/TOhwF15uZUHLifUTga7eyvHFPY3lVWd0A sqGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=Gaf+kx7RIOF/U4PqMr0dagqHc8dm/ObO0XEF+OQjw1Y=; b=XAchBQjjtMkZjokkaC3Eet4gKrZm89keiaKnG3v/aNq0ynKuU8Ghz/X6fHkRPvRX6b cE7kQw9OmQ2ZmxongwZ34JU10YJOEVD7zpVR3vcAmlGIqJyggTTUX16/5T+okHWSqCqb Kh84O8qCZ96Z3Fp+LAllrA6WWAl6hibyttJsrguoE36LJ5LLpXVRQ8AOTRzr7hiNyGt1 +oNUXRok2en6uzl/GD3KauCiQgeC6PDHQvAFh6uJ0ahAMJMBkDz8gBLiEOOCSKS90Dq0 hE5BTYezSUMjlbVfj4s4fLRBPIODokEkCbq+IEhrh309UnMveG6xpvYbZJF6ugX51OUa ERbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FhDhRrmZ; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y18si5097716pgf.247.2019.03.07.16.58.02; Thu, 07 Mar 2019 16:58:19 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=FhDhRrmZ; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726329AbfCHA5k (ORCPT + 99 others); Thu, 7 Mar 2019 19:57:40 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:40018 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726237AbfCHA5k (ORCPT ); Thu, 7 Mar 2019 19:57:40 -0500 Received: by mail-ed1-f68.google.com with SMTP id 10so15061102eds.7; Thu, 07 Mar 2019 16:57:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=Gaf+kx7RIOF/U4PqMr0dagqHc8dm/ObO0XEF+OQjw1Y=; b=FhDhRrmZDkUh3xhSfPBgQh3euUdl2NVxje9qvDp/GpJjYTQ1tMmuajBF0cGRvJ4xSL dELlfxjxOe3mSU22A1gkzTAeI0yJxDNY0HDwxD6TgtnXdjgRRSfvioszUFsZrspDm2Ci 1gM5Bvywl1ALKMZ6jMrfAV5R9dZqvMxSjGEzBpqESNRQNqqQ5eTNqfBoA62bCKhyQa7x qO5HrbPPbgS0bBwhYF/k3RrFr4GYt8pLDqa8FUeEYvETdylUdj+f7w6QCo34E1zA9Bmi B34UawNItflE3wX0wfE7aV+4G2aBaNzacuM/oNy3VuiTK1hPTHD9V7bHgKyl60xfVyZh kKQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=Gaf+kx7RIOF/U4PqMr0dagqHc8dm/ObO0XEF+OQjw1Y=; b=OT3bCnuLr3EB9dwvd2CEQFhdpgqAXQshQLe0z09fMHQQnzaXByi++gvG4RrUk3KXTG YX16CKGmKF4Qc3LQLiLYaedJ90gIU0WnlpPK/0Z+uHcCtcGQ6ZQ00Jfrz1RgoPTsRiKc 4688HxaIAi7tcN40e55e3frcixJ4+b2Vxweu9P/t8K86anMjmAyNTWD5plxIrTjaHsiI dEXtfVx9MG8K6C81ac1Tse/ECVYY4uqVNr4Rj0Omeodxb3bmUEwEUkEfVOy06SW/ON/X FML4BxA7JJHS04wSHgGus5UneGahTeaHrgP3URjNHxREYSG+8P7BwQYJxEQpEBOehyl8 jHwQ== X-Gm-Message-State: APjAAAVD4V/IHXz4ima8qq1d9HSzHjPC4IAeFe96Gm4+hun2T3T3nDIK 7jjnJLxCN+88ikGfD2AHN3U= X-Received: by 2002:a17:906:5784:: with SMTP id k4mr9738078ejq.107.1552006658134; Thu, 07 Mar 2019 16:57:38 -0800 (PST) Received: from archlinux-ryzen ([2a01:4f9:2a:1fae::2]) by smtp.gmail.com with ESMTPSA id b10sm1727862edy.80.2019.03.07.16.57.37 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 07 Mar 2019 16:57:37 -0800 (PST) Date: Thu, 7 Mar 2019 17:57:35 -0700 From: Nathan Chancellor To: Michael Chan , "David S. Miller" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nick Desaulniers , clang-built-linux@googlegroups.com Subject: -Wsometimes-uninitialized Clang warning in drivers/net/ethernet/broadcom/bnxt/bnxt.c Message-ID: <20190308005735.GA4122@archlinux-ryzen> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Cheers, Nathan diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 0bb9d7b3a2b6..7d3d206c2e86 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -1615,7 +1615,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, bnxt_reuse_rx_agg_bufs(cpr, cp_cons, agg_bufs); rc = -EIO; - goto next_rx; + goto next_rx_no_prod_no_len; } len = le32_to_cpu(rxcmp->rx_cmp_len_flags_type) >> RX_CMP_LEN_SHIFT;