All of lore.kernel.org
 help / color / mirror / Atom feed
* [tty:tty-linus 23/26] drivers/tty/n_gsm.c:939:13: warning: variable 'size' is used uninitialized whenever 'if' condition is false
@ 2022-04-22 23:42 kernel test robot
  2022-04-23  8:38   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 7+ messages in thread
From: kernel test robot @ 2022-04-22 23:42 UTC (permalink / raw)
  To: Daniel Starke; +Cc: llvm, kbuild-all, linux-serial, Greg Kroah-Hartman

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-linus
head:   637674fa40059cddcc3ad2212728965072f62ea3
commit: c19ffe00fed6bb423d81406d2a7e5793074c7d83 [23/26] tty: n_gsm: fix invalid use of MSC in advanced option
config: hexagon-randconfig-r035-20220422 (https://download.01.org/0day-ci/archive/20220423/202204230704.5MxboEEo-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 5bd87350a5ae429baf8f373cb226a57b62f87280)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git/commit/?id=c19ffe00fed6bb423d81406d2a7e5793074c7d83
        git remote add tty https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git
        git fetch --no-tags tty tty-linus
        git checkout c19ffe00fed6bb423d81406d2a7e5793074c7d83
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/tty/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

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.


vim +939 drivers/tty/n_gsm.c

   916	
   917	/**
   918	 *	gsm_dlci_modem_output	-	try and push modem status out of a DLCI
   919	 *	@gsm: mux
   920	 *	@dlci: the DLCI to pull modem status from
   921	 *	@brk: break signal
   922	 *
   923	 *	Push an empty frame in to the transmit queue to update the modem status
   924	 *	bits and to transmit an optional break.
   925	 *
   926	 *	Caller must hold the tx_lock of the mux.
   927	 */
   928	
   929	static int gsm_dlci_modem_output(struct gsm_mux *gsm, struct gsm_dlci *dlci,
   930					 u8 brk)
   931	{
   932		u8 *dp = NULL;
   933		struct gsm_msg *msg;
   934		int size;
   935	
   936		/* for modem bits without break data */
   937		if (dlci->adaption == 1) {
   938			size = 0;
 > 939		} else if (dlci->adaption == 2) {
   940			size = 1;
   941			if (brk > 0)
   942				size++;
   943		} else {
   944			pr_err("%s: unsupported adaption %d\n", __func__,
   945			       dlci->adaption);
   946		}
   947	
   948		msg = gsm_data_alloc(gsm, dlci->addr, size, gsm->ftype);
   949		if (!msg) {
   950			pr_err("%s: gsm_data_alloc error", __func__);
   951			return -ENOMEM;
   952		}
   953		dp = msg->data;
   954		switch (dlci->adaption) {
   955		case 1: /* Unstructured */
   956			break;
   957		case 2: /* Unstructured with modem bits. */
   958			if (brk == 0) {
   959				*dp++ = (gsm_encode_modem(dlci) << 1) | EA;
   960			} else {
   961				*dp++ = gsm_encode_modem(dlci) << 1;
   962				*dp++ = (brk << 4) | 2 | EA; /* Length, Break, EA */
   963			}
   964			break;
   965		default:
   966			/* Handled above */
   967			break;
   968		}
   969	
   970		__gsm_data_queue(dlci, msg);
   971		return size;
   972	}
   973	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* Re: [tty:tty-linus 23/26] drivers/tty/n_gsm.c:939:13: warning: variable 'size' is used uninitialized whenever 'if' condition is false
  2022-04-22 23:42 [tty:tty-linus 23/26] drivers/tty/n_gsm.c:939:13: warning: variable 'size' is used uninitialized whenever 'if' condition is false kernel test robot
@ 2022-04-23  8:38   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2022-04-23  8:38 UTC (permalink / raw)
  To: kernel test robot; +Cc: Daniel Starke, llvm, kbuild-all, linux-serial

On Sat, Apr 23, 2022 at 07:42:41AM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-linus
> head:   637674fa40059cddcc3ad2212728965072f62ea3
> commit: c19ffe00fed6bb423d81406d2a7e5793074c7d83 [23/26] tty: n_gsm: fix invalid use of MSC in advanced option
> config: hexagon-randconfig-r035-20220422 (https://download.01.org/0day-ci/archive/20220423/202204230704.5MxboEEo-lkp@intel.com/config)
> compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 5bd87350a5ae429baf8f373cb226a57b62f87280)
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git/commit/?id=c19ffe00fed6bb423d81406d2a7e5793074c7d83
>         git remote add tty https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git
>         git fetch --no-tags tty tty-linus
>         git checkout c19ffe00fed6bb423d81406d2a7e5793074c7d83
>         # save the config file
>         mkdir build_dir && cp config build_dir/.config
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/tty/
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> 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?

thanks,

greg k-h

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

* Re: [tty:tty-linus 23/26] drivers/tty/n_gsm.c:939:13: warning: variable 'size' is used uninitialized whenever 'if' condition is false
@ 2022-04-23  8:38   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2022-04-23  8:38 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2550 bytes --]

