From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54188) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXX1M-0006W5-NQ for qemu-devel@nongnu.org; Fri, 26 Sep 2014 11:01:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XXX1B-0000oW-P9 for qemu-devel@nongnu.org; Fri, 26 Sep 2014 11:01:20 -0400 Received: from mail-wg0-x233.google.com ([2a00:1450:400c:c00::233]:48293) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXX1B-0000mX-J6 for qemu-devel@nongnu.org; Fri, 26 Sep 2014 11:01:09 -0400 Received: by mail-wg0-f51.google.com with SMTP id b13so1326532wgh.10 for ; Fri, 26 Sep 2014 08:01:03 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <54257F9E.9060401@redhat.com> Date: Fri, 26 Sep 2014 17:00:46 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1409344310-5441-1-git-send-email-ehabkost@redhat.com> <1409344310-5441-5-git-send-email-ehabkost@redhat.com> In-Reply-To: <1409344310-5441-5-git-send-email-ehabkost@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 04/17] accel: Simplify configure_accelerator() using AccelType *acc variable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost , qemu-devel@nongnu.org Cc: Michael Mueller , "Michael S. Tsirkin" , Marcel Apfelbaum , Alexander Graf , Christian Borntraeger , "Jason J. Herne" , =?windows-1252?Q?Andreas_?= =?windows-1252?Q?F=E4rber?= Il 29/08/2014 22:31, Eduardo Habkost ha scritto: > 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; > Reviewed-by: Paolo Bonzini