All of lore.kernel.org
 help / color / mirror / Atom feed
* [jic23-iio:sparse-friendly-direct-mode 111/166] drivers/iio/adc/ad7173.c:1184:8: warning: variable 'ret' is used uninitialized whenever 'if' condition is true
@ 2025-02-02 23:53 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2025-02-02 23:53 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: llvm, oe-kbuild-all

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git sparse-friendly-direct-mode
head:   bada9cd0235b288b74ee2bd65fd4223d71f62b02
commit: a0df9059bd2ef36d622cf94311dfb017b6b5de5d [111/166] iio: adc: Simple cases of switch to sparse friendly iio_device_claim/release_direct()
config: hexagon-randconfig-001-20250203 (https://download.01.org/0day-ci/archive/20250203/202502030711.VjFc2dxK-lkp@intel.com/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 355d0b186f178668b103068537e517f3d52ad639)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250203/202502030711.VjFc2dxK-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502030711.VjFc2dxK-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/iio/adc/ad7173.c:1184:8: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
    1184 |                         if (freq >= st->info->sinc5_data_rates[i])
         |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/iio/adc/ad7173.c:1198:9: note: uninitialized use occurs here
    1198 |         return ret;
         |                ^~~
   drivers/iio/adc/ad7173.c:1184:4: note: remove the 'if' if its condition is always false
    1184 |                         if (freq >= st->info->sinc5_data_rates[i])
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1185 |                                 break;
         |                                 ~~~~~
>> drivers/iio/adc/ad7173.c:1183:39: warning: variable 'ret' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized]
    1183 |                 for (i = st->info->odr_start_value; i < st->info->num_sinc5_data_rates - 1; i++)
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/iio/adc/ad7173.c:1198:9: note: uninitialized use occurs here
    1198 |         return ret;
         |                ^~~
   drivers/iio/adc/ad7173.c:1183:39: note: remove the condition if it is always true
    1183 |                 for (i = st->info->odr_start_value; i < st->info->num_sinc5_data_rates - 1; i++)
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/iio/adc/ad7173.c:1160:9: note: initialize the variable 'ret' to silence this warning
    1160 |         int ret;
         |                ^
         |                 = 0
   2 warnings generated.


vim +1184 drivers/iio/adc/ad7173.c

76a1e6a4280211 Dumitru Ceclan   2024-02-28  1152  
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1153  static int ad7173_write_raw(struct iio_dev *indio_dev,
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1154  			    struct iio_chan_spec const *chan,
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1155  			    int val, int val2, long info)
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1156  {
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1157  	struct ad7173_state *st = iio_priv(indio_dev);
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1158  	struct ad7173_channel_config *cfg;
182bc496dc63ca Dumitru Ceclan   2024-05-30  1159  	unsigned int freq, i;
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1160  	int ret;
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1161  
a0df9059bd2ef3 Jonathan Cameron 2025-02-02  1162  	if (!iio_device_claim_direct(indio_dev))
a0df9059bd2ef3 Jonathan Cameron 2025-02-02  1163  		return -EBUSY;
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1164  
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1165  	switch (info) {
f87b076b934f72 Dumitru Ceclan   2024-06-07  1166  	/*
f87b076b934f72 Dumitru Ceclan   2024-06-07  1167  	 * This attribute sets the sampling frequency for each channel individually.
f87b076b934f72 Dumitru Ceclan   2024-06-07  1168  	 * There are no issues for raw or buffered reads of an individual channel.
f87b076b934f72 Dumitru Ceclan   2024-06-07  1169  	 *
f87b076b934f72 Dumitru Ceclan   2024-06-07  1170  	 * When multiple channels are enabled in buffered mode, the effective
f87b076b934f72 Dumitru Ceclan   2024-06-07  1171  	 * sampling rate of a channel is lowered in correlation to the number
f87b076b934f72 Dumitru Ceclan   2024-06-07  1172  	 * of channels enabled and the sampling rate of the other channels.
f87b076b934f72 Dumitru Ceclan   2024-06-07  1173  	 *
f87b076b934f72 Dumitru Ceclan   2024-06-07  1174  	 * Example: 3 channels enabled with rates CH1:6211sps CH2,CH3:10sps
f87b076b934f72 Dumitru Ceclan   2024-06-07  1175  	 * While the reading of CH1 takes only 0.16ms, the reading of CH2 and CH3
f87b076b934f72 Dumitru Ceclan   2024-06-07  1176  	 * will take 100ms each.
f87b076b934f72 Dumitru Ceclan   2024-06-07  1177  	 *
f87b076b934f72 Dumitru Ceclan   2024-06-07  1178  	 * This will cause the reading of CH1 to be actually done once every
f87b076b934f72 Dumitru Ceclan   2024-06-07  1179  	 * 200.16ms, an effective rate of 4.99sps.
f87b076b934f72 Dumitru Ceclan   2024-06-07  1180  	 */
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1181  	case IIO_CHAN_INFO_SAMP_FREQ:
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1182  		freq = val * MILLI + val2 / MILLI;
37ae8381ccda3c Dumitru Ceclan   2024-03-06 @1183  		for (i = st->info->odr_start_value; i < st->info->num_sinc5_data_rates - 1; i++)
76a1e6a4280211 Dumitru Ceclan   2024-02-28 @1184  			if (freq >= st->info->sinc5_data_rates[i])
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1185  				break;
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1186  
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1187  		cfg = &st->channels[chan->address].cfg;
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1188  		cfg->odr = i;
182bc496dc63ca Dumitru Ceclan   2024-05-30  1189  		cfg->live = false;
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1190  		break;
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1191  
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1192  	default:
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1193  		ret = -EINVAL;
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1194  		break;
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1195  	}
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1196  
a0df9059bd2ef3 Jonathan Cameron 2025-02-02  1197  	iio_device_release_direct(indio_dev);
76a1e6a4280211 Dumitru Ceclan   2024-02-28 @1198  	return ret;
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1199  }
76a1e6a4280211 Dumitru Ceclan   2024-02-28  1200  

:::::: The code at line 1184 was first introduced by commit
:::::: 76a1e6a4280211b1ceffec4f79f96e492c661229 iio: adc: ad7173: add AD7173 driver

:::::: TO: Dumitru Ceclan <mitrutzceclan@gmail.com>
:::::: CC: Jonathan Cameron <Jonathan.Cameron@huawei.com>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-02-02 23:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-02 23:53 [jic23-iio:sparse-friendly-direct-mode 111/166] drivers/iio/adc/ad7173.c:1184:8: warning: variable 'ret' is used uninitialized whenever 'if' condition is true kernel test robot

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.