Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp848385img; Wed, 20 Mar 2019 12:10:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZ+8HolGmPDAe77GX7laWe4UVnEgs580ftuVIBgHq84V54VZsL99KzCN/SlB8mWesvbXtW X-Received: by 2002:a17:902:9f83:: with SMTP id g3mr9795459plq.296.1553109006061; Wed, 20 Mar 2019 12:10:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553109006; cv=none; d=google.com; s=arc-20160816; b=yRklLq0PpmnoiX8Xc/ggFBwQHgQgXYRcbpofXss5pp0KmTvSXM4qfX73fgXtbhzakS jT0c6q6JerYAeOgXDFvVIEF4Cps58AUMjapsWVNM3P/RN7O0TcljC9KhH6+H3q3i7kr9 LMn61I7IglJgTsLGzH8xyRwEDduwp703EuwfN047waTBl7gg6Kl24gWlZWvYf/jd4wI1 iqvWG3leCtQ687CRg5b/cNyyzQIT6Um1AYvgR2wH2EFq8psLVXPn6CZzupHPXA4wp5T8 tYiI/MpigWvDofGBF2hgzEXbMqIQolbBbK93Psb7QQ55NP7H+iwybDc1YWQPasBEPDu8 cs7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=3j7+CoBE5moNxDmBNVzkQjsnY/Mbp7RYB6a+PG6v6fU=; b=UeT6bcyIJc5diTDtJ3/80wc2LnAx3ps6xtEMkXb4c1jGBW8KRx6cIr1vna+Au/duIk XQNyBZqhsy4RjqRhXRMMJhCQgqEV8s1VqEEgc1zlN+BfuO57jHF301bM9HQvCbv/58AG 8t3CrSE6Zpi4UfRTueTu3YSefRjkGIg0bOLIonVIv6cXK4AtRxS8NT2jDju+MjqYfmEw mY9ES4Q/b+VWemyxXhIc4QdE988oxh0ih06mrOyNvco7u+jg6bqN8manvjaI+oIcN/41 4U20EkKep0vZU/qc6cf8j3YbDPjKxP/Z5LRyz2bspEeP9C6Itevm4onr8U3iX3TxAauM Vz7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GoWRQRmO; 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 e96si2517973plb.123.2019.03.20.12.09.50; Wed, 20 Mar 2019 12:10:06 -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=@gmail.com header.s=20161025 header.b=GoWRQRmO; 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 S1727494AbfCTTI7 (ORCPT + 99 others); Wed, 20 Mar 2019 15:08:59 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:41866 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727382AbfCTTIz (ORCPT ); Wed, 20 Mar 2019 15:08:55 -0400 Received: by mail-ed1-f68.google.com with SMTP id a25so2964054edc.8; Wed, 20 Mar 2019 12:08:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=3j7+CoBE5moNxDmBNVzkQjsnY/Mbp7RYB6a+PG6v6fU=; b=GoWRQRmOacd6Ukw9KEdU4F4crc8IuyOUhrSODQ4JUqZekUsnDTgZHapA84HneT3IYd jVDDnFBJuWEBIkgl7ZbsiAK1fAnm2hgf4Xzuf6o9hQMrV1v/QTfNfqxNE7AO7oUUvqe9 FUphrFHNma4N5mhJOftC5LxK1/E7mPbRLBaqgtLP9WsaKNeuAYe6lkGFryNbTLiJwB0b TYCe/NpetT8+/T76SyfYwtFBanWtvKvcGT3kY5RnmUlPbuX67gYxgAaWEJln411r+dK+ 5fLNWLer0adYYVc+Qx1HWaa7LdlzJaxbkUpHu6JJc/5vUxE4vovHtLJ/DsHjVvTLyXcl hZTA== 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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=3j7+CoBE5moNxDmBNVzkQjsnY/Mbp7RYB6a+PG6v6fU=; b=CBA6p/XYnAqe76pucWbTLmTSvtwonvGfU4OKUUbP6xHp4RaJiF1nQnvnAxNEgo9P6Q muAQC73Py0HgYbXNCSo3dmyPGlRlRgJa1mb5hzP5yo0SctZjscqs6dxeAjXrjMN/ve/j mBt4vF7BYoXpPvrumIombQY04FfjGHRO1UaaQ08lljCA8GtEQ5gdMMpJJ/ESpvAIWriK O8alk2W2oyNX7YAJL9zDiR0D0yxZISkXe0NAKI8SkXJUbFFUa6d9tyw7mhi/S3oQ8AKl 9FC7ZuokoFkOsWW305fbOgTJu3xd8FpHdbrV2g/4VKCUhkdX0xRsfzhh0W2CuHLunfvn s3Lw== X-Gm-Message-State: APjAAAVBefryaMCTTAkQ6bXq+WzFTzD6eCd+8CATfwci1Y5v4RxNpvF+ SRlI4FdXb8O3H30GY2ZuXKs= X-Received: by 2002:a17:906:1299:: with SMTP id k25mr17674642ejb.80.1553108932886; Wed, 20 Mar 2019 12:08:52 -0700 (PDT) Received: from archlinux-ryzen ([2a01:4f9:2a:1fae::2]) by smtp.gmail.com with ESMTPSA id x3sm882219ede.25.2019.03.20.12.08.51 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 20 Mar 2019 12:08:51 -0700 (PDT) Date: Wed, 20 Mar 2019 12:08:49 -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: Re: -Wsometimes-uninitialized Clang warning in drivers/net/ethernet/broadcom/bnxt/bnxt.c Message-ID: <20190320190849.GB28744@archlinux-ryzen> References: <20190308005735.GA4122@archlinux-ryzen> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190308005735.GA4122@archlinux-ryzen> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > 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; Gentle ping (if there was a response to this, I didn't receive it). I know I sent it in the middle of a merge window so I get if it slipped through the cracks. Thanks, Nathan