CCID emulation needs to insert at tail. Use a QTAILQ, even though the double links are strictly not necessary.
Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> --- hw/ccid-card-emulated.c | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-) diff --git a/hw/ccid-card-emulated.c b/hw/ccid-card-emulated.c index 2d2ebce..1d0e67d 100644 --- a/hw/ccid-card-emulated.c +++ b/hw/ccid-card-emulated.c @@ -89,7 +89,7 @@ static const char *emul_event_to_string(uint32_t emul_event) } typedef struct EmulEvent { - QSIMPLEQ_ENTRY(EmulEvent) entry; + QTAILQ_ENTRY(EmulEvent) entry; union { struct { uint32_t type; @@ -118,11 +118,11 @@ struct EmulatedState { char *db; uint8_t atr[MAX_ATR_SIZE]; uint8_t atr_length; - QSIMPLEQ_HEAD(event_list, EmulEvent) event_list; + QTAILQ_HEAD(event_list, EmulEvent) event_list; QemuMutex event_list_mutex; QemuThread event_thread_id; VReader *reader; - QSIMPLEQ_HEAD(guest_apdu_list, EmulEvent) guest_apdu_list; + QTAILQ_HEAD(guest_apdu_list, EmulEvent) guest_apdu_list; QemuMutex vreader_mutex; /* and guest_apdu_list mutex */ QemuMutex handle_apdu_mutex; QemuCond handle_apdu_cond; @@ -142,7 +142,7 @@ static void emulated_apdu_from_guest(CCIDCardState *base, event->p.data.len = len; memcpy(event->p.data.data, apdu, len); qemu_mutex_lock(&card->vreader_mutex); - QSIMPLEQ_INSERT_TAIL(&card->guest_apdu_list, event, entry); + QTAILQ_INSERT_TAIL(&card->guest_apdu_list, event, entry); qemu_mutex_unlock(&card->vreader_mutex); qemu_mutex_lock(&card->handle_apdu_mutex); qemu_cond_signal(&card->handle_apdu_cond); @@ -160,7 +160,7 @@ static const uint8_t *emulated_get_atr(CCIDCardState *base, uint32_t *len) static void emulated_push_event(EmulatedState *card, EmulEvent *event) { qemu_mutex_lock(&card->event_list_mutex); - QSIMPLEQ_INSERT_TAIL(&(card->event_list), event, entry); + QTAILQ_INSERT_TAIL(&(card->event_list), event, entry); qemu_mutex_unlock(&card->event_list_mutex); if (write(card->pipe[1], card, 1) != 1) { DPRINTF(card, 1, "write to pipe failed\n"); @@ -243,10 +243,10 @@ static void *handle_apdu_thread(void* arg) break; } qemu_mutex_lock(&card->vreader_mutex); - while (!QSIMPLEQ_EMPTY(&card->guest_apdu_list)) { - event = QSIMPLEQ_FIRST(&card->guest_apdu_list); + while (!QTAILQ_EMPTY(&card->guest_apdu_list)) { + event = QTAILQ_FIRST(&card->guest_apdu_list); assert((unsigned long)event > 1000); - QSIMPLEQ_REMOVE_HEAD(&card->guest_apdu_list, entry); + QTAILQ_REMOVE(&card->guest_apdu_list, event, entry); if (event->p.data.type != EMUL_GUEST_APDU) { DPRINTF(card, 1, "unexpected message in handle_apdu_thread\n"); g_free(event); @@ -369,7 +369,7 @@ static void pipe_read(void *opaque) len = read(card->pipe[0], &dummy, sizeof(dummy)); } while (len == sizeof(dummy)); qemu_mutex_lock(&card->event_list_mutex); - QSIMPLEQ_FOREACH_SAFE(event, &card->event_list, entry, next) { + QTAILQ_FOREACH_SAFE(event, &card->event_list, entry, next) { DPRINTF(card, 2, "event %s\n", emul_event_to_string(event->p.gen.type)); switch (event->p.gen.type) { case EMUL_RESPONSE_APDU: @@ -400,7 +400,7 @@ static void pipe_read(void *opaque) } g_free(event); } - QSIMPLEQ_INIT(&card->event_list); + QTAILQ_INIT(&card->event_list); qemu_mutex_unlock(&card->event_list_mutex); } @@ -489,8 +489,8 @@ static int emulated_initfn(CCIDCardState *base) VCardEmulError ret; EnumTable *ptable; - QSIMPLEQ_INIT(&card->event_list); - QSIMPLEQ_INIT(&card->guest_apdu_list); + QTAILQ_INIT(&card->event_list); + QTAILQ_INIT(&card->guest_apdu_list); qemu_mutex_init(&card->event_list_mutex); qemu_mutex_init(&card->vreader_mutex); qemu_mutex_init(&card->handle_apdu_mutex); -- 1.7.7.1