[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: [PATCH 1/4] kbd leds: infrastructure
From: |
Juan Quintela |
Subject: |
[Qemu-devel] Re: [PATCH 1/4] kbd leds: infrastructure |
Date: |
Thu, 25 Feb 2010 11:57:28 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
Gerd Hoffmann <address@hidden> 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.