From: Nick Desaulniers <ndesaulniers@google.com> To: Nathan Chancellor <natechancellor@gmail.com> Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>, Alexandre Torgue <alexandre.torgue@st.com>, Jose Abreu <joabreu@synopsys.com>, "David S. Miller" <davem@davemloft.net>, Maxime Coquelin <mcoquelin.stm32@gmail.com>, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Linux ARM <linux-arm-kernel@lists.infradead.org>, LKML <linux-kernel@vger.kernel.org>, clang-built-linux@googlegroups.com Subject: Re: [PATCH] net: stmmac: Avoid one more sometimes uninitialized Clang warning Date: Fri, 8 Mar 2019 13:02:47 -0800 [thread overview] Message-ID: <CAKwvOdkjpRVJ=TE8JCoMDJ46s6ToSgo0c2RcsoQ-JOPYMgLUpw@mail.gmail.com> (raw) In-Reply-To: <20190308040239.9400-1-natechancellor@gmail.com> On Thu, Mar 7, 2019 at 8:02 PM Nathan Chancellor <natechancellor@gmail.com> wrote: > > When building with -Wsometimes-uninitialized, Clang warns: > > drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c:111:2: error: variable > 'ns' is used uninitialized whenever 'if' condition is false > [-Werror,-Wsometimes-uninitialized] > drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c:111:2: error: variable > 'ns' is used uninitialized whenever '&&' condition is false > [-Werror,-Wsometimes-uninitialized] > > Clang is concerned with the use of stmmac_do_void_callback (which > stmmac_get_systime wraps), as it may fail to initialize these values if > the if condition was ever false (meaning the callback doesn't exist). > It's not wrong because the callback is what initializes ns. While it's > unlikely that the callback is going to disappear at some point and make > that condition false, we can easily avoid this warning by zero > initializing the variable. > > Link: https://github.com/ClangBuiltLinux/linux/issues/384 > Fixes: df103170854e ("net: stmmac: Avoid sometimes uninitialized Clang warnings") Was initially confused by the link (thought I caught the 3 previous instances in code review of df103170854e). I see now that I did not report stmmac_ptp.c (only stmmac_main.c) properly. Had I, this could have been bundled up into df103170854e indeed. Sorry. Thanks for circling back and cleaning up this additional instance. Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> > Suggested-by: Nick Desaulniers <ndesaulniers@google.com> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> > --- > drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c > index 2293e21f789f..cc60b3fb0892 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c > @@ -105,7 +105,7 @@ static int stmmac_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts) > struct stmmac_priv *priv = > container_of(ptp, struct stmmac_priv, ptp_clock_ops); > unsigned long flags; > - u64 ns; > + u64 ns = 0; > > spin_lock_irqsave(&priv->ptp_lock, flags); > stmmac_get_systime(priv, priv->ptpaddr, &ns); > -- > 2.21.0 > -- Thanks, ~Nick Desaulniers
WARNING: multiple messages have this Message-ID (diff)
From: Nick Desaulniers <ndesaulniers@google.com> To: Nathan Chancellor <natechancellor@gmail.com> Cc: Alexandre Torgue <alexandre.torgue@st.com>, netdev@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>, linux-stm32@st-md-mailman.stormreply.com, clang-built-linux@googlegroups.com, Jose Abreu <joabreu@synopsys.com>, Maxime Coquelin <mcoquelin.stm32@gmail.com>, Giuseppe Cavallaro <peppe.cavallaro@st.com>, "David S. Miller" <davem@davemloft.net>, Linux ARM <linux-arm-kernel@lists.infradead.org> Subject: Re: [PATCH] net: stmmac: Avoid one more sometimes uninitialized Clang warning Date: Fri, 8 Mar 2019 13:02:47 -0800 [thread overview] Message-ID: <CAKwvOdkjpRVJ=TE8JCoMDJ46s6ToSgo0c2RcsoQ-JOPYMgLUpw@mail.gmail.com> (raw) In-Reply-To: <20190308040239.9400-1-natechancellor@gmail.com> On Thu, Mar 7, 2019 at 8:02 PM Nathan Chancellor <natechancellor@gmail.com> wrote: > > When building with -Wsometimes-uninitialized, Clang warns: > > drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c:111:2: error: variable > 'ns' is used uninitialized whenever 'if' condition is false > [-Werror,-Wsometimes-uninitialized] > drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c:111:2: error: variable > 'ns' is used uninitialized whenever '&&' condition is false > [-Werror,-Wsometimes-uninitialized] > > Clang is concerned with the use of stmmac_do_void_callback (which > stmmac_get_systime wraps), as it may fail to initialize these values if > the if condition was ever false (meaning the callback doesn't exist). > It's not wrong because the callback is what initializes ns. While it's > unlikely that the callback is going to disappear at some point and make > that condition false, we can easily avoid this warning by zero > initializing the variable. > > Link: https://github.com/ClangBuiltLinux/linux/issues/384 > Fixes: df103170854e ("net: stmmac: Avoid sometimes uninitialized Clang warnings") Was initially confused by the link (thought I caught the 3 previous instances in code review of df103170854e). I see now that I did not report stmmac_ptp.c (only stmmac_main.c) properly. Had I, this could have been bundled up into df103170854e indeed. Sorry. Thanks for circling back and cleaning up this additional instance. Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> > Suggested-by: Nick Desaulniers <ndesaulniers@google.com> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> > --- > drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c > index 2293e21f789f..cc60b3fb0892 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c > @@ -105,7 +105,7 @@ static int stmmac_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts) > struct stmmac_priv *priv = > container_of(ptp, struct stmmac_priv, ptp_clock_ops); > unsigned long flags; > - u64 ns; > + u64 ns = 0; > > spin_lock_irqsave(&priv->ptp_lock, flags); > stmmac_get_systime(priv, priv->ptpaddr, &ns); > -- > 2.21.0 > -- Thanks, ~Nick Desaulniers _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-03-08 21:03 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-03-07 16:21 [PATCH] net: stmmac: Avoid sometimes uninitialized Clang warnings Nathan Chancellor 2019-03-07 16:21 ` Nathan Chancellor 2019-03-07 17:49 ` David Miller 2019-03-07 17:49 ` David Miller 2019-03-07 17:54 ` Nick Desaulniers 2019-03-07 17:54 ` Nick Desaulniers 2019-03-07 18:00 ` [PATCH v2] " Nathan Chancellor 2019-03-07 18:00 ` Nathan Chancellor 2019-03-07 18:12 ` Nick Desaulniers 2019-03-07 18:12 ` Nick Desaulniers 2019-03-07 18:59 ` David Miller 2019-03-07 18:59 ` David Miller 2019-03-08 4:02 ` [PATCH] net: stmmac: Avoid one more sometimes uninitialized Clang warning Nathan Chancellor 2019-03-08 4:02 ` Nathan Chancellor 2019-03-08 21:02 ` Nick Desaulniers [this message] 2019-03-08 21:02 ` Nick Desaulniers 2019-03-09 7:20 ` David Miller 2019-03-09 7:20 ` David Miller
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='CAKwvOdkjpRVJ=TE8JCoMDJ46s6ToSgo0c2RcsoQ-JOPYMgLUpw@mail.gmail.com' \ --to=ndesaulniers@google.com \ --cc=alexandre.torgue@st.com \ --cc=clang-built-linux@googlegroups.com \ --cc=davem@davemloft.net \ --cc=joabreu@synopsys.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-stm32@st-md-mailman.stormreply.com \ --cc=mcoquelin.stm32@gmail.com \ --cc=natechancellor@gmail.com \ --cc=netdev@vger.kernel.org \ --cc=peppe.cavallaro@st.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: linkBe 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.