Skip to content

Commit

Permalink
Input: touchscreen - use sizeof(*pointer) instead of sizeof(type)
Browse files Browse the repository at this point in the history
It is preferred to use sizeof(*pointer) instead of sizeof(type)
due to the type of the variable can change and one needs not
change the former (unlike the latter).

The refactoring is mostly trivial except for "usbtouchscreen.c"
file. Here, in the "mtouch_alloc" and "nexio_alloc" functions,
it is necessary to use a variable with a predefined type instead
of the "usbtouch->priv" variable (void * type). This way, the
"sizeof" operator can now know the correct size. Moreover, we
need to set the "usbtouch->priv" pointer after the memory
allocation since now the "kmalloc" return value is not assigned
directly.

This patch has no effect on runtime behavior.

Signed-off-by: Erick Archer <[email protected]>
Link: https://lore.kernel.org/r/AS8PR02MB723708364CC0DF2EAAFEE5968BC42@AS8PR02MB7237.eurprd02.prod.outlook.com
Signed-off-by: Dmitry Torokhov <[email protected]>
[[email protected]: Imported into input-wacom (f81d03d43965)]
Signed-off-by: Jason Gerecke <[email protected]>
  • Loading branch information
Erick Archer authored and jigpu committed Jun 10, 2024
1 parent f22b0b9 commit 48e3b45
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion 4.5/wacom_w8001.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ static int w8001_connect(struct serio *serio, struct serio_driver *drv)
char basename[64] = "Wacom Serial";
int err, err_pen, err_touch;

w8001 = kzalloc(sizeof(struct w8001), GFP_KERNEL);
w8001 = kzalloc(sizeof(*w8001), GFP_KERNEL);
input_dev_pen = input_allocate_device();
input_dev_touch = input_allocate_device();
if (!w8001 || !input_dev_pen || !input_dev_touch) {
Expand Down

0 comments on commit 48e3b45

Please sign in to comment.