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

From: Nathan Chancellor

Date: Mon May 18 2026 - 15:12:45 EST


Hi Geert,

On Mon, May 18, 2026 at 11:10:49AM +0200, Geert Uytterhoeven wrote:
> On Sun, 17 May 2026 at 06:51, Nathan Chancellor <nathan@xxxxxxxxxx> wrote:
> > --- 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 %zu)\n",
> > report->id, csize, bsize);
>
> Both report->id and csize are unsigned, so should use %u.
>
> > 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 %zu)\n",
> > report->id, rsize, bsize);
>
> Same here.
>
> > return -EINVAL;
> > }
>
> And more incorrect %d outside the context!

Yeah, I had noticed this as well but I decided to keep the patch
contained to only address the instances that the compiler warned about.
I do think this is worth addressing in a follow up patch, which either I
or the HID maintainers can do.

Thanks for the review!

Cheers,
Nathan