Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NkbPR-000299-IT for qemu-devel@nongnu.org; Thu, 25 Feb 2010 05:57:33 -0500 Received: from [199.232.76.173] (port=35837 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NkbPR-00028x-3e for qemu-devel@nongnu.org; Thu, 25 Feb 2010 05:57:33 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NkbPP-0006aE-Rj for qemu-devel@nongnu.org; Thu, 25 Feb 2010 05:57:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34542) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NkbPP-0006a8-Fw for qemu-devel@nongnu.org; Thu, 25 Feb 2010 05:57:31 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1PAvUip023787 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 25 Feb 2010 05:57:30 -0500 From: Juan Quintela In-Reply-To: <1267087161-15204-2-git-send-email-kraxel@redhat.com> (Gerd Hoffmann's message of "Thu, 25 Feb 2010 09:39:18 +0100") References: <1267087161-15204-1-git-send-email-kraxel@redhat.com> <1267087161-15204-2-git-send-email-kraxel@redhat.com> Date: Thu, 25 Feb 2010 11:57:28 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Qemu-devel] Re: [PATCH 1/4] kbd leds: infrastructure List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org Gerd Hoffmann 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.