Skip to content

Commit 17f18e0

Browse files
andy-shevgregkh
authored andcommitted
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 <[email protected]> Reviewed-by: Amit Shah <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 790b2f2 commit 17f18e0

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

drivers/char/virtio_console.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,6 @@ static void send_sigio_to_port(struct port *port)
13211321

13221322
static int add_port(struct ports_device *portdev, u32 id)
13231323
{
1324-
char debugfs_name[16];
13251324
struct port *port;
13261325
dev_t devt;
13271326
int err;
@@ -1424,9 +1423,7 @@ static int add_port(struct ports_device *portdev, u32 id)
14241423
* Finally, create the debugfs file that we can use to
14251424
* inspect a port's state at any time
14261425
*/
1427-
snprintf(debugfs_name, sizeof(debugfs_name), "vport%up%u",
1428-
port->portdev->vdev->index, id);
1429-
port->debugfs_file = debugfs_create_file(debugfs_name, 0444,
1426+
port->debugfs_file = debugfs_create_file(dev_name(port->dev), 0444,
14301427
pdrvdata.debugfs_dir,
14311428
port, &port_debugfs_fops);
14321429
return 0;

0 commit comments

Comments
 (0)