Gerd Hoffmann <kra...@redhat.com> wrote: > Adds infrastructure for keyboard led status tracking to qemu. > } QEMUPutMouseEntry; > > +typedef struct QEMUPutLEDEntry { > + QEMUPutLEDEvent *put_led; > + void *opaque; > + struct QEMUPutLEDEntry *next; > +} QEMUPutLEDEntry;
Please, change this to a QLIST(), code becomes way simpler. > +void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry) > +{ > + QEMUPutLEDEntry *prev = NULL, *cursor; > + > + if (!qemu_put_led_event_head || entry == NULL) > + return; > + > + cursor = qemu_put_led_event_head; > + while (cursor != NULL && cursor != entry) { > + prev = cursor; > + cursor = cursor->next; > + } > + > + if (cursor == NULL) // does not exist or list empty > + return; > + > + if (prev == NULL) { // entry is head > + qemu_put_led_event_head = cursor->next; > + } else { > + prev->next = entry->next; > + } > + qemu_free(entry); > +} This functions simplifies to: void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry) { QLIST_REMOVE(entry, leds); qemu_free(entry); } Rest of gains are smaller, but easier to read. Concept of the patch is ok with me. Later, Juan.