[PATCH] usbip: vhci: fix -Wformat-truncation warning in vhci_sysfs

From: Ricardo Barbosa Dias

Date: Sun Sep 13 2026 - 13:01:48 EST


Fix a compilation warning reported by GCC when building with W=1:

drivers/usb/usbip/vhci_sysfs.c:474:67: error: '%d' directive output may be
truncated writing between 1 and 11 bytes into a region of size 10
[-Werror=format-truncation=]

Although vhci_num_controllers is bounded between 1 and 32 in Kconfig,
the compiler performs static analysis considering the full range of a
signed integer.

Increase MAX_STATUS_NAME in vhci.h to 18 to ensure the buffer char array
can accommodate the theoretical maximum length of formatted status names,
silencing the format-truncation warning.

Signed-off-by: Ricardo Barbosa Dias <ricardobarbosamscg@xxxxxxxxx>
---
drivers/usb/usbip/vhci.h | 2 +-
drivers/usb/usbip/vhci_sysfs.c | 2 --
2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/usb/usbip/vhci.h b/drivers/usb/usbip/vhci.h
index 5659dce15..2c09fcb61 100644
--- a/drivers/usb/usbip/vhci.h
+++ b/drivers/usb/usbip/vhci.h
@@ -88,7 +88,7 @@ enum hub_speed {
#define VHCI_NR_HCS 1
#endif

-#define MAX_STATUS_NAME 16
+#define MAX_STATUS_NAME 18

struct vhci {
spinlock_t lock;
diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
index a7ede6fb3..d870e2c27 100644
--- a/drivers/usb/usbip/vhci_sysfs.c
+++ b/drivers/usb/usbip/vhci_sysfs.c
@@ -454,8 +454,6 @@ static ssize_t attach_store(struct device *dev, struct device_attribute *attr,
}
static DEVICE_ATTR_WO(attach);

-#define MAX_STATUS_NAME 16
-
struct status_attr {
struct device_attribute attr;
char name[MAX_STATUS_NAME+1];
--
2.43.0