mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2026-05-01 00:58:01 +02: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,
|
sync_mt_state(struct libevdev *dev,
|
||||||
struct slot_change_state changes_out[dev->num_slots])
|
struct slot_change_state changes_out[dev->num_slots])
|
||||||
{
|
{
|
||||||
|
#define MAX_SLOTS 256
|
||||||
int rc;
|
int rc;
|
||||||
struct slot_change_state changes[dev->num_slots];
|
struct slot_change_state changes[MAX_SLOTS] = {0};
|
||||||
|
|
||||||
memset(changes, 0, sizeof(changes));
|
|
||||||
|
|
||||||
for (int axis = ABS_MT_MIN; axis <= ABS_MT_MAX; axis++) {
|
for (int axis = ABS_MT_MIN; axis <= ABS_MT_MAX; axis++) {
|
||||||
/* EVIOCGMTSLOTS required format */
|
/* EVIOCGMTSLOTS required format */
|
||||||
struct mt_sync_state {
|
struct mt_sync_state {
|
||||||
uint32_t code;
|
uint32_t code;
|
||||||
int32_t val[dev->num_slots];
|
int32_t val[MAX_SLOTS];
|
||||||
} mt_state;
|
} mt_state;
|
||||||
|
|
||||||
if (axis == ABS_MT_SLOT ||
|
if (axis == ABS_MT_SLOT ||
|
||||||
|
|
@ -698,7 +697,7 @@ sync_mt_state(struct libevdev *dev,
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto out;
|
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),
|
int val_before = *slot_value(dev, slot, axis),
|
||||||
val_after = mt_state.val[slot];
|
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:
|
out:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue