Commit ff06ed7e authored by Ye Guojin's avatar Ye Guojin Committed by Jens Axboe

block: aoe: fixup coccinelle warnings

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: default avatarZeal Robot <zealci@zte.com.cn>
Signed-off-by: default avatarYe Guojin <ye.guojin@zte.com.cn>
Link: https://lore.kernel.org/r/20211021064931.1047687-1-ye.guojin@zte.com.cnSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent cbab6ae0
...@@ -37,8 +37,7 @@ static ssize_t aoedisk_show_state(struct device *dev, ...@@ -37,8 +37,7 @@ static ssize_t aoedisk_show_state(struct device *dev,
struct gendisk *disk = dev_to_disk(dev); struct gendisk *disk = dev_to_disk(dev);
struct aoedev *d = disk->private_data; struct aoedev *d = disk->private_data;
return snprintf(page, PAGE_SIZE, return sysfs_emit(page, "%s%s\n",
"%s%s\n",
(d->flags & DEVFL_UP) ? "up" : "down", (d->flags & DEVFL_UP) ? "up" : "down",
(d->flags & DEVFL_KICKME) ? ",kickme" : (d->flags & DEVFL_KICKME) ? ",kickme" :
(d->nopen && !(d->flags & DEVFL_UP)) ? ",closewait" : ""); (d->nopen && !(d->flags & DEVFL_UP)) ? ",closewait" : "");
...@@ -52,8 +51,8 @@ static ssize_t aoedisk_show_mac(struct device *dev, ...@@ -52,8 +51,8 @@ static ssize_t aoedisk_show_mac(struct device *dev,
struct aoetgt *t = d->targets[0]; struct aoetgt *t = d->targets[0];
if (t == NULL) if (t == NULL)
return snprintf(page, PAGE_SIZE, "none\n"); return sysfs_emit(page, "none\n");
return snprintf(page, PAGE_SIZE, "%pm\n", t->addr); return sysfs_emit(page, "%pm\n", t->addr);
} }
static ssize_t aoedisk_show_netif(struct device *dev, static ssize_t aoedisk_show_netif(struct device *dev,
struct device_attribute *attr, char *page) struct device_attribute *attr, char *page)
...@@ -85,7 +84,7 @@ static ssize_t aoedisk_show_netif(struct device *dev, ...@@ -85,7 +84,7 @@ static ssize_t aoedisk_show_netif(struct device *dev,
ne = nd; ne = nd;
nd = nds; nd = nds;
if (*nd == NULL) if (*nd == NULL)
return snprintf(page, PAGE_SIZE, "none\n"); return sysfs_emit(page, "none\n");
for (p = page; nd < ne; nd++) for (p = page; nd < ne; nd++)
p += scnprintf(p, PAGE_SIZE - (p-page), "%s%s", p += scnprintf(p, PAGE_SIZE - (p-page), "%s%s",
p == page ? "" : ",", (*nd)->name); p == page ? "" : ",", (*nd)->name);
...@@ -99,7 +98,7 @@ static ssize_t aoedisk_show_fwver(struct device *dev, ...@@ -99,7 +98,7 @@ static ssize_t aoedisk_show_fwver(struct device *dev,
struct gendisk *disk = dev_to_disk(dev); struct gendisk *disk = dev_to_disk(dev);
struct aoedev *d = disk->private_data; struct aoedev *d = disk->private_data;
return snprintf(page, PAGE_SIZE, "0x%04x\n", (unsigned int) d->fw_ver); return sysfs_emit(page, "0x%04x\n", (unsigned int) d->fw_ver);
} }
static ssize_t aoedisk_show_payload(struct device *dev, static ssize_t aoedisk_show_payload(struct device *dev,
struct device_attribute *attr, char *page) struct device_attribute *attr, char *page)
...@@ -107,7 +106,7 @@ static ssize_t aoedisk_show_payload(struct device *dev, ...@@ -107,7 +106,7 @@ static ssize_t aoedisk_show_payload(struct device *dev,
struct gendisk *disk = dev_to_disk(dev); struct gendisk *disk = dev_to_disk(dev);
struct aoedev *d = disk->private_data; struct aoedev *d = disk->private_data;
return snprintf(page, PAGE_SIZE, "%lu\n", d->maxbcnt); return sysfs_emit(page, "%lu\n", d->maxbcnt);
} }
static int aoedisk_debugfs_show(struct seq_file *s, void *ignored) static int aoedisk_debugfs_show(struct seq_file *s, void *ignored)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment