From patchwork Fri Dec 18 15:35:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 558954 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 36D871400A0 for ; Sat, 19 Dec 2015 03:36:27 +1100 (AEDT) Received: from localhost ([::1]:33509 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9y13-0007ZM-61 for incoming@patchwork.ozlabs.org; Fri, 18 Dec 2015 11:36:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9x4B-0005J5-Gp for qemu-devel@nongnu.org; Fri, 18 Dec 2015 10:35:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9x49-00032F-Nv for qemu-devel@nongnu.org; Fri, 18 Dec 2015 10:35:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57482) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9x49-00031c-BB for qemu-devel@nongnu.org; Fri, 18 Dec 2015 10:35:33 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 0728EAACC4 for ; Fri, 18 Dec 2015 15:35:33 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-44.phx2.redhat.com [10.3.113.44]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBIFZUe5022571 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Dec 2015 10:35:32 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id DAB823011FAB; Fri, 18 Dec 2015 16:35:27 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 18 Dec 2015 16:35:11 +0100 Message-Id: <1450452927-8346-9-git-send-email-armbru@redhat.com> In-Reply-To: <1450452927-8346-1-git-send-email-armbru@redhat.com> References: <1450452927-8346-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 08/24] test-throttle: Simplify qemu_init_main_loop() error handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The code looks like it tries to check for both qemu_init_main_loop() and qemu_get_aio_context() failure in one conditional. In fact, qemu_get_aio_context() can fail only after qemu_init_main_loop() failed. Simplify accordingly: check for qemu_init_main_loop() error directly, without bothering to improve its error message. Call qemu_get_aio_context() only when qemu_get_aio_context() succeeded. It can't fail then, so no need to check. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/test-throttle.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/tests/test-throttle.c b/tests/test-throttle.c index 85c9b6c..a95039f 100644 --- a/tests/test-throttle.c +++ b/tests/test-throttle.c @@ -581,21 +581,8 @@ static void test_groups(void) int main(int argc, char **argv) { - Error *local_error = NULL; - - qemu_init_main_loop(&local_error); + qemu_init_main_loop(&error_fatal); ctx = qemu_get_aio_context(); - - if (!ctx) { - error_report("Failed to create AIO Context: '%s'", - local_error ? error_get_pretty(local_error) : - "Failed to initialize the QEMU main loop"); - if (local_error) { - error_free(local_error); - } - exit(1); - } - bdrv_init(); do {} while (g_main_context_iteration(NULL, false));