Received: from eggs.gnu.org ([209.51.188.92]:40209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1go7hb-0007SD-OV for qemu-devel@nongnu.org; Mon, 28 Jan 2019 09:16:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1go7hY-0007FP-OK for qemu-devel@nongnu.org; Mon, 28 Jan 2019 09:15:55 -0500 Received: from m15-113.126.com ([220.181.15.113]:49510) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1go7hT-00075K-4v for qemu-devel@nongnu.org; Mon, 28 Jan 2019 09:15:49 -0500 From: Fei Li Date: Mon, 28 Jan 2019 22:14:49 +0800 Message-Id: <20190128141506.12731-7-lifei1214@126.com> In-Reply-To: <20190128141506.12731-1-lifei1214@126.com> References: <20190128141506.12731-1-lifei1214@126.com> Subject: [Qemu-devel] [PATCH for-4.0 06/11] qemu_thread: supplement error handling for emulated_realize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, shirley17fei@gmail.com Cc: Markus Armbruster , David Gibson , Gerd Hoffmann , Eric Blake , "Dr . David Alan Gilbert" , Peter Xu , Fei Li From: Fei Li Utilize the existed errp to propagate the error and do the corresponding cleanup to replace the temporary &error_abort. Cc: Markus Armbruster Cc: Gerd Hoffmann Signed-off-by: Fei Li --- hw/usb/ccid-card-emulated.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c index 0b170f6328..19b4b9a8fa 100644 --- a/hw/usb/ccid-card-emulated.c +++ b/hw/usb/ccid-card-emulated.c @@ -544,11 +544,16 @@ static void emulated_realize(CCIDCardState *base, Error **errp) error_setg(errp, "%s: failed to initialize vcard", TYPE_EMULATED_CCID); goto out2; } - /* TODO: let the further caller handle the error instead of abort() here */ - qemu_thread_create(&card->event_thread_id, "ccid/event", event_thread, - card, QEMU_THREAD_JOINABLE, &error_abort); - qemu_thread_create(&card->apdu_thread_id, "ccid/apdu", handle_apdu_thread, - card, QEMU_THREAD_JOINABLE, &error_abort); + if (qemu_thread_create(&card->event_thread_id, "ccid/event", event_thread, + card, QEMU_THREAD_JOINABLE, errp) < 0) { + goto out2; + } + if (qemu_thread_create(&card->apdu_thread_id, "ccid/apdu", + handle_apdu_thread, card, + QEMU_THREAD_JOINABLE, errp) < 0) { + qemu_thread_join(&card->event_thread_id); + goto out2; + } return; -- 2.17.2 (Apple Git-113)