mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usbip: vhci: fix -Wformat-truncation warning in vhci_sysfs
@ 2026-09-13 17:00 Ricardo Barbosa Dias
  0 siblings, 0 replies; only message in thread
From: Ricardo Barbosa Dias @ 2026-09-13 17:00 UTC (permalink / raw)
  To: shuah, valentina.manea.m, gregkh
  Cc: i, linux-usb, linux-kernel, Ricardo Barbosa Dias

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@gmail.com>
---
 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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-13 17:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-13 17:00 [PATCH] usbip: vhci: fix -Wformat-truncation warning in vhci_sysfs Ricardo Barbosa Dias

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®