Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Ye Guojin <ye.guojin@zte.com.cn>
Link: https://lore.kernel.org/r/20211021064931.1047687-1-ye.guojin@zte.com.cn
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Ye Guojin and committed by
Jens Axboe
ff06ed7e cbab6ae0

+6 -7
+6 -7
drivers/block/aoe/aoeblk.c
··· 37 37 struct gendisk *disk = dev_to_disk(dev); 38 38 struct aoedev *d = disk->private_data; 39 39 40 - return snprintf(page, PAGE_SIZE, 41 - "%s%s\n", 40 + return sysfs_emit(page, "%s%s\n", 42 41 (d->flags & DEVFL_UP) ? "up" : "down", 43 42 (d->flags & DEVFL_KICKME) ? ",kickme" : 44 43 (d->nopen && !(d->flags & DEVFL_UP)) ? ",closewait" : ""); ··· 51 52 struct aoetgt *t = d->targets[0]; 52 53 53 54 if (t == NULL) 54 - return snprintf(page, PAGE_SIZE, "none\n"); 55 - return snprintf(page, PAGE_SIZE, "%pm\n", t->addr); 55 + return sysfs_emit(page, "none\n"); 56 + return sysfs_emit(page, "%pm\n", t->addr); 56 57 } 57 58 static ssize_t aoedisk_show_netif(struct device *dev, 58 59 struct device_attribute *attr, char *page) ··· 84 85 ne = nd; 85 86 nd = nds; 86 87 if (*nd == NULL) 87 - return snprintf(page, PAGE_SIZE, "none\n"); 88 + return sysfs_emit(page, "none\n"); 88 89 for (p = page; nd < ne; nd++) 89 90 p += scnprintf(p, PAGE_SIZE - (p-page), "%s%s", 90 91 p == page ? "" : ",", (*nd)->name); ··· 98 99 struct gendisk *disk = dev_to_disk(dev); 99 100 struct aoedev *d = disk->private_data; 100 101 101 - return snprintf(page, PAGE_SIZE, "0x%04x\n", (unsigned int) d->fw_ver); 102 + return sysfs_emit(page, "0x%04x\n", (unsigned int) d->fw_ver); 102 103 } 103 104 static ssize_t aoedisk_show_payload(struct device *dev, 104 105 struct device_attribute *attr, char *page) ··· 106 107 struct gendisk *disk = dev_to_disk(dev); 107 108 struct aoedev *d = disk->private_data; 108 109 109 - return snprintf(page, PAGE_SIZE, "%lu\n", d->maxbcnt); 110 + return sysfs_emit(page, "%lu\n", d->maxbcnt); 110 111 } 111 112 112 113 static int aoedisk_debugfs_show(struct seq_file *s, void *ignored)