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

virtio_console: Get rid of unneeded temporary variable

When compiling a kernel with GCC using `make W=1` with CONFIG_WERROR=y
(which is default nowadays), the build fails:

drivers/char/virtio_console.c:1427:9: note: ‘snprintf’ output between 9 and 27 bytes into a destination of size 16

Indeed, GCC can't see the limits of the variables that are in use.
Fix this by using dev_name() of the newly created device that is
luckily the same as the string used for the DebugFS node name.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Amit Shah <amit@kernel.org>
Link: https://lore.kernel.org/r/20250210095946.4122771-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Andy Shevchenko and committed by
Greg Kroah-Hartman
17f18e04 790b2f24

+1 -4
+1 -4
drivers/char/virtio_console.c
··· 1321 1321 1322 1322 static int add_port(struct ports_device *portdev, u32 id) 1323 1323 { 1324 - char debugfs_name[16]; 1325 1324 struct port *port; 1326 1325 dev_t devt; 1327 1326 int err; ··· 1423 1424 * Finally, create the debugfs file that we can use to 1424 1425 * inspect a port's state at any time 1425 1426 */ 1426 - snprintf(debugfs_name, sizeof(debugfs_name), "vport%up%u", 1427 - port->portdev->vdev->index, id); 1428 - port->debugfs_file = debugfs_create_file(debugfs_name, 0444, 1427 + port->debugfs_file = debugfs_create_file(dev_name(port->dev), 0444, 1429 1428 pdrvdata.debugfs_dir, 1430 1429 port, &port_debugfs_fops); 1431 1430 return 0;