Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

HID: constify params and return value of fetch_item()

fetch_item() does not modify the descriptor it operates on.
As a prerequisite for the constification of hid_driver::dev_rdesc,
mark the parameters and return value of fetch_item() as const.

Also adapt the variable types in the callers to match this
constification.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://patch.msgid.link/20240803-hid-const-fixup-v2-4-f53d7a7b29d8@weissschuh.net
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>

authored by

Thomas Weißschuh and committed by
Benjamin Tissoires
80cfb508 24ddd0d7

+7 -7
+6 -6
drivers/hid/hid-core.c
··· 723 723 * items, though they are not used yet. 724 724 */ 725 725 726 - static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item) 726 + static const u8 *fetch_item(const __u8 *start, const __u8 *end, struct hid_item *item) 727 727 { 728 728 u8 b; 729 729 ··· 880 880 { 881 881 struct hid_parser *parser; 882 882 struct hid_item item; 883 - __u8 *start = hid->dev_rdesc; 884 - __u8 *end = start + hid->dev_rsize; 883 + const __u8 *start = hid->dev_rdesc; 884 + const __u8 *end = start + hid->dev_rsize; 885 885 static int (*dispatch_type[])(struct hid_parser *parser, 886 886 struct hid_item *item) = { 887 887 hid_scan_main, ··· 1204 1204 struct hid_parser *parser; 1205 1205 struct hid_item item; 1206 1206 unsigned int size; 1207 - __u8 *start; 1207 + const __u8 *start; 1208 1208 __u8 *buf; 1209 - __u8 *end; 1210 - __u8 *next; 1209 + const __u8 *end; 1210 + const __u8 *next; 1211 1211 int ret; 1212 1212 int i; 1213 1213 static int (*dispatch_type[])(struct hid_parser *parser,
+1 -1
include/linux/hid.h
··· 46 46 __s16 s16; 47 47 __u32 u32; 48 48 __s32 s32; 49 - __u8 *longdata; 49 + const __u8 *longdata; 50 50 } data; 51 51 }; 52 52