linux-next: build failure after merge of the hid tree

Stephen Rothwell posted 1 patch 1 year, 5 months ago
drivers/hid/hidraw.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
linux-next: build failure after merge of the hid tree
Posted by Stephen Rothwell 1 year, 5 months ago
Hi all,

After merging the hid tree, today's linux-next build (i386 defconfig)
failed like this:

drivers/hid/hidraw.c: In function 'hidraw_send_report':
drivers/hid/hidraw.c:143:63: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  143 |                 ret = __hid_hw_output_report(dev, buf, count, (__u64)file, false);
      |                                                               ^
drivers/hid/hidraw.c:154:56: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  154 |                                    HID_REQ_SET_REPORT, (__u64)file, false);
      |                                                        ^
drivers/hid/hidraw.c: In function 'hidraw_get_report':
drivers/hid/hidraw.c:231:56: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  231 |                                    HID_REQ_GET_REPORT, (__u64)file, false);
      |                                                        ^
cc1: all warnings being treated as errors

Caused by commit

  67eccf151d76 ("HID: add source argument to HID low level functions")

I applied the following patch.

From: Stephen Rothwell <sfr@canb.auug.org.au>
Date: Mon, 1 Jul 2024 18:36:36 +1000
Subject: [PATCH] fix up for "HID: add source argument to HID low level
 functions"

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
---
 drivers/hid/hidraw.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index c2396916cdaa..34633f99f3e4 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -140,7 +140,7 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer,
 
 	if ((report_type == HID_OUTPUT_REPORT) &&
 	    !(dev->quirks & HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP)) {
-		ret = __hid_hw_output_report(dev, buf, count, (__u64)file, false);
+		ret = __hid_hw_output_report(dev, buf, count, (unsigned long)file, false);
 		/*
 		 * compatibility with old implementation of USB-HID and I2C-HID:
 		 * if the device does not support receiving output reports,
@@ -151,7 +151,7 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer,
 	}
 
 	ret = __hid_hw_raw_request(dev, buf[0], buf, count, report_type,
-				   HID_REQ_SET_REPORT, (__u64)file, false);
+				   HID_REQ_SET_REPORT, (unsigned long)file, false);
 
 out_free:
 	kfree(buf);
@@ -228,7 +228,7 @@ static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t
 	}
 
 	ret = __hid_hw_raw_request(dev, report_number, buf, count, report_type,
-				   HID_REQ_GET_REPORT, (__u64)file, false);
+				   HID_REQ_GET_REPORT, (unsigned long)file, false);
 
 	if (ret < 0)
 		goto out_free;
-- 
2.43.0

-- 
Cheers,
Stephen Rothwell
Re: linux-next: build failure after merge of the hid tree
Posted by Benjamin Tissoires 1 year, 5 months ago
Hi Stephen,

On Jul 01 2024, Stephen Rothwell wrote:
> Hi all,
> 
> After merging the hid tree, today's linux-next build (i386 defconfig)
> failed like this:
> 
> drivers/hid/hidraw.c: In function 'hidraw_send_report':
> drivers/hid/hidraw.c:143:63: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
>   143 |                 ret = __hid_hw_output_report(dev, buf, count, (__u64)file, false);
>       |                                                               ^
> drivers/hid/hidraw.c:154:56: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
>   154 |                                    HID_REQ_SET_REPORT, (__u64)file, false);
>       |                                                        ^
> drivers/hid/hidraw.c: In function 'hidraw_get_report':
> drivers/hid/hidraw.c:231:56: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
>   231 |                                    HID_REQ_GET_REPORT, (__u64)file, false);
>       |                                                        ^
> cc1: all warnings being treated as errors
> 
> Caused by commit
> 
>   67eccf151d76 ("HID: add source argument to HID low level functions")
> 
> I applied the following patch.

Thanks a lot for the report and the proposed patch. I've just finished
and published[0] my own version which enforces a u64 in the end. It's the
same approach that can be found in the kernel/bpf/helper.c file, which
is IMO slightly better than yours.

I think I'll apply all of the series[0] right now so you can drop this
patch below from your tree.

Cheers,
Benjamin

[0] https://lore.kernel.org/all/20240701-fix-cki-v2-2-20564e2e1393@kernel.org/

> 
> From: Stephen Rothwell <sfr@canb.auug.org.au>
> Date: Mon, 1 Jul 2024 18:36:36 +1000
> Subject: [PATCH] fix up for "HID: add source argument to HID low level
>  functions"
> 
> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
> ---
>  drivers/hid/hidraw.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
> index c2396916cdaa..34633f99f3e4 100644
> --- a/drivers/hid/hidraw.c
> +++ b/drivers/hid/hidraw.c
> @@ -140,7 +140,7 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer,
>  
>  	if ((report_type == HID_OUTPUT_REPORT) &&
>  	    !(dev->quirks & HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP)) {
> -		ret = __hid_hw_output_report(dev, buf, count, (__u64)file, false);
> +		ret = __hid_hw_output_report(dev, buf, count, (unsigned long)file, false);
>  		/*
>  		 * compatibility with old implementation of USB-HID and I2C-HID:
>  		 * if the device does not support receiving output reports,
> @@ -151,7 +151,7 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer,
>  	}
>  
>  	ret = __hid_hw_raw_request(dev, buf[0], buf, count, report_type,
> -				   HID_REQ_SET_REPORT, (__u64)file, false);
> +				   HID_REQ_SET_REPORT, (unsigned long)file, false);
>  
>  out_free:
>  	kfree(buf);
> @@ -228,7 +228,7 @@ static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t
>  	}
>  
>  	ret = __hid_hw_raw_request(dev, report_number, buf, count, report_type,
> -				   HID_REQ_GET_REPORT, (__u64)file, false);
> +				   HID_REQ_GET_REPORT, (unsigned long)file, false);
>  
>  	if (ret < 0)
>  		goto out_free;
> -- 
> 2.43.0
> 
> -- 
> Cheers,
> Stephen Rothwell