From: Nathan Chancellor <natechancellor@gmail.com>
To: Michael Chan <michael.chan@broadcom.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
Nick Desaulniers <ndesaulniers@google.com>,
"David S. Miller" <davem@davemloft.net>,
Networking <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
clang-built-linux@googlegroups.com,
Eddie Wai <eddie.wai@broadcom.com>,
"jeffrey.huang@broadcom.com" <huangjw@broadcom.com>,
"prashant.sreedharan@broadcom.com" <prashant@broadcom.com>,
"michael.chan@broadcom.com" <mchan@broadcom.com>,
Vasundhara Volam <vasundhara-v.volam@broadcom.com>
Subject: Re: -Wsometimes-uninitialized Clang warning in drivers/net/ethernet/broadcom/bnxt/bnxt.c
Date: Thu, 25 Apr 2019 11:35:02 -0700 [thread overview]
Message-ID: <20190425183502.GA7812@archlinux-i9> (raw)
In-Reply-To: <CACKFLikGY0=_FBosBdp2nq8F+Upmpo-Oi8kFeMH8diBEZP_0AQ@mail.gmail.com>
On Thu, Apr 25, 2019 at 11:33:04AM -0700, Michael Chan wrote:
> On Thu, Apr 25, 2019 at 11:14 AM Nathan Chancellor
> <natechancellor@gmail.com> 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 <clang-built-linux@googlegroups.com> 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
> > > > <natechancellor@gmail.com> 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.
Thank you for the reply, I appreciate it! I'll be on the lookout for the
patch.
Cheers,
Nathan
prev parent reply other threads:[~2019-04-25 18:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-08 0:57 -Wsometimes-uninitialized Clang warning in drivers/net/ethernet/broadcom/bnxt/bnxt.c Nathan Chancellor
2019-03-20 19:08 ` Nathan Chancellor
2019-03-20 20:41 ` Nick Desaulniers
2019-03-22 14:32 ` Arnd Bergmann
2019-04-25 18:14 ` Nathan Chancellor
2019-04-25 18:33 ` Michael Chan
2019-04-25 18:35 ` Nathan Chancellor [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190425183502.GA7812@archlinux-i9 \
--to=natechancellor@gmail.com \
--cc=arnd@arndb.de \
--cc=clang-built-linux@googlegroups.com \
--cc=davem@davemloft.net \
--cc=eddie.wai@broadcom.com \
--cc=huangjw@broadcom.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mchan@broadcom.com \
--cc=michael.chan@broadcom.com \
--cc=ndesaulniers@google.com \
--cc=netdev@vger.kernel.org \
--cc=prashant@broadcom.com \
--cc=vasundhara-v.volam@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.