openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libevdev/1.7.0-r0/libevdev-1.7.0/libevdev/libevdev.c
static inline enum event_filter_status
    sanitize_event(const struct libevdev* dev, struct input_event* ev,
                   enum SyncState sync_state)
{
    if (!libevdev_has_event_code(dev, ev->type, ev->code))
        return EVENT_FILTER_DISCARD;

    if (unlikely(dev->num_slots > -1 &&
                 libevdev_event_is_code(ev, EV_ABS, ABS_MT_SLOT) &&
                 (ev->value < 0 || ev->value >= dev->num_slots)))
    {
        log_bug(dev,
                "Device \"%s\" received an invalid slot index %d."
                "Capping to announced max slot number %d.\n",
                dev->name, ev->value, dev->num_slots - 1);
        ev->value = dev->num_slots - 1;
        return EVENT_FILTER_MODIFIED;

        /* Drop any invalid tracking IDs, they are only supposed to go from
           N to -1 or from -1 to N. Never from -1 to -1, or N to M. Very
           unlikely to ever happen from a real device.
           */
    }
    else if (unlikely(
                 sync_state == SYNC_NONE && dev->num_slots > -1 &&
                 libevdev_event_is_code(ev, EV_ABS, ABS_MT_TRACKING_ID) &&
                 ((ev->value == -1 && *slot_value(dev, dev->current_slot,
                                                  ABS_MT_TRACKING_ID) == -1) ||
                  (ev->value != -1 && *slot_value(dev, dev->current_slot,
                                                  ABS_MT_TRACKING_ID) != -1))))
    {
        log_bug(dev,
                "Device \"%s\" received a double tracking ID %d in slot %d.\n",
                dev->name, ev->value, dev->current_slot);
        return EVENT_FILTER_DISCARD;
    }

    return EVENT_FILTER_NONE;
}
/**
 * Sanitize/modify events where needed.
 */
Sanitize/modify events where needed.
Sanitize / modify events where needed .
static inline enum event_filter_status
    sanitize_event(const struct libevdev* dev, struct input_event* ev,
                   enum SyncState sync_state)
{
    if (!libevdev_has_event_code(dev, ev->type, ev->code))
        return EVENT_FILTER_DISCARD;
    if (unlikely(dev->num_slots > -1 &&
                 libevdev_event_is_code(ev, EV_ABS, ABS_MT_SLOT) &&
                 (ev->value < 0 || ev->value >= dev->num_slots)))
    {
        log_bug(dev,
                "Device \"%s\" received an invalid slot index %d."
                "Capping to announced max slot number %d.\n",
                dev->name, ev->value, dev->num_slots - 1);
        ev->value = dev->num_slots - 1;
        return EVENT_FILTER_MODIFIED;
    }
    else if (unlikely(
                 sync_state == SYNC_NONE && dev->num_slots > -1 &&
                 libevdev_event_is_code(ev, EV_ABS, ABS_MT_TRACKING_ID) &&
                 ((ev->value == -1 && *slot_value(dev, dev->current_slot,
                                                  ABS_MT_TRACKING_ID) == -1) ||
                  (ev->value != -1 && *slot_value(dev, dev->current_slot,
                                                  ABS_MT_TRACKING_ID) != -1))))
    {
        log_bug(dev,
                "Device \"%s\" received a double tracking ID %d in slot %d.\n",
                dev->name, ev->value, dev->current_slot);
        return EVENT_FILTER_DISCARD;
    }
    return EVENT_FILTER_NONE;
}
static inline enum event_filter_status sanitize_event ( const struct libevdev * dev , struct input_event * ev , enum SyncState sync_state ) { if ( ! libevdev_has_event_code ( dev , ev -> type , ev -> code ) ) return EVENT_FILTER_DISCARD ; if ( unlikely ( dev -> num_slots > -1 && libevdev_event_is_code ( ev , EV_ABS , ABS_MT_SLOT ) && ( ev -> value < 0 || ev -> value >= dev -> num_slots ) ) ) { log_bug ( dev , " \" \" " " \n " , dev -> name , ev -> value , dev -> num_slots - 1 ) ; ev -> value = dev -> num_slots - 1 ; return EVENT_FILTER_MODIFIED ; } else if ( unlikely ( sync_state == SYNC_NONE && dev -> num_slots > -1 && libevdev_event_is_code ( ev , EV_ABS , ABS_MT_TRACKING_ID ) && ( ( ev -> value == -1 && * slot_value ( dev , dev -> current_slot , ABS_MT_TRACKING_ID ) == -1 ) || ( ev -> value != -1 && * slot_value ( dev , dev -> current_slot , ABS_MT_TRACKING_ID ) != -1 ) ) ) ) { log_bug ( dev , " \" \" \n " , dev -> name , ev -> value , dev -> current_slot ) ; return EVENT_FILTER_DISCARD ; } return EVENT_FILTER_NONE ; }
Sanitize/modify events where needed.
Sanitize / modify events where needed .
/* Drop any invalid tracking IDs, they are only supposed to go from
           N to -1 or from -1 to N. Never from -1 to -1, or N to M. Very
           unlikely to ever happen from a real device.
           */