mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2025-12-20 08:00:09 +01:00
Ignore slot sync for slots > 256
Clang doesn't support variable length arrays inside a struct so we could either make our life complicated or just assume no-one is using more than 256 slots and hard-code that. Let's go for the easy solution until someone notices. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
e9ecb5cabc
commit
6ccee710bd
1 changed files with 5 additions and 6 deletions
|
|
@ -677,16 +677,15 @@ static int
|
|||
sync_mt_state(struct libevdev *dev,
|
||||
struct slot_change_state changes_out[dev->num_slots])
|
||||
{
|
||||
#define MAX_SLOTS 256
|
||||
int rc;
|
||||
struct slot_change_state changes[dev->num_slots];
|
||||
|
||||
memset(changes, 0, sizeof(changes));
|
||||
struct slot_change_state changes[MAX_SLOTS] = {0};
|
||||
|
||||
for (int axis = ABS_MT_MIN; axis <= ABS_MT_MAX; axis++) {
|
||||
/* EVIOCGMTSLOTS required format */
|
||||
struct mt_sync_state {
|
||||
uint32_t code;
|
||||
int32_t val[dev->num_slots];
|
||||
int32_t val[MAX_SLOTS];
|
||||
} mt_state;
|
||||
|
||||
if (axis == ABS_MT_SLOT ||
|
||||
|
|
@ -698,7 +697,7 @@ sync_mt_state(struct libevdev *dev,
|
|||
if (rc < 0)
|
||||
goto out;
|
||||
|
||||
for (int slot = 0; slot < dev->num_slots; slot++) {
|
||||
for (int slot = 0; slot < min(MAX_SLOTS, dev->num_slots); slot++) {
|
||||
int val_before = *slot_value(dev, slot, axis),
|
||||
val_after = mt_state.val[slot];
|
||||
|
||||
|
|
@ -729,7 +728,7 @@ sync_mt_state(struct libevdev *dev,
|
|||
}
|
||||
}
|
||||
|
||||
memcpy(changes_out, changes, sizeof(changes));
|
||||
memcpy(changes_out, changes, sizeof(*changes) * dev->num_slots);
|
||||
out:
|
||||
return rc;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue