Skip to contentSkip to conversation

mm/backing-dev.c:209:8-16: WARNING: use scnprintf or sprintf

DISCUSSION kernel test robot 1 participant 7 messages Dec 14, 2020

Subsystems (8)
lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Denis Efremov <[email protected]>
CC: Julia Lawall <[email protected]>

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

:::::: branch date: 16 hours ago
:::::: commit date: 4 months ago
config: c6x-randconfig-c004-20201213 (attached as .config)
compiler: c6x-elf-gcc (GCC) 9.3.0

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

"coccinelle warnings: (new ones prefixed by >>)"

>> mm/backing-dev.c:209:8-16: WARNING: use scnprintf or sprintf
--
>> drivers/most/core.c:254:8-16: WARNING: use scnprintf or sprintf

drivers/most/core.c:398:8-16: WARNING: use scnprintf or sprintf drivers/most/core.c:409:9-17: WARNING: use scnprintf or sprintf drivers/most/core.c:211:8-16: WARNING: use scnprintf or sprintf drivers/most/core.c:222:8-16: WARNING: use scnprintf or sprintf drivers/most/core.c:272:8-16: WARNING: use scnprintf or sprintf drivers/most/core.c:297:10-18: WARNING: use scnprintf or sprintf drivers/most/core.c:326:8-16: WARNING: use scnprintf or sprintf drivers/most/core.c:282:9-17: WARNING: use scnprintf or sprintf drivers/most/core.c:263:8-16: WARNING: use scnprintf or sprintf drivers/most/core.c:318:8-16: WARNING: use scnprintf or sprintf drivers/most/core.c:309:8-16: WARNING: use scnprintf or sprintf drivers/most/core.c:233:8-16: WARNING: use scnprintf or sprintf drivers/most/core.c:244:8-16: WARNING: use scnprintf or sprintf
--

>> drivers/char/hw_random/core.c:399:8-16: WARNING: use scnprintf or sprintf
--
>> drivers/gpu/drm/drm_sysfs.c:172:8-16: WARNING: use scnprintf or sprintf
   drivers/gpu/drm/drm_sysfs.c:185:8-16: WARNING: use scnprintf or sprintf
   drivers/gpu/drm/drm_sysfs.c:159:8-16: WARNING: use scnprintf or sprintf
--
>> drivers/misc/enclosure.c:427:8-16: WARNING: use scnprintf or sprintf

drivers/misc/enclosure.c:540:8-16: WARNING: use scnprintf or sprintf drivers/misc/enclosure.c:482:8-16: WARNING: use scnprintf or sprintf drivers/misc/enclosure.c:564:8-16: WARNING: use scnprintf or sprintf drivers/misc/enclosure.c:594:8-16: WARNING: use scnprintf or sprintf drivers/misc/enclosure.c:639:8-16: WARNING: use scnprintf or sprintf drivers/misc/enclosure.c:506:8-16: WARNING: use scnprintf or sprintf drivers/misc/enclosure.c:624:8-16: WARNING: use scnprintf or sprintf
--

>> drivers/video/fbdev/core/fbcon.c:3509:8-16: WARNING: use scnprintf or sprintf
   drivers/video/fbdev/core/fbcon.c:3484:8-16: WARNING: use scnprintf or sprintf
--
>> drivers/video/fbdev/core/fbsysfs.c:233:8-16: WARNING: use scnprintf or sprintf

drivers/video/fbdev/core/fbsysfs.c:421:8-16: WARNING: use scnprintf or sprintf drivers/video/fbdev/core/fbsysfs.c:393:8-16: WARNING: use scnprintf or sprintf drivers/video/fbdev/core/fbsysfs.c:384:8-16: WARNING: use scnprintf or sprintf drivers/video/fbdev/core/fbsysfs.c:260:8-16: WARNING: use scnprintf or sprintf drivers/video/fbdev/core/fbsysfs.c:296:8-16: WARNING: use scnprintf or sprintf drivers/video/fbdev/core/fbsysfs.c:288:8-16: WARNING: use scnprintf or sprintf
--

>> drivers/char/ipmi/ipmi_msghandler.c:2694:8-16: WARNING: use scnprintf or sprintf

