Skip to contentSkip to conversation

drivers/power/supply/cw2015_battery.c:692:12-18: ERROR: application of sizeof to pointer

PATCH kernel test robot 1 participant 2 messages Jan 17, 2022

Subsystems (2)
lore
Share & tools
lore
author build bot
#1 lore raw

[PATCH] power: supply_core: fix noderef.cocci warnings

In reply to kernel test robot
drivers/power/supply/cw2015_battery.c:692:12-18: ERROR: application of sizeof to pointer

From: kernel test robot <[email protected]>

drivers/power/supply/cw2015_battery.c:692:12-18: ERROR: application of sizeof to pointer

sizeof when applied to a pointer typed expression gives the size of the pointer

Generated by: scripts/coccinelle/misc/noderef.cocci

Fixes 0839e7a54fc2 ("power: supply_core: Pass pointer to battery info")

---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-nomadik.git ux500-href-charging-v5.16-rc1
head:   1e846b0b60ac01cac4f283975a1bc395ff73d995
commit: 0839e7a54fc2233ea74b21651d022b981c124f78 [32/58] power: supply_core: Pass pointer to battery info

:::::: branch date: 2 days ago
:::::: commit date: 4 weeks ago

 cw2015_battery.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/cw2015_battery.c +1 -1
@@ -689,7 +689,7 @@ static int cw_bat_probe(struct i2c_clien
 	if (ret) {
 		/* Allocate an empty battery */
 		cw_bat->battery = devm_kzalloc(&client->dev,
-					       sizeof(cw_bat->battery),
+					       sizeof(*cw_bat->battery),
 					       GFP_KERNEL);
 		if (!cw_bat->battery)
 			return -ENOMEM;

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-nomadik.git ux500-href-charging-v5.16-rc1
head:   1e846b0b60ac01cac4f283975a1bc395ff73d995
commit: 0839e7a54fc2233ea74b21651d022b981c124f78 [32/58] power: supply_core: Pass pointer to battery info
config: xtensa-randconfig-c004-20220116 (https://download.01.org/0day-ci/archive/20220117/202201170953.yxBdZqTf-lkp(a)intel.com/config)
compiler: xtensa-linux-gcc (GCC) 11.2.0

If you fix the issue, kindly add following tag as appropriate

cocci warnings: (new ones prefixed by >>)

>> drivers/power/supply/cw2015_battery.c:692:12-18: ERROR: application of sizeof to pointer

Please review and possibly fold the followup patch.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org