linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] virtio-blk: fixup coccinelle warnings
@ 2021-10-21  6:51 cgel.zte
  2021-10-21  7:08 ` Joe Perches
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: cgel.zte @ 2021-10-21  6:51 UTC (permalink / raw)
  To: mst
  Cc: jasowang, pbonzini, stefanha, axboe, virtualization, linux-block,
	linux-kernel, Ye Guojin, Zeal Robot

From: Ye Guojin <ye.guojin@zte.com.cn>

coccicheck complains about the use of snprintf() in sysfs show
functions:
WARNING  use scnprintf or sprintf

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Ye Guojin <ye.guojin@zte.com.cn>
---
 drivers/block/virtio_blk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 303caf2d17d0..8a71b2f9f4b7 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -624,7 +624,7 @@ cache_type_show(struct device *dev, struct device_attribute *attr, char *buf)
 	u8 writeback = virtblk_get_cache_mode(vblk->vdev);
 
 	BUG_ON(writeback >= ARRAY_SIZE(virtblk_cache_types));
-	return snprintf(buf, 40, "%s\n", virtblk_cache_types[writeback]);
+	return sysfs_emit(buf, "%s\n", virtblk_cache_types[writeback]);
 }
 
 static DEVICE_ATTR_RW(cache_type);
-- 
2.25.1


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

end of thread, other threads:[~2021-10-21 14:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21  6:51 [PATCH] virtio-blk: fixup coccinelle warnings cgel.zte
2021-10-21  7:08 ` Joe Perches
2021-10-21  9:15   ` Stefan Hajnoczi
2021-10-21  9:13 ` Stefan Hajnoczi
2021-10-21 14:35 ` Stefano Garzarella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).