drivers/char/ipmi/ipmi_msghandler.c:2743:8-16: WARNING: use scnprintf or sprintf drivers/char/ipmi/ipmi_msghandler.c:2612:8-16: WARNING: use scnprintf or sprintf drivers/char/ipmi/ipmi_msghandler.c:2659:8-16: WARNING: use scnprintf or sprintf drivers/char/ipmi/ipmi_msghandler.c:2765:8-16: WARNING: use scnprintf or sprintf drivers/char/ipmi/ipmi_msghandler.c:2676:8-16: WARNING: use scnprintf or sprintf drivers/char/ipmi/ipmi_msghandler.c:2711:8-16: WARNING: use scnprintf or sprintf drivers/char/ipmi/ipmi_msghandler.c:2727:8-16: WARNING: use scnprintf or sprintf drivers/char/ipmi/ipmi_msghandler.c:2628:8-16: WARNING: use scnprintf or sprintf drivers/char/ipmi/ipmi_msghandler.c:2643:8-16: WARNING: use scnprintf or sprintf
--

>> drivers/ata/libata-sata.c:954:8-16: WARNING: use scnprintf or sprintf
   drivers/ata/libata-sata.c:830:8-16: WARNING: use scnprintf or sprintf
--
>> drivers/mtd/mtdpart.c:220:8-16: WARNING: use scnprintf or sprintf
--
>> drivers/scsi/scsi_sysfs.c:671:8-16: WARNING: use scnprintf or sprintf

drivers/scsi/scsi_sysfs.c:662:8-16: WARNING: use scnprintf or sprintf drivers/scsi/scsi_sysfs.c:1068:9-17: WARNING: use scnprintf or sprintf drivers/scsi/scsi_sysfs.c:704:8-16: WARNING: use scnprintf or sprintf drivers/scsi/scsi_sysfs.c:935:8-16: WARNING: use scnprintf or sprintf drivers/scsi/scsi_sysfs.c:1158:8-16: WARNING: use scnprintf or sprintf drivers/scsi/scsi_sysfs.c:683:8-16: WARNING: use scnprintf or sprintf drivers/scsi/scsi_sysfs.c:385:8-16: WARNING: use scnprintf or sprintf drivers/scsi/scsi_sysfs.c:910:8-16: WARNING: use scnprintf or sprintf drivers/scsi/scsi_sysfs.c:833:8-16: WARNING: use scnprintf or sprintf drivers/scsi/scsi_sysfs.c:276:9-17: WARNING: use scnprintf or sprintf drivers/scsi/scsi_sysfs.c:326:9-17: WARNING: use scnprintf or sprintf drivers/scsi/scsi_sysfs.c:230:8-16: WARNING: use scnprintf or sprintf drivers/scsi/scsi_sysfs.c:818:8-16: WARNING: use scnprintf or sprintf
--

>> drivers/scsi/scsi_transport_fc.c:1557:9-17: WARNING: use scnprintf or sprintf

drivers/scsi/scsi_transport_fc.c:1481:9-17: WARNING: use scnprintf or sprintf drivers/scsi/scsi_transport_fc.c:1505:9-17: WARNING: use scnprintf or sprintf drivers/scsi/scsi_transport_fc.c:1590:8-16: WARNING: use scnprintf or sprintf drivers/scsi/scsi_transport_fc.c:955:9-17: WARNING: use scnprintf or sprintf drivers/scsi/scsi_transport_fc.c:921:10-18: WARNING: use scnprintf or sprintf drivers/scsi/scsi_transport_fc.c:826:9-17: WARNING: use scnprintf or sprintf drivers/scsi/scsi_transport_fc.c:1255:9-17: 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

author build bot
#1 lore raw

[PATCH] coccinelle: api: fix device_attr_show.cocci warnings

CC: kbuild-all(a)lists.01.org CC: linux-kernel(a)vger.kernel.org TO: Denis Efremov <[email protected]> CC: Julia Lawall <[email protected]> CC: "Greg Kroah-Hartman" <[email protected]>…

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Denis Efremov <[email protected]>
CC: Julia Lawall <[email protected]>
CC: "Greg Kroah-Hartman" <[email protected]>
CC: Christian Gromm <[email protected]>
CC: Masahiro Yamada <[email protected]>
CC: Takashi Iwai <[email protected]>
CC: linux-kernel(a)vger.kernel.org

From: kernel test robot <[email protected]>

drivers/most/core.c:254:8-16: WARNING: use scnprintf or sprintf drivers/most/core.c:398:8-16: WARNING: use scnprintf or sprintf drivers/most/core.c:409:9-17: WARNING: use scnprintf or sprintf drivers/most/core.c:211:8-16: WARNING: use scnprintf or sprintf drivers/most/core.c:222:8-16: WARNING: use scnprintf or sprintf drivers/most/core.c:272:8-16: WARNING: use scnprintf or sprintf drivers/most/core.c:297:10-18: WARNING: use scnprintf or sprintf drivers/most/core.c:326:8-16: WARNING: use scnprintf or sprintf drivers/most/core.c:282:9-17: WARNING: use scnprintf or sprintf drivers/most/core.c:263:8-16: WARNING: use scnprintf or sprintf drivers/most/core.c:318:8-16: WARNING: use scnprintf or sprintf drivers/most/core.c:309:8-16: WARNING: use scnprintf or sprintf drivers/most/core.c:233:8-16: WARNING: use scnprintf or sprintf drivers/most/core.c:244: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 <[email protected]>

---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   2c85ebc57b3e1817b6ce1a6b703928e113a90442
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script

:::::: branch date: 16 hours ago
:::::: commit date: 4 months ago

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

 core.c |   52 ++++++++++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 26 deletions(-)
drivers/most/core.c +26 -26
@@ -208,7 +208,7 @@ static ssize_t number_of_packet_buffers_
 	struct most_channel *c = to_channel(dev);
 	unsigned int i = c->channel_id;
 
-	return snprintf(buf, PAGE_SIZE, "%d\n",
+	return scnprintf(buf, PAGE_SIZE, "%d\n",
 			c->iface->channel_vector[i].num_buffers_packet);
 }
 
@@ -219,7 +219,7 @@ static ssize_t number_of_stream_buffers_
 	struct most_channel *c = to_channel(dev);
 	unsigned int i = c->channel_id;
 
-	return snprintf(buf, PAGE_SIZE, "%d\n",
+	return scnprintf(buf, PAGE_SIZE, "%d\n",
 			c->iface->channel_vector[i].num_buffers_streaming);
 }
 
@@ -230,7 +230,7 @@ static ssize_t size_of_packet_buffer_sho
 	struct most_channel *c = to_channel(dev);
 	unsigned int i = c->channel_id;
 
-	return snprintf(buf, PAGE_SIZE, "%d\n",
+	return scnprintf(buf, PAGE_SIZE, "%d\n",
 			c->iface->channel_vector[i].buffer_size_packet);
 }
 
@@ -241,7 +241,7 @@ static ssize_t size_of_stream_buffer_sho
 	struct most_channel *c = to_channel(dev);
 	unsigned int i = c->channel_id;
 
-	return snprintf(buf, PAGE_SIZE, "%d\n",
+	return scnprintf(buf, PAGE_SIZE, "%d\n",
 			c->iface->channel_vector[i].buffer_size_streaming);
 }
 
