From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcAte-0000Cy-GT for qemu-devel@nongnu.org; Thu, 09 Oct 2014 06:24:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XcAtU-0002K3-W5 for qemu-devel@nongnu.org; Thu, 09 Oct 2014 06:24:34 -0400 Received: from mail-wi0-x234.google.com ([2a00:1450:400c:c05::234]:64450) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcAtU-0002Jh-Pl for qemu-devel@nongnu.org; Thu, 09 Oct 2014 06:24:24 -0400 Received: by mail-wi0-f180.google.com with SMTP id em10so1313738wid.1 for ; Thu, 09 Oct 2014 03:24:24 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 9 Oct 2014 12:17:17 +0200 Message-Id: <1412849855-12661-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1412849438-12274-1-git-send-email-pbonzini@redhat.com> References: <1412849438-12274-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 10/28] 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 Cc: Eduardo Habkost From: Eduardo Habkost Reviewed-by: Paolo Bonzini Signed-off-by: Eduardo Habkost Signed-off-by: Paolo Bonzini --- accel.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/accel.c b/accel.c index 3cefd74..fc8c551 100644 --- a/accel.c +++ b/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.8.3.1