usbip: vhci: fix -Wformat-truncation warning in vhci_sysfs
Subsystems (2)
PATCH 1/1 usbip: vhci: fix -Wformat-truncation warning in vhci_sysfs
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 <[email protected]>
--- drivers/usb/usbip/vhci.h | 2 +- drivers/usb/usbip/vhci_sysfs.c | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/usb/usbip/vhci.h +1 -1
@@ -88,7 +88,7 @@ enum hub_speed {#define VHCI_NR_HCS 1#endif -#define MAX_STATUS_NAME 16 +#define MAX_STATUS_NAME 18struct vhci {spinlock_t lock;
drivers/usb/usbip/vhci_sysfs.c +0 -2
@@ -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 ];
Signature · 1 line
2.43.0