On Sat, Apr 23, 2022 at 07:42:41AM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-linus
> head:   637674fa40059cddcc3ad2212728965072f62ea3
> commit: c19ffe00fed6bb423d81406d2a7e5793074c7d83 [23/26] tty: n_gsm: fix invalid use of MSC in advanced option
> config: hexagon-randconfig-r035-20220422 (https://download.01.org/0day-ci/archive/20220423/202204230704.5MxboEEo-lkp(a)intel.com/config)
> compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 5bd87350a5ae429baf8f373cb226a57b62f87280)
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git/commit/?id=c19ffe00fed6bb423d81406d2a7e5793074c7d83
>         git remote add tty https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git
>         git fetch --no-tags tty tty-linus
>         git checkout c19ffe00fed6bb423d81406d2a7e5793074c7d83
>         # save the config file
>         mkdir build_dir && cp config build_dir/.config
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/tty/
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> 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?

thanks,

greg k-h

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

* Re: [tty:tty-linus 23/26] drivers/tty/n_gsm.c:939:13: warning: variable 'size' is used uninitialized whenever 'if' condition is false
  2022-04-23  8:38   ` Greg Kroah-Hartman
@ 2022-04-24 22:02     ` Nathan Chancellor
  -1 siblings, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2022-04-24 22:02 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: kernel test robot, Daniel Starke, llvm, kbuild-all, linux-serial

On Sat, Apr 23, 2022 at 10:38:35AM +0200, Greg Kroah-Hartman wrote:
> On Sat, Apr 23, 2022 at 07:42:41AM +0800, kernel test robot wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-linus
> > head:   637674fa40059cddcc3ad2212728965072f62ea3
> > commit: c19ffe00fed6bb423d81406d2a7e5793074c7d83 [23/26] tty: n_gsm: fix invalid use of MSC in advanced option
> > config: hexagon-randconfig-r035-20220422 (https://download.01.org/0day-ci/archive/20220423/202204230704.5MxboEEo-lkp@intel.com/config)
> > compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 5bd87350a5ae429baf8f373cb226a57b62f87280)
> > reproduce (this is a W=1 build):
> >         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> >         chmod +x ~/bin/make.cross
> >         # https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git/commit/?id=c19ffe00fed6bb423d81406d2a7e5793074c7d83
> >         git remote add tty https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git
> >         git fetch --no-tags tty tty-linus
> >         git checkout c19ffe00fed6bb423d81406d2a7e5793074c7d83
> >         # save the config file
> >         mkdir build_dir && cp config build_dir/.config
> >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/tty/
> > 
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> > 
> > 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.

Cheers,
Nathan

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

* Re: [tty:tty-linus 23/26] drivers/tty/n_gsm.c:939:13: warning: variable 'size' is used uninitialized whenever 'if' condition is false
@ 2022-04-24 22:02     ` Nathan Chancellor
  0 siblings, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2022-04-24 22:02 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2889 bytes --]

On Sat, Apr 23, 2022 at 10:38:35AM +0200, Greg Kroah-Hartman wrote:
> On Sat, Apr 23, 2022 at 07:42:41AM +0800, kernel test robot wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-linus
> > head:   637674fa40059cddcc3ad2212728965072f62ea3
> > commit: c19ffe00fed6bb423d81406d2a7e5793074c7d83 [23/26] tty: n_gsm: fix invalid use of MSC in advanced option
> > config: hexagon-randconfig-r035-20220422 (https://download.01.org/0day-ci/archive/20220423/202204230704.5MxboEEo-lkp(a)intel.com/config)
> > compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 5bd87350a5ae429baf8f373cb226a57b62f87280)
> > reproduce (this is a W=1 build):
> >         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> >         chmod +x ~/bin/make.cross
> >         # https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git/commit/?id=c19ffe00fed6bb423d81406d2a7e5793074c7d83
> >         git remote add tty https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git
> >         git fetch --no-tags tty tty-linus
> >         git checkout c19ffe00fed6bb423d81406d2a7e5793074c7d83
> >         # save the config file
> >         mkdir build_dir && cp config build_dir/.config
> >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/tty/
> > 
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> > 
> > 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.

Cheers,
Nathan

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

* RE: [tty:tty-linus 23/26] drivers/tty/n_gsm.c:939:13: warning: variable 'size' is used uninitialized whenever 'if' condition is false
@ 2022-04-25  7:04 Starke, Daniel
  0 siblings, 0 replies; 7+ messages in thread
From: Starke, Daniel @ 2022-04-25  7:04 UTC (permalink / raw)
  To: Nathan Chancellor, Greg Kroah-Hartman
  Cc: kernel test robot, llvm, kbuild-all, linux-serial

> > > If you fix the issue, kindly add following tag as appropriate
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > 
> > > 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

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

* Re: [tty:tty-linus 23/26] drivers/tty/n_gsm.c:939:13: warning: variable 'size' is used uninitialized whenever 'if' condition is false
@ 2022-04-25  7:04 Starke, Daniel
  0 siblings, 0 replies; 7+ messages in thread
From: Starke, Daniel @ 2022-04-25  7:04 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1636 bytes --]

> > > If you fix the issue, kindly add following tag as appropriate
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > 
> > > 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

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

end of thread, other threads:[~2022-04-25  7:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-22 23:42 [tty:tty-linus 23/26] drivers/tty/n_gsm.c:939:13: warning: variable 'size' is used uninitialized whenever 'if' condition is false kernel test robot
2022-04-23  8:38 ` Greg Kroah-Hartman
2022-04-23  8:38   ` Greg Kroah-Hartman
2022-04-24 22:02   ` Nathan Chancellor
2022-04-24 22:02     ` Nathan Chancellor
2022-04-25  7:04 Starke, Daniel
2022-04-25  7:04 Starke, Daniel

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.