Skip to contentSkip to conversation

drivers/video/backlight/lp855x_bl.c:252:7: warning: variable 'ret' is used uninitialized whenever 'if' condition is false

PATCH kernel test robot 3 participants 4 messages Aug 9, 2023 – Aug 17, 2023 Memory management

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   21ef7b1e17d039053edaeaf41142423810572741
commit: 5145531be5fbad0e914d1dc1cbd392d7b756abaa [4727/8441] backlight: lp855x: Catch errors when changing brightness
config: x86_64-buildonly-randconfig-r002-20230808 (https://download.01.org/0day-ci/archive/20230809/[email protected]/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce: (https://download.01.org/0day-ci/archive/20230809/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/video/backlight/lp855x_bl.c:252:7: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
           else if (lp->mode == REGISTER_BASED)
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:55:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:57:30: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/video/backlight/lp855x_bl.c:256:9: note: uninitialized use occurs here
           return ret;
                  ^~~
   drivers/video/backlight/lp855x_bl.c:252:7: note: remove the 'if' if its condition is always true
           else if (lp->mode == REGISTER_BASED)
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:55:23: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                         ^
   drivers/video/backlight/lp855x_bl.c:244:9: note: initialize the variable 'ret' to silence this warning
           int ret;
                  ^
                   = 0

1 warning generated.

vim +252 drivers/video/backlight/lp855x_bl.c

8cc9764c9c7d01 Kim, Milo    2012-12-17  239  
7be865ab8634d4 Kim, Milo    2012-03-23  240  static int lp855x_bl_update_status(struct backlight_device *bl)
7be865ab8634d4 Kim, Milo    2012-03-23  241  {
7be865ab8634d4 Kim, Milo    2012-03-23  242  	struct lp855x *lp = bl_get_data(bl);
61c1c6147f69d8 Sean Paul    2015-05-11  243  	int brightness = bl->props.brightness;
5145531be5fbad Artur Weber  2023-07-14  244  	int ret;
7be865ab8634d4 Kim, Milo    2012-03-23  245  
9f0a511f4a227c Shingo Nakao 2013-07-02  246  	if (bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
61c1c6147f69d8 Sean Paul    2015-05-11  247  		brightness = 0;
7be865ab8634d4 Kim, Milo    2012-03-23  248  
61c1c6147f69d8 Sean Paul    2015-05-11  249  	if (lp->mode == PWM_BASED)
5145531be5fbad Artur Weber  2023-07-14  250  		ret = lp855x_pwm_ctrl(lp, brightness,
5145531be5fbad Artur Weber  2023-07-14  251  				      bl->props.max_brightness);
61c1c6147f69d8 Sean Paul    2015-05-11 @252  	else if (lp->mode == REGISTER_BASED)
5145531be5fbad Artur Weber  2023-07-14  253  		ret = lp855x_write_byte(lp, lp->cfg->reg_brightness,
5145531be5fbad Artur Weber  2023-07-14  254  					(u8)brightness);
7be865ab8634d4 Kim, Milo    2012-03-23  255  
5145531be5fbad Artur Weber  2023-07-14  256  	return ret;
7be865ab8634d4 Kim, Milo    2012-03-23  257  }
7be865ab8634d4 Kim, Milo    2012-03-23  258  

:::::: The code at line 252 was first introduced by commit
:::::: 61c1c6147f69d8dea31fd133d2ec0b1594c9a3eb backlight: lp855x: Don't clear level on suspend/blank

:::::: TO: Sean Paul <[email protected]>
:::::: CC: Lee Jones <[email protected]>

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#1 lore raw

Arthur,

Please submit a follow-up patch or I'll have to revert it.

Thanks.

Quoted 71 lines · kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   21ef7b1e17d039053edaeaf41142423810572741
commit: 5145531be5fbad0e914d1dc1cbd392d7b756abaa [4727/8441] backlight: lp855x: Catch errors when changing brightness
config: x86_64-buildonly-randconfig-r002-20230808 (https://download.01.org/0day-ci/archive/20230809/[email protected]/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce: (https://download.01.org/0day-ci/archive/20230809/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

drivers/video/backlight/lp855x_bl.c:252:7: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

           else if (lp->mode == REGISTER_BASED)
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:55:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:57:30: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/video/backlight/lp855x_bl.c:256:9: note: uninitialized use occurs here
           return ret;
                  ^~~
   drivers/video/backlight/lp855x_bl.c:252:7: note: remove the 'if' if its condition is always true
           else if (lp->mode == REGISTER_BASED)
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:55:23: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                         ^
   drivers/video/backlight/lp855x_bl.c:244:9: note: initialize the variable 'ret' to silence this warning
           int ret;
                  ^
                   = 0

1 warning generated.

vim +252 drivers/video/backlight/lp855x_bl.c

8cc9764c9c7d01 Kim, Milo    2012-12-17  239  
7be865ab8634d4 Kim, Milo    2012-03-23  240  static int lp855x_bl_update_status(struct backlight_device *bl)
7be865ab8634d4 Kim, Milo    2012-03-23  241  {
7be865ab8634d4 Kim, Milo    2012-03-23  242  	struct lp855x *lp = bl_get_data(bl);
61c1c6147f69d8 Sean Paul    2015-05-11  243  	int brightness = bl->props.brightness;
5145531be5fbad Artur Weber  2023-07-14  244  	int ret;
7be865ab8634d4 Kim, Milo    2012-03-23  245  
9f0a511f4a227c Shingo Nakao 2013-07-02  246  	if (bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
61c1c6147f69d8 Sean Paul    2015-05-11  247  		brightness = 0;
7be865ab8634d4 Kim, Milo    2012-03-23  248  
61c1c6147f69d8 Sean Paul    2015-05-11  249  	if (lp->mode == PWM_BASED)
5145531be5fbad Artur Weber  2023-07-14  250  		ret = lp855x_pwm_ctrl(lp, brightness,
5145531be5fbad Artur Weber  2023-07-14  251  				      bl->props.max_brightness);
61c1c6147f69d8 Sean Paul    2015-05-11 @252  	else if (lp->mode == REGISTER_BASED)
5145531be5fbad Artur Weber  2023-07-14  253  		ret = lp855x_write_byte(lp, lp->cfg->reg_brightness,
5145531be5fbad Artur Weber  2023-07-14  254  					(u8)brightness);
7be865ab8634d4 Kim, Milo    2012-03-23  255  
5145531be5fbad Artur Weber  2023-07-14  256  	return ret;
7be865ab8634d4 Kim, Milo    2012-03-23  257  }
7be865ab8634d4 Kim, Milo    2012-03-23  258  

:::::: The code at line 252 was first introduced by commit
:::::: 61c1c6147f69d8dea31fd133d2ec0b1594c9a3eb backlight: lp855x: Don't clear level on suspend/blank

:::::: TO: Sean Paul <[email protected]>
:::::: CC: Lee Jones <[email protected]>

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Signature · 1 line
Lee Jones [李琼斯]
#3 lore raw
Quoted 8 lines · Nathan Chancellor
Quoted 3 lines · Lee Jones

Arthur,

Please submit a follow-up patch or I'll have to revert it.

The follow up fix was sent a couple hours after this report:

https://lore.kernel.org/[email protected]/

Super, thanks.

I had a simple grep for a follow-up, but must have missed it. I'll probably get up to it (working reverse chronologically) tomorrow some time.

Signature · 1 line
Lee Jones [李琼斯]