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>
#endif
struct bh_priv {
- unsigned long *seen;
struct input_handle handle;
+ unsigned long seen[];
};
struct bh_event {
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;