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

macintosh/ams: Replace snprintf in show functions with sysfs_emit

show() must not use snprintf() when formatting the value to be returned
to user space.

Fix the following coccicheck warning:
drivers/macintosh/ams/ams-core.c:53: 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: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/1634280544-4581-1-git-send-email-wangqing@vivo.com

authored by

Qing Wang and committed by
Michael Ellerman
cc463998 5749e7c1

+1 -1
+1 -1
drivers/macintosh/ams/ams-core.c
··· 50 50 ams_sensors(&x, &y, &z); 51 51 mutex_unlock(&ams_info.lock); 52 52 53 - return snprintf(buf, PAGE_SIZE, "%d %d %d\n", x, y, z); 53 + return sysfs_emit(buf, "%d %d %d\n", x, y, z); 54 54 } 55 55 56 56 static DEVICE_ATTR(current, S_IRUGO, ams_show_current, NULL);