diff mbox

hid: huion: Fix sparse warnings

Message ID 1406638206-6108-1-git-send-email-spbnick@gmail.com (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

Nikolai Kondrashov July 29, 2014, 12:50 p.m. UTC
Fix sparse warnings in hid-huion.c by using correct buffer type for
retrieved string descriptor.

The warnings in question were:

    drivers/hid/hid-huion.c:144:44: sparse: cast to restricted __le16
    drivers/hid/hid-huion.c:145:44: sparse: cast to restricted __le16
    drivers/hid/hid-huion.c:146:51: sparse: cast to restricted __le16
    drivers/hid/hid-huion.c:147:30: sparse: cast to restricted __le16

Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
---

Hi Jiri, Benjamin,

Thanks for the review. There is one minor problem, though. I didn't run a
sparse check and only just got a message with "sparse" warnings. This patch
fixes them.

If you wouldn't like adding a tiny patch like this, I can send another version
of the original patches. Otherwise, please feel free to just fixup my "Switch
to generating report descriptor" commit with this one.

I'll try to remember to run sparse next time before submitting the patches.

Thank you.

Nick

 drivers/hid/hid-huion.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jiri Kosina July 29, 2014, 1:06 p.m. UTC | #1
On Tue, 29 Jul 2014, Nikolai Kondrashov wrote:

> Fix sparse warnings in hid-huion.c by using correct buffer type for
> retrieved string descriptor.
> 
> The warnings in question were:
> 
>     drivers/hid/hid-huion.c:144:44: sparse: cast to restricted __le16
>     drivers/hid/hid-huion.c:145:44: sparse: cast to restricted __le16
>     drivers/hid/hid-huion.c:146:51: sparse: cast to restricted __le16
>     drivers/hid/hid-huion.c:147:30: sparse: cast to restricted __le16

Interestingly enough, my sparse doesn't seem to report this problem 
(running sparse is part of my machinery before pushing anything out).

> Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
> ---
> 
> Hi Jiri, Benjamin,
> 
> Thanks for the review. There is one minor problem, though. I didn't run a
> sparse check and only just got a message with "sparse" warnings. This patch
> fixes them.
> 
> If you wouldn't like adding a tiny patch like this, I can send another version
> of the original patches. Otherwise, please feel free to just fixup my "Switch
> to generating report descriptor" commit with this one.

Yup, I'll be applying this on top of your previous one.

Thanks.
Nikolai Kondrashov July 29, 2014, 1:24 p.m. UTC | #2
On 07/29/2014 04:06 PM, Jiri Kosina wrote:
> On Tue, 29 Jul 2014, Nikolai Kondrashov wrote:
>
>> Fix sparse warnings in hid-huion.c by using correct buffer type for
>> retrieved string descriptor.
>>
>> The warnings in question were:
>>
>>      drivers/hid/hid-huion.c:144:44: sparse: cast to restricted __le16
>>      drivers/hid/hid-huion.c:145:44: sparse: cast to restricted __le16
>>      drivers/hid/hid-huion.c:146:51: sparse: cast to restricted __le16
>>      drivers/hid/hid-huion.c:147:30: sparse: cast to restricted __le16
>
> Interestingly enough, my sparse doesn't seem to report this problem
> (running sparse is part of my machinery before pushing anything out).

The above only appears with CF=-D__CHECK_ENDIAN__.

>> If you wouldn't like adding a tiny patch like this, I can send another version
>> of the original patches. Otherwise, please feel free to just fixup my "Switch
>> to generating report descriptor" commit with this one.
>
> Yup, I'll be applying this on top of your previous one.

Thanks!

Nick
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/hid/hid-huion.c b/drivers/hid/hid-huion.c
index 438b54e..60f44cd 100644
--- a/drivers/hid/hid-huion.c
+++ b/drivers/hid/hid-huion.c
@@ -115,7 +115,7 @@  static int huion_tablet_enable(struct hid_device *hdev)
 	int rc;
 	struct usb_device *usb_dev = hid_to_usb_dev(hdev);
 	struct huion_drvdata *drvdata = hid_get_drvdata(hdev);
-	u16 buf[6];
+	__le16 buf[6];
 
 	/*
 	 * Read string descriptor containing tablet parameters. The specific