lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <0a725ef2-0f2a-f096-c8ae-af1d95b97479@intel.com>
Date:   Mon, 9 May 2022 16:54:29 +0800
From:   kernel test robot <yujie.liu@...el.com>
To:     Lucas Stankus <lucas.p.stankus@...il.com>
CC:     <kbuild-all@...ts.01.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Jonathan Cameron <Jonathan.Cameron@...wei.com>,
        Alexandru Ardelean <ardeleanalex@...il.com>
Subject: drivers/staging/iio/cdc/ad7746.c:244:24: warning: The statement 'if
 (chip->capdac_set!=chan->channel) chip->capdac_set=chan->channel' is
 logically equivalent to 'chip->capdac_set=chan->channel'.
 [duplicateConditionalAssign]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   672c0c5173427e6b3e2a9bbb7be51ceeec78093a
commit: 6a7e4b04df3f4fb91a1516671a2610a0ac9f0c69 staging: iio: cdc: ad7746: extract capac setup to own function
date:   11 months ago
compiler: arm-linux-gnueabi-gcc (GCC) 11.3.0
reproduce (cppcheck warning):
         # apt-get install cppcheck
         git checkout 6a7e4b04df3f4fb91a1516671a2610a0ac9f0c69
         cppcheck --quiet --enable=style,performance,portability --template=gcc FILE

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


cppcheck possible warnings: (new ones prefixed by >>, may not be real problems)

 >> drivers/staging/iio/cdc/ad7746.c:244:24: warning: The statement 'if (chip->capdac_set!=chan->channel) chip->capdac_set=chan->channel' is logically equivalent to 'chip->capdac_set=chan->channel'. [duplicateConditionalAssign]
      if (chip->capdac_set != chan->channel) {
                           ^

vim +244 drivers/staging/iio/cdc/ad7746.c

6a7e4b04df3f4f drivers/staging/iio/cdc/ad7746.c Lucas Stankus     2021-05-23  224
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  225  static int ad7746_select_channel(struct iio_dev *indio_dev,
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  226  				 struct iio_chan_spec const *chan)
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  227  {
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  228  	struct ad7746_chip_info *chip = iio_priv(indio_dev);
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  229  	u8 vt_setup, cap_setup;
afcd0b22e35e0b drivers/staging/iio/cdc/ad7746.c HernĂ¡n Gonzalez   2018-04-13  230  	int ret, delay, idx;
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  231
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  232  	switch (chan->type) {
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  233  	case IIO_CAPACITANCE:
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  234  		cap_setup = (chan->address & 0xFF) | AD7746_CAPSETUP_CAPEN;
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  235  		vt_setup = chip->vt_setup & ~AD7746_VTSETUP_VTEN;
579d542534c96c drivers/staging/iio/cdc/ad7746.c Eva Rachel Retuya 2016-10-28  236  		idx = (chip->config & AD7746_CONF_CAPFS_MASK) >>
579d542534c96c drivers/staging/iio/cdc/ad7746.c Eva Rachel Retuya 2016-10-28  237  			AD7746_CONF_CAPFS_SHIFT;
579d542534c96c drivers/staging/iio/cdc/ad7746.c Eva Rachel Retuya 2016-10-28  238  		delay = ad7746_cap_filter_rate_table[idx][1];
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  239
6a7e4b04df3f4f drivers/staging/iio/cdc/ad7746.c Lucas Stankus     2021-05-23  240  		ret = ad7746_set_capdac(chip, chan->channel);
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  241  		if (ret < 0)
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  242  			return ret;
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  243
6a7e4b04df3f4f drivers/staging/iio/cdc/ad7746.c Lucas Stankus     2021-05-23 @244  		if (chip->capdac_set != chan->channel) {
6a7e4b04df3f4f drivers/staging/iio/cdc/ad7746.c Lucas Stankus     2021-05-23  245
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  246  			chip->capdac_set = chan->channel;
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  247  		}
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  248  		break;
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  249  	case IIO_VOLTAGE:
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  250  	case IIO_TEMP:
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  251  		vt_setup = (chan->address & 0xFF) | AD7746_VTSETUP_VTEN;
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  252  		cap_setup = chip->cap_setup & ~AD7746_CAPSETUP_CAPEN;
579d542534c96c drivers/staging/iio/cdc/ad7746.c Eva Rachel Retuya 2016-10-28  253  		idx = (chip->config & AD7746_CONF_VTFS_MASK) >>
579d542534c96c drivers/staging/iio/cdc/ad7746.c Eva Rachel Retuya 2016-10-28  254  			AD7746_CONF_VTFS_SHIFT;
579d542534c96c drivers/staging/iio/cdc/ad7746.c Eva Rachel Retuya 2016-10-28  255  		delay = ad7746_cap_filter_rate_table[idx][1];
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  256  		break;
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  257  	default:
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  258  		return -EINVAL;
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  259  	}
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  260
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  261  	if (chip->cap_setup != cap_setup) {
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  262  		ret = i2c_smbus_write_byte_data(chip->client,
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  263  						AD7746_REG_CAP_SETUP,
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  264  						cap_setup);
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  265  		if (ret < 0)
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  266  			return ret;
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  267
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  268  		chip->cap_setup = cap_setup;
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  269  	}
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  270
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  271  	if (chip->vt_setup != vt_setup) {
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  272  		ret = i2c_smbus_write_byte_data(chip->client,
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  273  						AD7746_REG_VT_SETUP,
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  274  						vt_setup);
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  275  		if (ret < 0)
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  276  			return ret;
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  277
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  278  		chip->vt_setup = vt_setup;
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  279  	}
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  280
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  281  	return delay;
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  282  }
83e416f458d532 drivers/staging/iio/adc/ad7746.c Michael Hennerich 2011-09-21  283

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