usb: gadget: Remove snprintf() from sysfs call-backs and replace with sysfs_emit()
authorLee Jones <lee@kernel.org>
Thu, 30 Nov 2023 10:54:38 +0000 (10:54 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 4 Dec 2023 13:25:17 +0000 (22:25 +0900)
commit38168e2de320b9c12132eb72cf1f1d3d411fe38c
treec409a56fb9237900228d4d0327b673fdb7c819d6
parent7d7f794482b74e39d8c0cd830333eb40fc0234d4
usb: gadget: Remove snprintf() from sysfs call-backs and replace with sysfs_emit()

Since snprintf() has the documented, but still rather strange trait of
returning the length of the data that *would have been* written to the
array if space were available, rather than the arguably more useful
length of data *actually* written, it is usually considered wise to use
something else instead in order to avoid confusion.

In the case of sysfs call-backs, new wrappers exist that do just that.

This patch replaces just one use of snprintf() found in the sysfs
.show() call-back with the new sysfs_emit() helper.

Link: https://lwn.net/Articles/69419/
Link: https://github.com/KSPP/linux/issues/105
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20231130105459.3208986-5-lee@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/configfs.c