Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH] HID: core: Fix bsize printk specifier in hid_report_raw_event()
@ 2026-05-22  7:27 yaolu
  2026-05-22  7:31 ` sashiko-bot
  2026-05-22  8:46 ` Benjamin Tissoires
  0 siblings, 2 replies; 3+ messages in thread
From: yaolu @ 2026-05-22  7:27 UTC (permalink / raw)
  To: jikos, bentiss; +Cc: linux-input, linux-kernel, Lu Yao, k2ci

From: Lu Yao <yaolu@kylinos.cn>

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@kylinos.cn>
Signed-off-by: Lu Yao <yaolu@kylinos.cn>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] HID: core: Fix bsize printk specifier in hid_report_raw_event()
  2026-05-22  7:27 [PATCH] HID: core: Fix bsize printk specifier in hid_report_raw_event() yaolu
@ 2026-05-22  7:31 ` sashiko-bot
  2026-05-22  8:46 ` Benjamin Tissoires
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-05-22  7:31 UTC (permalink / raw)
  To: yaolu; +Cc: linux-input, dmitry.torokhov

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Incorrect format specifier for the `size_t` variable `bsize`. The patch replaces `%ld` with `%u` to fix a warning on 32-bit architectures (where `size_t` is `unsigned int`), but this introduces a new warning on 64-bit architectures (where `size_t` is `unsigned long`). The correct format specifier for `size_t` is `%zu`.
--

commit d6a5fb9c76c9718771a50e1f79f29b3df496f869
Author: Lu Yao <yaolu@kylinos.cn>

HID: core: Fix bsize printk specifier in hid_report_raw_event()

This commit attempts to fix a build warning on 32-bit architectures by
changing the format specifier for a size_t variable from %ld to %u.

> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> index b3596851c7191..c21c58d7bf02b 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",

[Severity: Low]
Will this cause a new format string warning on 64-bit architectures? bsize is
of type size_t, which is an unsigned long on 64-bit systems. Should this use
the %zu format specifier instead to be portable across both 32-bit and 64-bit
architectures?

>  				     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",

[Severity: Low]
Similarly here, should this also use %zu for the size_t variable bsize?

>  				     report->id, rsize, bsize);
>  		return -EINVAL;
>  	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260522072718.186707-1-yaolu@kylinos.cn?part=1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] HID: core: Fix bsize printk specifier in hid_report_raw_event()
  2026-05-22  7:27 [PATCH] HID: core: Fix bsize printk specifier in hid_report_raw_event() yaolu
  2026-05-22  7:31 ` sashiko-bot
@ 2026-05-22  8:46 ` Benjamin Tissoires
  1 sibling, 0 replies; 3+ messages in thread
From: Benjamin Tissoires @ 2026-05-22  8:46 UTC (permalink / raw)
  To: yaolu; +Cc: jikos, linux-input, linux-kernel, k2ci

On May 22 2026, yaolu@kylinos.cn wrote:
> From: Lu Yao <yaolu@kylinos.cn>
> 
> 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@kylinos.cn>
> Signed-off-by: Lu Yao <yaolu@kylinos.cn>

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
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-22  8:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-22  7:27 [PATCH] HID: core: Fix bsize printk specifier in hid_report_raw_event() yaolu
2026-05-22  7:31 ` sashiko-bot
2026-05-22  8:46 ` Benjamin Tissoires

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