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

video: fbdev: replace snprintf in show functions with sysfs_emit

coccicheck complains about the use of snprintf() in sysfs show functions.

Fix the coccicheck warning:
WARNING: use scnprintf or sprintf.

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

Signed-off-by: Qing Wang <wangqing@vivo.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1634095680-4377-1-git-send-email-wangqing@vivo.com

authored by

Qing Wang and committed by
Sam Ravnborg
4701a0dd 26bc3371

+7 -7
+7 -7
drivers/video/fbdev/core/fbsysfs.c
··· 230 230 char *buf) 231 231 { 232 232 struct fb_info *fb_info = dev_get_drvdata(device); 233 - return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.bits_per_pixel); 233 + return sysfs_emit(buf, "%d\n", fb_info->var.bits_per_pixel); 234 234 } 235 235 236 236 static ssize_t store_rotate(struct device *device, ··· 257 257 { 258 258 struct fb_info *fb_info = dev_get_drvdata(device); 259 259 260 - return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.rotate); 260 + return sysfs_emit(buf, "%d\n", fb_info->var.rotate); 261 261 } 262 262 263 263 static ssize_t store_virtual(struct device *device, ··· 285 285 struct device_attribute *attr, char *buf) 286 286 { 287 287 struct fb_info *fb_info = dev_get_drvdata(device); 288 - return snprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xres_virtual, 288 + return sysfs_emit(buf, "%d,%d\n", fb_info->var.xres_virtual, 289 289 fb_info->var.yres_virtual); 290 290 } 291 291 ··· 293 293 struct device_attribute *attr, char *buf) 294 294 { 295 295 struct fb_info *fb_info = dev_get_drvdata(device); 296 - return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->fix.line_length); 296 + return sysfs_emit(buf, "%d\n", fb_info->fix.line_length); 297 297 } 298 298 299 299 static ssize_t store_blank(struct device *device, ··· 381 381 struct device_attribute *attr, char *buf) 382 382 { 383 383 struct fb_info *fb_info = dev_get_drvdata(device); 384 - return snprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xoffset, 384 + return sysfs_emit(buf, "%d,%d\n", fb_info->var.xoffset, 385 385 fb_info->var.yoffset); 386 386 } 387 387 ··· 390 390 { 391 391 struct fb_info *fb_info = dev_get_drvdata(device); 392 392 393 - return snprintf(buf, PAGE_SIZE, "%s\n", fb_info->fix.id); 393 + return sysfs_emit(buf, "%s\n", fb_info->fix.id); 394 394 } 395 395 396 396 static ssize_t store_fbstate(struct device *device, ··· 418 418 struct device_attribute *attr, char *buf) 419 419 { 420 420 struct fb_info *fb_info = dev_get_drvdata(device); 421 - return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->state); 421 + return sysfs_emit(buf, "%d\n", fb_info->state); 422 422 } 423 423 424 424 #if IS_ENABLED(CONFIG_FB_BACKLIGHT)