From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Nathan Chancellor <natechancellor@gmail.com>
Cc: Andy Gross <andy.gross@linaro.org>,
David Brown <david.brown@linaro.org>,
Karthikeyan Ramasubramanian <kramasub@codeaurora.org>,
Douglas Anderson <dianders@chromium.org>,
Ryan Case <ryandcase@chromium.org>,
linux-arm-msm@vger.kernel.org, linux-serial@vger.kernel.org,
linux-kernel@vger.kernel.org,
Nick Desaulniers <ndesaulniers@google.com>,
clang-built-linux@googlegroups.com
Subject: Re: -Wsometimes-uninitialized Clang warning in drivers/tty/serial/qcom_geni_serial.c
Date: Fri, 8 Mar 2019 09:40:22 +0100 [thread overview]
Message-ID: <20190308084022.GA31474@kroah.com> (raw)
In-Reply-To: <20190308004526.GA11580@archlinux-ryzen>
On Thu, Mar 07, 2019 at 05:45:26PM -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/tty/serial/qcom_geni_serial.c:1079:6: warning: variable 'baud' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
> if (options)
> ^~~~~~~
> drivers/tty/serial/qcom_geni_serial.c:1082:37: note: uninitialized use occurs here
> return uart_set_options(uport, co, baud, parity, bits, flow);
> ^~~~
> drivers/tty/serial/qcom_geni_serial.c:1079:2: note: remove the 'if' if its condition is always true
> if (options)
> ^~~~~~~~~~~~
> drivers/tty/serial/qcom_geni_serial.c:1053:10: note: initialize the variable 'baud' to silence this warning
> int baud;
> ^
> = 0
> 1 warning generated.
>
> While this is probably not an issue in practice (I assume baud is always
> supplied as an option), we should clean up this warning. I would fix it
> myself but I have no idea what baud's initial value should be as it
> seems it is dependent on the driver. Your input would be much
> appreciated.
this function can be called with the option variable set to NULL, so
there could not be a default baud rate set, nice catch.
As for the default, let's just be sane and set it to 9600 as that's a
normal default baudrate.
Do you want to make up a patch for this, or do you need me to?
thanks,
greg k-h
next prev parent reply other threads:[~2019-03-08 8:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-08 0:45 -Wsometimes-uninitialized Clang warning in drivers/tty/serial/qcom_geni_serial.c Nathan Chancellor
2019-03-08 8:40 ` Greg Kroah-Hartman [this message]
2019-03-08 18:37 ` [PATCH] tty: serial: qcom_geni_serial: Initialize baud in qcom_geni_console_setup Nathan Chancellor
2019-03-08 18:40 ` Nick Desaulniers
2019-03-22 14:20 ` Arnd Bergmann
2019-03-22 18:04 ` Nick Desaulniers
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=20190308084022.GA31474@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=andy.gross@linaro.org \
--cc=clang-built-linux@googlegroups.com \
--cc=david.brown@linaro.org \
--cc=dianders@chromium.org \
--cc=kramasub@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=natechancellor@gmail.com \
--cc=ndesaulniers@google.com \
--cc=ryandcase@chromium.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox