All of lore.kernel.org
 help / color / mirror / Atom feed
* [jlawall:for-5.9 1/7] drivers/most/core.c:254:8-16: WARNING: use scnprintf or sprintf
@ 2020-07-27  3:35 kernel test robot
  2020-07-27  3:35 ` [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-07-27  3:35 UTC (permalink / raw)
  To: kbuild

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

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux.git for-5.9
head:   89c775cf9e2b970ac05b0f659597a114da2457de
commit: 988676da837516bbfafda5478472fd4265f0de4e [1/7] coccinelle: api: add device_attr_show script
:::::: branch date: 2 days ago
:::::: commit date: 5 weeks ago
config: c6x-randconfig-c022-20200727 (attached as .config)
compiler: c6x-elf-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/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

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: 24761 bytes --]

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

* [PATCH] coccinelle: api: fix device_attr_show.cocci warnings
  2020-07-27  3:35 [jlawall:for-5.9 1/7] drivers/most/core.c:254:8-16: WARNING: use scnprintf or sprintf kernel test robot
@ 2020-07-27  3:35 ` kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2020-07-27  3:35 UTC (permalink / raw)
  To: kbuild

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

CC: kbuild-all(a)lists.01.org
TO: Denis Efremov <efremov@linux.com>
CC: Julia Lawall <Julia.Lawall@lip6.fr>
CC: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
CC: Christian Gromm <christian.gromm@microchip.com>
CC: Masahiro Yamada <masahiroy@kernel.org>
CC: Peikan Tsai <peikantsai@gmail.com>
CC: Takashi Iwai <tiwai@suse.de>
CC: linux-kernel(a)vger.kernel.org

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

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: 988676da8375 ("coccinelle: api: add device_attr_show script")
CC: Denis Efremov <efremov@linux.com>
Signed-off-by: kernel test robot <lkp@intel.com>
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux.git for-5.9
head:   89c775cf9e2b970ac05b0f659597a114da2457de
commit: 988676da837516bbfafda5478472fd4265f0de4e [1/7] coccinelle: api: add device_attr_show script
:::::: branch date: 2 days ago
:::::: commit date: 5 weeks ago

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

 core.c |   52 ++++++++++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

--- a/drivers/most/core.c
+++ b/drivers/most/core.c
@@ -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);

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

end of thread, other threads:[~2020-07-27  3:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-27  3:35 [jlawall:for-5.9 1/7] drivers/most/core.c:254:8-16: WARNING: use scnprintf or sprintf kernel test robot
2020-07-27  3:35 ` [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.