linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tty: serial: msm_serial.c:  Cleaning up uninitialized variables
@ 2014-06-01 13:38 Rickard Strandqvist
  2014-06-02 10:15 ` Daniel Thompson
  2014-06-02 23:15 ` dwalker
  0 siblings, 2 replies; 3+ messages in thread
From: Rickard Strandqvist @ 2014-06-01 13:38 UTC (permalink / raw)
  To: David Brown, Daniel Walker
  Cc: Rickard Strandqvist, Bryan Huntsman, Greg Kroah-Hartman,
	Jiri Slaby, Grant Likely, Rob Herring, linux-arm-msm,
	linux-serial, linux-kernel, devicetree

There is a risk that the variable will be used without being initialized.

This was largely found by using a static code analysis program called cppcheck.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
 drivers/tty/serial/msm_serial.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index 053b98e..c67f5c5 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -962,7 +962,7 @@ static int __init msm_console_setup(struct console *co, char *options)
 {
 	struct uart_port *port;
 	struct msm_port *msm_port;
-	int baud, flow, bits, parity;
+	int baud = 0, flow, bits, parity;
 
 	if (unlikely(co->index >= UART_NR || co->index < 0))
 		return -ENXIO;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] tty: serial: msm_serial.c:  Cleaning up uninitialized variables
  2014-06-01 13:38 [PATCH] tty: serial: msm_serial.c: Cleaning up uninitialized variables Rickard Strandqvist
@ 2014-06-02 10:15 ` Daniel Thompson
  2014-06-02 23:15 ` dwalker
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Thompson @ 2014-06-02 10:15 UTC (permalink / raw)
  To: Rickard Strandqvist, David Brown, Daniel Walker
  Cc: Bryan Huntsman, Greg Kroah-Hartman, Jiri Slaby, Grant Likely,
	Rob Herring, linux-arm-msm, linux-serial, linux-kernel,
	devicetree

On 01/06/14 14:38, Rickard Strandqvist wrote:
> There is a risk that the variable will be used without being initialized.
> 
> This was largely found by using a static code analysis program called cppcheck.
> 
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
>  drivers/tty/serial/msm_serial.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
> index 053b98e..c67f5c5 100644
> --- a/drivers/tty/serial/msm_serial.c
> +++ b/drivers/tty/serial/msm_serial.c
> @@ -962,7 +962,7 @@ static int __init msm_console_setup(struct console *co, char *options)
>  {
>  	struct uart_port *port;
>  	struct msm_port *msm_port;
> -	int baud, flow, bits, parity;
> +	int baud = 0, flow, bits, parity;

This made me wonder my "baud" is special compared to the other three
variables. In fact I don't really think it is special so setting "baud"
from the else clause in the uninitialized branch makes more sense to me.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tty: serial: msm_serial.c:  Cleaning up uninitialized variables
  2014-06-01 13:38 [PATCH] tty: serial: msm_serial.c: Cleaning up uninitialized variables Rickard Strandqvist
  2014-06-02 10:15 ` Daniel Thompson
@ 2014-06-02 23:15 ` dwalker
  1 sibling, 0 replies; 3+ messages in thread
From: dwalker @ 2014-06-02 23:15 UTC (permalink / raw)
  To: Rickard Strandqvist
  Cc: David Brown, Bryan Huntsman, Greg Kroah-Hartman, Jiri Slaby,
	Grant Likely, Rob Herring, linux-arm-msm, linux-serial,
	linux-kernel, devicetree

On Sun, Jun 01, 2014 at 03:38:24PM +0200, Rickard Strandqvist wrote:
> There is a risk that the variable will be used without being initialized.
> 
> This was largely found by using a static code analysis program called cppcheck.
> 
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
>  drivers/tty/serial/msm_serial.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
> index 053b98e..c67f5c5 100644
> --- a/drivers/tty/serial/msm_serial.c
> +++ b/drivers/tty/serial/msm_serial.c
> @@ -962,7 +962,7 @@ static int __init msm_console_setup(struct console *co, char *options)
>  {
>  	struct uart_port *port;
>  	struct msm_port *msm_port;
> -	int baud, flow, bits, parity;
> +	int baud = 0, flow, bits, parity;
>  

It looks valid .. We might want to just set it to 115200 which is what your change eventually does later in
the code.

Daniel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-02 23:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-01 13:38 [PATCH] tty: serial: msm_serial.c: Cleaning up uninitialized variables Rickard Strandqvist
2014-06-02 10:15 ` Daniel Thompson
2014-06-02 23:15 ` dwalker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).