Received: from eggs.gnu.org ([2001:4830:134:3::10]:58749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4zyz-0007Sd-Qv for qemu-devel@nongnu.org; Wed, 09 Jul 2014 18:05:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4zyq-0008HN-Oj for qemu-devel@nongnu.org; Wed, 09 Jul 2014 18:04:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13076) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4zyq-0008HC-EY for qemu-devel@nongnu.org; Wed, 09 Jul 2014 18:04:48 -0400 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 (8.14.4/8.14.4) with ESMTP id s69M4l89013339 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 9 Jul 2014 18:04:48 -0400 From: Eduardo Habkost Date: Wed, 9 Jul 2014 19:04:01 -0300 Message-Id: <1404943462-711-5-git-send-email-ehabkost@redhat.com> In-Reply-To: <1404943462-711-1-git-send-email-ehabkost@redhat.com> References: <1404943462-711-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [RFC 04/25] accel: Simplify configure_accelerator() using AccelType *acc variable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Signed-off-by: Eduardo Habkost --- hw/core/accel.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/core/accel.c b/hw/core/accel.c index c23c04b..00a71c0 100644 --- a/hw/core/accel.c +++ b/hw/core/accel.c @@ -62,6 +62,7 @@ int configure_accelerator(MachineClass *mc) int i, ret; bool accel_initialised = false; bool init_failed = false; + AccelType *acc = NULL; p = qemu_opt_get(qemu_get_machine_opts(), "accel"); if (p == NULL) { @@ -75,20 +76,21 @@ int configure_accelerator(MachineClass *mc) } p = get_opt_name(buf, sizeof(buf), p, ':'); for (i = 0; i < ARRAY_SIZE(accel_list); i++) { - if (strcmp(accel_list[i].opt_name, buf) == 0) { - if (!accel_list[i].available()) { + acc = &accel_list[i]; + if (strcmp(acc->opt_name, buf) == 0) { + if (!acc->available()) { printf("%s not supported for this target\n", - accel_list[i].name); + acc->name); break; } - *(accel_list[i].allowed) = true; - ret = accel_list[i].init(mc); + *(acc->allowed) = true; + ret = acc->init(mc); if (ret < 0) { init_failed = true; fprintf(stderr, "failed to initialize %s: %s\n", - accel_list[i].name, + acc->name, strerror(-ret)); - *(accel_list[i].allowed) = false; + *(acc->allowed) = false; } else { accel_initialised = true; } @@ -108,7 +110,7 @@ int configure_accelerator(MachineClass *mc) } if (init_failed) { - fprintf(stderr, "Back to %s accelerator.\n", accel_list[i].name); + fprintf(stderr, "Back to %s accelerator.\n", acc->name); } return !accel_initialised; -- 1.9.3