RE: [tty:tty-linus 23/26] drivers/tty/n_gsm.c:939:13: warning: variable 'size' is used uninitialized whenever 'if' condition is false

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> > > If you fix the issue, kindly add following tag as appropriate
> > > Reported-by: kernel test robot <lkp@xxxxxxxxx>
> > > 
> > > All warnings (new ones prefixed by >>):
> > > 
> > > >> drivers/tty/n_gsm.c:939:13: warning: variable 'size' is used 
> > > >> uninitialized whenever 'if' condition is false 
> > > >> [-Wsometimes-uninitialized]
> > >            } else if (dlci->adaption == 2) {
> > >                       ^~~~~~~~~~~~~~~~~~~
> > >    drivers/tty/n_gsm.c:948:40: note: uninitialized use occurs here
> > >            msg = gsm_data_alloc(gsm, dlci->addr, size, gsm->ftype);
> > >                                                  ^~~~
> > >    drivers/tty/n_gsm.c:939:9: note: remove the 'if' if its condition is always true
> > >            } else if (dlci->adaption == 2) {
> > >                   ^~~~~~~~~~~~~~~~~~~~~~~~~
> > >    drivers/tty/n_gsm.c:934:10: note: initialize the variable 'size' to silence this warning
> > >            int size;
> > >                    ^
> > >                     = 0
> > >    1 warning generated.
> > > 
> > 
> > It's not obvious, but this should be fine as adaption is only 1 or 2 
> > from what I can tell.
> > 
> > To make the compiler understand this easier, this should probably be 
> > an enum and use switch statements.  Daniel, want to make that change?
> 
> Alternatively, 'return -EINVAL' or something similar in the 'else'
> branch of the first if statement? The error message makes it seem like the function shouldn't continue but it does.

Thank you for the hint. I will create an appropriate patch.

Best regards,
Daniel Starke




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux