All of lore.kernel.org
 help / color / mirror / Atom feed
* drivers/hwmon/occ/common.c:554:9-17: WARNING: use scnprintf or sprintf
@ 2020-11-19  7:24 kernel test robot
  2020-11-19  7:24 ` [PATCH] coccinelle: api: fix device_attr_show.cocci warnings kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2020-11-19  7:24 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 1639 bytes --]

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Denis Efremov <efremov@linux.com>
CC: Julia Lawall <Julia.Lawall@lip6.fr>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   c2e7554e1b85935d962127efa3c2a76483b0b3b6
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script
date:   4 months ago
:::::: branch date: 11 hours ago
:::::: commit date: 4 months ago
config: arm-randconfig-c004-20201119 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>


"coccinelle warnings: (new ones prefixed by >>)"
>> drivers/hwmon/occ/common.c:554:9-17: WARNING: use scnprintf or sprintf
   drivers/hwmon/occ/common.c:604:9-17: WARNING: use scnprintf or sprintf
   drivers/hwmon/occ/common.c:337:8-16: WARNING: use scnprintf or sprintf
   drivers/hwmon/occ/common.c:367:8-16: WARNING: use scnprintf or sprintf
   drivers/hwmon/occ/common.c:406:8-16: WARNING: use scnprintf or sprintf
   drivers/hwmon/occ/common.c:435:9-17: WARNING: use scnprintf or sprintf
   drivers/hwmon/occ/common.c:474:9-17: WARNING: use scnprintf or sprintf
   drivers/hwmon/occ/common.c:256:8-16: WARNING: use scnprintf or sprintf
   drivers/hwmon/occ/common.c:307:8-16: WARNING: use scnprintf or sprintf

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

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 25581 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] coccinelle: api: fix device_attr_show.cocci warnings
  2020-11-19  7:24 drivers/hwmon/occ/common.c:554:9-17: WARNING: use scnprintf or sprintf kernel test robot
@ 2020-11-19  7:24 ` kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2020-11-19  7:24 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 6695 bytes --]

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Denis Efremov <efremov@linux.com>
CC: Julia Lawall <Julia.Lawall@lip6.fr>
CC: Jean Delvare <jdelvare@suse.com>
CC: Guenter Roeck <linux@roeck-us.net>
CC: linux-hwmon(a)vger.kernel.org
CC: linux-kernel(a)vger.kernel.org

From: kernel test robot <lkp@intel.com>

drivers/hwmon/occ/common.c:554:9-17: WARNING: use scnprintf or sprintf
drivers/hwmon/occ/common.c:604:9-17: WARNING: use scnprintf or sprintf
drivers/hwmon/occ/common.c:337:8-16: WARNING: use scnprintf or sprintf
drivers/hwmon/occ/common.c:367:8-16: WARNING: use scnprintf or sprintf
drivers/hwmon/occ/common.c:406:8-16: WARNING: use scnprintf or sprintf
drivers/hwmon/occ/common.c:435:9-17: WARNING: use scnprintf or sprintf
drivers/hwmon/occ/common.c:474:9-17: WARNING: use scnprintf or sprintf
drivers/hwmon/occ/common.c:256:8-16: WARNING: use scnprintf or sprintf
drivers/hwmon/occ/common.c:307:8-16: WARNING: use scnprintf or sprintf


 From Documentation/filesystems/sysfs.txt:
  show() must not use snprintf() when formatting the value to be
  returned to user space. If you can guarantee that an overflow
  will never happen you can use sprintf() otherwise you must use
  scnprintf().

Generated by: scripts/coccinelle/api/device_attr_show.cocci

Fixes: abfc19ff202d ("coccinelle: api: add device_attr_show script")
CC: Denis Efremov <efremov@linux.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: kernel test robot <lkp@intel.com>
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   c2e7554e1b85935d962127efa3c2a76483b0b3b6
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script
:::::: branch date: 11 hours ago
:::::: commit date: 4 months ago

Please take the patch only if it's a positive warning. Thanks!

 common.c |   32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

--- a/drivers/hwmon/occ/common.c
+++ b/drivers/hwmon/occ/common.c
@@ -253,7 +253,7 @@ static ssize_t occ_show_temp_1(struct de
 		return -EINVAL;
 	}
 
-	return snprintf(buf, PAGE_SIZE - 1, "%u\n", val);
+	return scnprintf(buf, PAGE_SIZE - 1, "%u\n", val);
 }
 
 static ssize_t occ_show_temp_2(struct device *dev,
@@ -304,7 +304,7 @@ static ssize_t occ_show_temp_2(struct de
 		return -EINVAL;
 	}
 
-	return snprintf(buf, PAGE_SIZE - 1, "%u\n", val);
+	return scnprintf(buf, PAGE_SIZE - 1, "%u\n", val);
 }
 
 static ssize_t occ_show_freq_1(struct device *dev,
@@ -334,7 +334,7 @@ static ssize_t occ_show_freq_1(struct de
 		return -EINVAL;
 	}
 
-	return snprintf(buf, PAGE_SIZE - 1, "%u\n", val);
+	return scnprintf(buf, PAGE_SIZE - 1, "%u\n", val);
 }
 
 static ssize_t occ_show_freq_2(struct device *dev,
@@ -364,7 +364,7 @@ static ssize_t occ_show_freq_2(struct de
 		return -EINVAL;
 	}
 
-	return snprintf(buf, PAGE_SIZE - 1, "%u\n", val);
+	return scnprintf(buf, PAGE_SIZE - 1, "%u\n", val);
 }
 
 static ssize_t occ_show_power_1(struct device *dev,
@@ -403,7 +403,7 @@ static ssize_t occ_show_power_1(struct d
 		return -EINVAL;
 	}
 
-	return snprintf(buf, PAGE_SIZE - 1, "%llu\n", val);
+	return scnprintf(buf, PAGE_SIZE - 1, "%llu\n", val);
 }
 
 static u64 occ_get_powr_avg(u64 *accum, u32 *samples)
@@ -432,7 +432,7 @@ static ssize_t occ_show_power_2(struct d
 
 	switch (sattr->nr) {
 	case 0:
-		return snprintf(buf, PAGE_SIZE - 1, "%u_%u_%u\n",
+		return scnprintf(buf, PAGE_SIZE - 1, "%u_%u_%u\n",
 				get_unaligned_be32(&power->sensor_id),
 				power->function_id, power->apss_channel);
 	case 1:
@@ -450,7 +450,7 @@ static ssize_t occ_show_power_2(struct d
 		return -EINVAL;
 	}
 
-	return snprintf(buf, PAGE_SIZE - 1, "%llu\n", val);
+	return scnprintf(buf, PAGE_SIZE - 1, "%llu\n", val);
 }
 
 static ssize_t occ_show_power_a0(struct device *dev,
@@ -471,7 +471,7 @@ static ssize_t occ_show_power_a0(struct
 
 	switch (sattr->nr) {
 	case 0:
-		return snprintf(buf, PAGE_SIZE - 1, "%u_system\n",
+		return scnprintf(buf, PAGE_SIZE - 1, "%u_system\n",
 				get_unaligned_be32(&power->sensor_id));
 	case 1:
 		val = occ_get_powr_avg(&power->system.accumulator,
@@ -485,7 +485,7 @@ static ssize_t occ_show_power_a0(struct
 		val = get_unaligned_be16(&power->system.value) * 1000000ULL;
 		break;
 	case 4:
-		return snprintf(buf, PAGE_SIZE - 1, "%u_proc\n",
+		return scnprintf(buf, PAGE_SIZE - 1, "%u_proc\n",
 				get_unaligned_be32(&power->sensor_id));
 	case 5:
 		val = occ_get_powr_avg(&power->proc.accumulator,
@@ -499,7 +499,7 @@ static ssize_t occ_show_power_a0(struct
 		val = get_unaligned_be16(&power->proc.value) * 1000000ULL;
 		break;
 	case 8:
-		return snprintf(buf, PAGE_SIZE - 1, "%u_vdd\n",
+		return scnprintf(buf, PAGE_SIZE - 1, "%u_vdd\n",
 				get_unaligned_be32(&power->sensor_id));
 	case 9:
 		val = occ_get_powr_avg(&power->vdd.accumulator,
@@ -513,7 +513,7 @@ static ssize_t occ_show_power_a0(struct
 		val = get_unaligned_be16(&power->vdd.value) * 1000000ULL;
 		break;
 	case 12:
-		return snprintf(buf, PAGE_SIZE - 1, "%u_vdn\n",
+		return scnprintf(buf, PAGE_SIZE - 1, "%u_vdn\n",
 				get_unaligned_be32(&power->sensor_id));
 	case 13:
 		val = occ_get_powr_avg(&power->vdn.accumulator,
@@ -530,7 +530,7 @@ static ssize_t occ_show_power_a0(struct
 		return -EINVAL;
 	}
 
-	return snprintf(buf, PAGE_SIZE - 1, "%llu\n", val);
+	return scnprintf(buf, PAGE_SIZE - 1, "%llu\n", val);
 }
 
 static ssize_t occ_show_caps_1_2(struct device *dev,
@@ -551,7 +551,7 @@ static ssize_t occ_show_caps_1_2(struct
 
 	switch (sattr->nr) {
 	case 0:
-		return snprintf(buf, PAGE_SIZE - 1, "system\n");
+		return scnprintf(buf, PAGE_SIZE - 1, "system\n");
 	case 1:
 		val = get_unaligned_be16(&caps->cap) * 1000000ULL;
 		break;
@@ -580,7 +580,7 @@ static ssize_t occ_show_caps_1_2(struct
 		return -EINVAL;
 	}
 
-	return snprintf(buf, PAGE_SIZE - 1, "%llu\n", val);
+	return scnprintf(buf, PAGE_SIZE - 1, "%llu\n", val);
 }
 
 static ssize_t occ_show_caps_3(struct device *dev,
@@ -601,7 +601,7 @@ static ssize_t occ_show_caps_3(struct de
 
 	switch (sattr->nr) {
 	case 0:
-		return snprintf(buf, PAGE_SIZE - 1, "system\n");
+		return scnprintf(buf, PAGE_SIZE - 1, "system\n");
 	case 1:
 		val = get_unaligned_be16(&caps->cap) * 1000000ULL;
 		break;
@@ -627,7 +627,7 @@ static ssize_t occ_show_caps_3(struct de
 		return -EINVAL;
 	}
 
-	return snprintf(buf, PAGE_SIZE - 1, "%llu\n", val);
+	return scnprintf(buf, PAGE_SIZE - 1, "%llu\n", val);
 }
 
 static ssize_t occ_store_caps_user(struct device *dev,

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-19  7:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-19  7:24 drivers/hwmon/occ/common.c:554:9-17: WARNING: use scnprintf or sprintf kernel test robot
2020-11-19  7:24 ` [PATCH] coccinelle: api: fix device_attr_show.cocci warnings 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.