]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
vdpa: Convert sprintf/snprintf to sysfs_emit
authorLi Zhijian <lizhijian@fujitsu.com>
Thu, 14 Mar 2024 09:58:53 +0000 (17:58 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 22 May 2024 12:31:15 +0000 (08:31 -0400)
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.

coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().

sprintf() will be converted as weel if they have.

Generally, this patch is generated by
make coccicheck M=<path/to/file> MODE=patch \
COCCI=scripts/coccinelle/api/device_attr_show.cocci

No functional change intended

CC: "Michael S. Tsirkin" <mst@redhat.com>
CC: Jason Wang <jasowang@redhat.com>
CC: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
CC: virtualization@lists.linux.dev
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
Message-Id: <20240314095853.1326111-1-lizhijian@fujitsu.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vdpa/vdpa.c

index 6cb96a1e8b7df453c00ac0eaf9a568908f743c9f..8d391947eb8de56563fc650ed7b8fda8f44df6a7 100644 (file)
@@ -98,7 +98,7 @@ static ssize_t driver_override_show(struct device *dev,
        ssize_t len;
 
        device_lock(dev);
-       len = snprintf(buf, PAGE_SIZE, "%s\n", vdev->driver_override);
+       len = sysfs_emit(buf, "%s\n", vdev->driver_override);
        device_unlock(dev);
 
        return len;