From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com
Subject: drivers/hwmon/emc2305.c:248:27: warning: Either the condition 'ret<=0' is redundant or there is division by zero at line 248. [zerodivcond]
Date: Thu, 16 Feb 2023 11:05:55 +0800 [thread overview]
Message-ID: <202302161009.cTUrz4Ed-lkp@intel.com> (raw)
::::::
:::::: 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
reply other threads:[~2023-02-16 3:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202302161009.cTUrz4Ed-lkp@intel.com \
--to=lkp@intel.com \
--cc=oe-kbuild@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.