mirror of
https://git.openwrt.org/openwrt/openwrt.git
synced 2026-03-14 17:19:43 +01:00
button-hotplug: use flex array and not pointer hack
The &pointer + 1 trick is a C89 trick to point to area allocated after the size of the struct. We have struct_size and flex arrays now. Signed-off-by: Rosen Penev <rosenp@gmail.com> Link: https://github.com/openwrt/openwrt/pull/22170 Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
parent
7a76074574
commit
c4e285049e
1 changed files with 2 additions and 5 deletions
|
|
@ -46,8 +46,8 @@
|
|||
#endif
|
||||
|
||||
struct bh_priv {
|
||||
unsigned long *seen;
|
||||
struct input_handle handle;
|
||||
unsigned long seen[];
|
||||
};
|
||||
|
||||
struct bh_event {
|
||||
|
|
@ -254,13 +254,10 @@ static int button_hotplug_connect(struct input_handler *handler,
|
|||
if (i == ARRAY_SIZE(button_map))
|
||||
return -ENODEV;
|
||||
|
||||
priv = kzalloc(sizeof(*priv) +
|
||||
(sizeof(unsigned long) * ARRAY_SIZE(button_map)),
|
||||
GFP_KERNEL);
|
||||
priv = kzalloc(struct_size(priv, seen, ARRAY_SIZE(button_map)), GFP_KERNEL);
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
priv->seen = (unsigned long *) &priv[1];
|
||||
priv->handle.private = priv;
|
||||
priv->handle.dev = dev;
|
||||
priv->handle.handler = handler;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue