All of lore.kernel.org
 help / color / mirror / Atom feed
* drivers/hwmon/emc2305.c:248:27: warning: Either the condition 'ret<=0' is redundant or there is division by zero at line 248. [zerodivcond]
@ 2023-02-16  3:05 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2023-02-16  3:05 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp

:::::: 
:::::: Manual check reason: "low confidence static check warning: drivers/hwmon/emc2305.c:248:27: warning: Either the condition 'ret<=0' is redundant or there is division by zero at line 248. [zerodivcond]"
:::::: 

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Michael Shych <michaelsh@nvidia.com>
CC: Guenter Roeck <linux@roeck-us.net>
CC: Vadim Pasternak <vadimp@nvidia.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   033c40a89f55525139fd5b6342281b09b97d05bf
commit: 0d8400c5a2ce1595f31b2f99e3139cf5bc5f35fd hwmon: (emc2305) add support for EMC2301/2/3/5 RPM-based PWM Fan Speed Controller.
date:   5 months ago
:::::: branch date: 4 hours ago
:::::: commit date: 5 months ago
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
reproduce (cppcheck warning):
        # apt-get install cppcheck
        git checkout 0d8400c5a2ce1595f31b2f99e3139cf5bc5f35fd
        cppcheck --quiet --enable=style,performance,portability --template=gcc FILE

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/r/202302161009.cTUrz4Ed-lkp@intel.com/


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

>> drivers/hwmon/emc2305.c:248:27: warning: Either the condition 'ret<=0' is redundant or there is division by zero at line 248. [zerodivcond]
    ret = EMC2305_RPM_FACTOR / ret;
                             ^
   drivers/hwmon/emc2305.c:244:10: note: Assuming that condition 'ret<=0' is not redundant
    if (ret <= 0)
            ^
   drivers/hwmon/emc2305.c:247:12: note: Assignment 'ret=ret>>3', assigned value is 0
    ret = ret >> EMC2305_TACH_REGS_UNUSE_BITS;
              ^
   drivers/hwmon/emc2305.c:248:27: note: Division by zero
    ret = EMC2305_RPM_FACTOR / ret;
                             ^

vim +248 drivers/hwmon/emc2305.c

0d8400c5a2ce15 Michael Shych 2022-08-10  236  
0d8400c5a2ce15 Michael Shych 2022-08-10  237  static int emc2305_show_fan(struct device *dev, int channel)
0d8400c5a2ce15 Michael Shych 2022-08-10  238  {
0d8400c5a2ce15 Michael Shych 2022-08-10  239  	struct emc2305_data *data = dev_get_drvdata(dev);
0d8400c5a2ce15 Michael Shych 2022-08-10  240  	struct i2c_client *client = data->client;
0d8400c5a2ce15 Michael Shych 2022-08-10  241  	int ret;
0d8400c5a2ce15 Michael Shych 2022-08-10  242  
0d8400c5a2ce15 Michael Shych 2022-08-10  243  	ret = i2c_smbus_read_word_swapped(client, EMC2305_REG_FAN_TACH(channel));
0d8400c5a2ce15 Michael Shych 2022-08-10  244  	if (ret <= 0)
0d8400c5a2ce15 Michael Shych 2022-08-10  245  		return ret;
0d8400c5a2ce15 Michael Shych 2022-08-10  246  
0d8400c5a2ce15 Michael Shych 2022-08-10  247  	ret = ret >> EMC2305_TACH_REGS_UNUSE_BITS;
0d8400c5a2ce15 Michael Shych 2022-08-10 @248  	ret = EMC2305_RPM_FACTOR / ret;
0d8400c5a2ce15 Michael Shych 2022-08-10  249  	if (ret <= EMC2305_TACH_RANGE_MIN)
0d8400c5a2ce15 Michael Shych 2022-08-10  250  		return 0;
0d8400c5a2ce15 Michael Shych 2022-08-10  251  
0d8400c5a2ce15 Michael Shych 2022-08-10  252  	return ret * EMC2305_TACH_CNT_MULTIPLIER;
0d8400c5a2ce15 Michael Shych 2022-08-10  253  }
0d8400c5a2ce15 Michael Shych 2022-08-10  254  

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

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

only message in thread, other threads:[~2023-02-16  3:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-16  3:05 drivers/hwmon/emc2305.c:248:27: warning: Either the condition 'ret<=0' is redundant or there is division by zero at line 248. [zerodivcond] 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.