Re: [PATCH] HID: core: Fix bsize printk specifier in hid_report_raw_event()

From: Benjamin Tissoires

Date: Fri May 22 2026 - 04:47:16 EST


On May 22 2026, yaolu@xxxxxxxxxx wrote:
> From: Lu Yao <yaolu@xxxxxxxxxx>
>
> Fix the following warning during build time:
>
> drivers/hid/hid-core.c:2053:43: error: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘size_t’ {aka ‘unsigned int’} [-Werror=format=]
> drivers/hid/hid-core.c:2075:43: error: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘size_t’ {aka ‘unsigned int’} [-Werror=format=]
>
> Fixes: 2c85c61d1332 ("HID: pass the buffer size to hid_report_raw_event")
> Reported-by: k2ci <kernel-bot@xxxxxxxxxx>
> Signed-off-by: Lu Yao <yaolu@xxxxxxxxxx>

In addition to shashiko comments about %zu, it's already in linus' tree:
4d3a2a466b8d ("HID: core: Fix size_t specifier in hid_report_raw_event()")

Cheers,
Benjamin

> ---
> drivers/hid/hid-core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> index b3596851c719..c21c58d7bf02 100644
> --- a/drivers/hid/hid-core.c
> +++ b/drivers/hid/hid-core.c
> @@ -2050,7 +2050,7 @@ int hid_report_raw_event(struct hid_device *hid, enum hid_report_type type, u8 *
> return 0;
>
> if (unlikely(bsize < csize)) {
> - hid_warn_ratelimited(hid, "Event data for report %d is incorrect (%d vs %ld)\n",
> + hid_warn_ratelimited(hid, "Event data for report %d is incorrect (%d vs %u)\n",
> report->id, csize, bsize);
> return -EINVAL;
> }
> @@ -2072,7 +2072,7 @@ int hid_report_raw_event(struct hid_device *hid, enum hid_report_type type, u8 *
> rsize = max_buffer_size;
>
> if (bsize < rsize) {
> - hid_warn_ratelimited(hid, "Event data for report %d was too short (%d vs %ld)\n",
> + hid_warn_ratelimited(hid, "Event data for report %d was too short (%d vs %u)\n",
> report->id, rsize, bsize);
> return -EINVAL;
> }
> --
> 2.25.1
>
>