@@ -251,7 +251,7 @@ static ssize_t channel_starving_show(str
 {
 	struct most_channel *c = to_channel(dev);
 
-	return snprintf(buf, PAGE_SIZE, "%d\n", c->is_starving);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", c->is_starving);
 }
 
 static ssize_t set_number_of_buffers_show(struct device *dev,
@@ -260,7 +260,7 @@ static ssize_t set_number_of_buffers_sho
 {
 	struct most_channel *c = to_channel(dev);
 
-	return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.num_buffers);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", c->cfg.num_buffers);
 }
 
 static ssize_t set_buffer_size_show(struct device *dev,
@@ -269,7 +269,7 @@ static ssize_t set_buffer_size_show(stru
 {
 	struct most_channel *c = to_channel(dev);
 
-	return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.buffer_size);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", c->cfg.buffer_size);
 }
 
 static ssize_t set_direction_show(struct device *dev,
@@ -279,10 +279,10 @@ static ssize_t set_direction_show(struct
 	struct most_channel *c = to_channel(dev);
 
 	if (c->cfg.direction & MOST_CH_TX)
-		return snprintf(buf, PAGE_SIZE, "tx\n");
+		return scnprintf(buf, PAGE_SIZE, "tx\n");
 	else if (c->cfg.direction & MOST_CH_RX)
-		return snprintf(buf, PAGE_SIZE, "rx\n");
-	return snprintf(buf, PAGE_SIZE, "unconfigured\n");
+		return scnprintf(buf, PAGE_SIZE, "rx\n");
+	return scnprintf(buf, PAGE_SIZE, "unconfigured\n");
 }
 
 static ssize_t set_datatype_show(struct device *dev,
@@ -294,10 +294,10 @@ static ssize_t set_datatype_show(struct
 
 	for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) {
 		if (c->cfg.data_type & ch_data_type[i].most_ch_data_type)
-			return snprintf(buf, PAGE_SIZE, "%s",
+			return scnprintf(buf, PAGE_SIZE, "%s",
 					ch_data_type[i].name);
 	}
-	return snprintf(buf, PAGE_SIZE, "unconfigured\n");
+	return scnprintf(buf, PAGE_SIZE, "unconfigured\n");
 }
 
 static ssize_t set_subbuffer_size_show(struct device *dev,
@@ -306,7 +306,7 @@ static ssize_t set_subbuffer_size_show(s
 {
 	struct most_channel *c = to_channel(dev);
 
-	return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.subbuffer_size);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", c->cfg.subbuffer_size);
 }
 
 static ssize_t set_packets_per_xact_show(struct device *dev,
@@ -315,7 +315,7 @@ static ssize_t set_packets_per_xact_show
 {
 	struct most_channel *c = to_channel(dev);
 
-	return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.packets_per_xact);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", c->cfg.packets_per_xact);
 }
 
 static ssize_t set_dbr_size_show(struct device *dev,
@@ -323,7 +323,7 @@ static ssize_t set_dbr_size_show(struct
 {
 	struct most_channel *c = to_channel(dev);
 
-	return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.dbr_size);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", c->cfg.dbr_size);
 }
 
 #define to_dev_attr(a) container_of(a, struct device_attribute, attr)
@@ -395,7 +395,7 @@ static ssize_t description_show(struct d
 {
 	struct most_interface *iface = dev_get_drvdata(dev);
 
-	return snprintf(buf, PAGE_SIZE, "%s\n", iface->description);
+	return scnprintf(buf, PAGE_SIZE, "%s\n", iface->description);
 }
 
 static ssize_t interface_show(struct device *dev,
@@ -406,25 +406,25 @@ static ssize_t interface_show(struct dev
 
 	switch (iface->interface) {
 	case ITYPE_LOOPBACK:
-		return snprintf(buf, PAGE_SIZE, "loopback\n");
+		return scnprintf(buf, PAGE_SIZE, "loopback\n");
 	case ITYPE_I2C:
-		return snprintf(buf, PAGE_SIZE, "i2c\n");
+		return scnprintf(buf, PAGE_SIZE, "i2c\n");
 	case ITYPE_I2S:
-		return snprintf(buf, PAGE_SIZE, "i2s\n");
+		return scnprintf(buf, PAGE_SIZE, "i2s\n");
 	case ITYPE_TSI:
-		return snprintf(buf, PAGE_SIZE, "tsi\n");
+		return scnprintf(buf, PAGE_SIZE, "tsi\n");
 	case ITYPE_HBI:
-		return snprintf(buf, PAGE_SIZE, "hbi\n");
+		return scnprintf(buf, PAGE_SIZE, "hbi\n");
 	case ITYPE_MEDIALB_DIM:
-		return snprintf(buf, PAGE_SIZE, "mlb_dim\n");
+		return scnprintf(buf, PAGE_SIZE, "mlb_dim\n");
 	case ITYPE_MEDIALB_DIM2:
-		return snprintf(buf, PAGE_SIZE, "mlb_dim2\n");
+		return scnprintf(buf, PAGE_SIZE, "mlb_dim2\n");
 	case ITYPE_USB:
-		return snprintf(buf, PAGE_SIZE, "usb\n");
+		return scnprintf(buf, PAGE_SIZE, "usb\n");
 	case ITYPE_PCIE:
-		return snprintf(buf, PAGE_SIZE, "pcie\n");
+		return scnprintf(buf, PAGE_SIZE, "pcie\n");
 	}
-	return snprintf(buf, PAGE_SIZE, "unknown\n");
+	return scnprintf(buf, PAGE_SIZE, "unknown\n");
 }
 
 static DEVICE_ATTR_RO(description);
author build bot
#2 lore raw

[PATCH] coccinelle: api: fix device_attr_show.cocci warnings

In reply to kernel test robot
CC: kbuild-all(a)lists.01.org CC: linux-kernel(a)vger.kernel.org TO: Denis Efremov <[email protected]> CC: Julia Lawall <[email protected]> CC: Matt Mackall <[email protected]> CC: Herbert Xu…

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Denis Efremov <[email protected]>
CC: Julia Lawall <[email protected]>
CC: Matt Mackall <[email protected]>
CC: Herbert Xu <[email protected]>
CC: Arnd Bergmann <[email protected]>
CC: "Greg Kroah-Hartman" <[email protected]>
CC: Colin Ian King <[email protected]>
CC: linux-crypto(a)vger.kernel.org
CC: linux-kernel(a)vger.kernel.org

From: kernel test robot <[email protected]>

drivers/char/hw_random/core.c:399: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 <[email protected]>

---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   2c85ebc57b3e1817b6ce1a6b703928e113a90442
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script

:::::: branch date: 16 hours ago
:::::: commit date: 4 months ago

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

 core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/hw_random/core.c +1 -1
@@ -396,7 +396,7 @@ static ssize_t hwrng_attr_selected_show(
 					struct device_attribute *attr,
 					char *buf)
 {
-	return snprintf(buf, PAGE_SIZE, "%d\n", cur_rng_set_by_user);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", cur_rng_set_by_user);
 }
 
 static DEVICE_ATTR(rng_current, S_IRUGO | S_IWUSR,
author build bot
#3 lore raw

[PATCH] coccinelle: api: fix device_attr_show.cocci warnings

In reply to kernel test robot
CC: kbuild-all(a)lists.01.org CC: linux-kernel(a)vger.kernel.org TO: Denis Efremov <[email protected]> CC: Julia Lawall <[email protected]> CC: Maarten Lankhorst…

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Denis Efremov <[email protected]>
CC: Julia Lawall <[email protected]>
CC: Maarten Lankhorst <[email protected]>
CC: Maxime Ripard <[email protected]>
CC: Thomas Zimmermann <[email protected]>
CC: David Airlie <[email protected]>
CC: Daniel Vetter <[email protected]>
CC: dri-devel(a)lists.freedesktop.org
CC: linux-kernel(a)vger.kernel.org

From: kernel test robot <[email protected]>

drivers/gpu/drm/drm_sysfs.c:172:8-16: WARNING: use scnprintf or sprintf drivers/gpu/drm/drm_sysfs.c:185:8-16: WARNING: use scnprintf or sprintf drivers/gpu/drm/drm_sysfs.c:159: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 <[email protected]>

---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   2c85ebc57b3e1817b6ce1a6b703928e113a90442
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script

:::::: branch date: 16 hours ago
:::::: commit date: 4 months ago

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

 drm_sysfs.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_sysfs.c +3 -3
@@ -156,7 +156,7 @@ static ssize_t status_show(struct device
 
 	status = READ_ONCE(connector->status);
 
-	return snprintf(buf, PAGE_SIZE, "%s\n",
+	return scnprintf(buf, PAGE_SIZE, "%s\n",
 			drm_get_connector_status_name(status));
 }
 
@@ -169,7 +169,7 @@ static ssize_t dpms_show(struct device *
 
 	dpms = READ_ONCE(connector->dpms);
 
-	return snprintf(buf, PAGE_SIZE, "%s\n",
+	return scnprintf(buf, PAGE_SIZE, "%s\n",
 			drm_get_dpms_name(dpms));
 }
 
@@ -182,7 +182,7 @@ static ssize_t enabled_show(struct devic
 
 	enabled = READ_ONCE(connector->encoder);
 
-	return snprintf(buf, PAGE_SIZE, enabled ? "enabled\n" : "disabled\n");
+	return scnprintf(buf, PAGE_SIZE, enabled ? "enabled\n" : "disabled\n");
 }
 
 static ssize_t edid_show(struct file *filp, struct kobject *kobj,
author build bot
#4 lore raw

[PATCH] coccinelle: api: fix device_attr_show.cocci warnings

In reply to kernel test robot
CC: kbuild-all(a)lists.01.org CC: linux-kernel(a)vger.kernel.org TO: Denis Efremov <[email protected]> CC: Julia Lawall <[email protected]> CC: Bartlomiej Zolnierkiewicz…

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Denis Efremov <[email protected]>
CC: Julia Lawall <[email protected]>
CC: Bartlomiej Zolnierkiewicz <[email protected]>
CC: dri-devel(a)lists.freedesktop.org
CC: linux-fbdev(a)vger.kernel.org
CC: linux-kernel(a)vger.kernel.org

From: kernel test robot <[email protected]>

drivers/video/fbdev/core/fbsysfs.c:233:8-16: WARNING: use scnprintf or sprintf drivers/video/fbdev/core/fbsysfs.c:421:8-16: WARNING: use scnprintf or sprintf drivers/video/fbdev/core/fbsysfs.c:393:8-16: WARNING: use scnprintf or sprintf drivers/video/fbdev/core/fbsysfs.c:384:8-16: WARNING: use scnprintf or sprintf drivers/video/fbdev/core/fbsysfs.c:260:8-16: WARNING: use scnprintf or sprintf drivers/video/fbdev/core/fbsysfs.c:296:8-16: WARNING: use scnprintf or sprintf drivers/video/fbdev/core/fbsysfs.c:288: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 <[email protected]>

---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   2c85ebc57b3e1817b6ce1a6b703928e113a90442
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script

:::::: branch date: 16 hours ago
:::::: commit date: 4 months ago

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

 fbsysfs.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/video/fbdev/core/fbsysfs.c +7 -7
@@ -230,7 +230,7 @@ static ssize_t show_bpp(struct device *d
 			char *buf)
 {
 	struct fb_info *fb_info = dev_get_drvdata(device);
-	return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.bits_per_pixel);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.bits_per_pixel);
 }
 
 static ssize_t store_rotate(struct device *device,
@@ -257,7 +257,7 @@ static ssize_t show_rotate(struct device
 {
 	struct fb_info *fb_info = dev_get_drvdata(device);
 
-	return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.rotate);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.rotate);
 }
 
 static ssize_t store_virtual(struct device *device,
@@ -285,7 +285,7 @@ static ssize_t show_virtual(struct devic
 			    struct device_attribute *attr, char *buf)
 {
 	struct fb_info *fb_info = dev_get_drvdata(device);
-	return snprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xres_virtual,
+	return scnprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xres_virtual,
 			fb_info->var.yres_virtual);
 }
 
@@ -293,7 +293,7 @@ static ssize_t show_stride(struct device
 			   struct device_attribute *attr, char *buf)
 {
 	struct fb_info *fb_info = dev_get_drvdata(device);
-	return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->fix.line_length);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", fb_info->fix.line_length);
 }
 
 static ssize_t store_blank(struct device *device,
@@ -381,7 +381,7 @@ static ssize_t show_pan(struct device *d
 			struct device_attribute *attr, char *buf)
 {
 	struct fb_info *fb_info = dev_get_drvdata(device);
-	return snprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xoffset,
+	return scnprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xoffset,
 			fb_info->var.yoffset);
 }
 
@@ -390,7 +390,7 @@ static ssize_t show_name(struct device *
 {
 	struct fb_info *fb_info = dev_get_drvdata(device);
 
-	return snprintf(buf, PAGE_SIZE, "%s\n", fb_info->fix.id);
+	return scnprintf(buf, PAGE_SIZE, "%s\n", fb_info->fix.id);
 }
 
 static ssize_t store_fbstate(struct device *device,
@@ -418,7 +418,7 @@ static ssize_t show_fbstate(struct devic
 			    struct device_attribute *attr, char *buf)
 {
 	struct fb_info *fb_info = dev_get_drvdata(device);
-	return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->state);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", fb_info->state);
 }
 
 #if IS_ENABLED(CONFIG_FB_BACKLIGHT)
author build bot
#5 lore raw

[PATCH] coccinelle: api: fix device_attr_show.cocci warnings

In reply to kernel test robot
CC: kbuild-all(a)lists.01.org CC: linux-kernel(a)vger.kernel.org TO: Denis Efremov <[email protected]> CC: Julia Lawall <[email protected]> CC: Jens Axboe <[email protected]> CC…

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Denis Efremov <[email protected]>
CC: Julia Lawall <[email protected]>
CC: Jens Axboe <[email protected]>
CC: linux-ide(a)vger.kernel.org
CC: linux-kernel(a)vger.kernel.org

From: kernel test robot <[email protected]>

drivers/ata/libata-sata.c:954:8-16: WARNING: use scnprintf or sprintf drivers/ata/libata-sata.c:830: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 <[email protected]>

---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   2c85ebc57b3e1817b6ce1a6b703928e113a90442
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script

:::::: branch date: 16 hours ago
:::::: commit date: 4 months ago

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

 libata-sata.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ata/libata-sata.c +2 -2
@@ -827,7 +827,7 @@ static ssize_t ata_scsi_lpm_show(struct
 	if (ap->target_lpm_policy >= ARRAY_SIZE(ata_lpm_policy_names))
 		return -EINVAL;
 
-	return snprintf(buf, PAGE_SIZE, "%s\n",
+	return scnprintf(buf, PAGE_SIZE, "%s\n",
 			ata_lpm_policy_names[ap->target_lpm_policy]);
 }
 DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR,
@@ -951,7 +951,7 @@ ata_scsi_em_message_type_show(struct dev
 	struct Scsi_Host *shost = class_to_shost(dev);
 	struct ata_port *ap = ata_shost_to_port(shost);
 
-	return snprintf(buf, 23, "%d\n", ap->em_message_type);
+	return scnprintf(buf, 23, "%d\n", ap->em_message_type);
 }
 DEVICE_ATTR(em_message_type, S_IRUGO,
 		  ata_scsi_em_message_type_show, NULL);
author build bot
#6 lore raw

[PATCH] coccinelle: api: fix device_attr_show.cocci warnings

In reply to kernel test robot
CC: kbuild-all(a)lists.01.org CC: linux-kernel(a)vger.kernel.org TO: Denis Efremov <[email protected]> CC: Julia Lawall <[email protected]> CC: Miquel Raynal <[email protected]> CC…

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Denis Efremov <[email protected]>
CC: Julia Lawall <[email protected]>
CC: Miquel Raynal <[email protected]>
CC: Richard Weinberger <[email protected]>
CC: Vignesh Raghavendra <[email protected]>
CC: linux-mtd(a)lists.infradead.org
CC: linux-kernel(a)vger.kernel.org

From: kernel test robot <[email protected]>

drivers/mtd/mtdpart.c:220: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 <[email protected]>

---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   2c85ebc57b3e1817b6ce1a6b703928e113a90442
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script

:::::: branch date: 16 hours ago
:::::: commit date: 4 months ago

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

 mtdpart.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/mtdpart.c +1 -1
@@ -217,7 +217,7 @@ static ssize_t mtd_partition_offset_show
 {
 	struct mtd_info *mtd = dev_get_drvdata(dev);
 
-	return snprintf(buf, PAGE_SIZE, "%lld\n", mtd->part.offset);
+	return scnprintf(buf, PAGE_SIZE, "%lld\n", mtd->part.offset);
 }
 
 static DEVICE_ATTR(offset, S_IRUGO, mtd_partition_offset_show, NULL);