From: Ricardo Barbosa Dias <ricardobarbosamscg@gmail.com>
To: shuah@kernel.org, valentina.manea.m@gmail.com,
gregkh@linuxfoundation.org
Cc: i@zenithal.me, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org,
Ricardo Barbosa Dias <ricardobarbosamscg@gmail.com>
Subject: [PATCH] usbip: vhci: fix -Wformat-truncation warning in vhci_sysfs
Date: Sun, 13 Sep 2026 17:00:38 +0000 [thread overview]
Message-ID: <20260913170038.119463-1-ricardobarbosamscg@gmail.com> (raw)
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
reply other threads:[~2026-09-13 17:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260913170038.119463-1-ricardobarbosamscg@gmail.com \
--to=ricardobarbosamscg@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=i@zenithal.me \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=valentina.manea.m@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox