From nobody Mon Feb 9 02:12:17 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15238775889981017.944487802132; Mon, 16 Apr 2018 04:19:48 -0700 (PDT) Received: from localhost ([::1]:37880 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f82Al-0003E6-MK for importer@patchew.org; Mon, 16 Apr 2018 07:19:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f828y-0002Gg-Cq for qemu-devel@nongnu.org; Mon, 16 Apr 2018 07:17:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f828v-00042F-G0 for qemu-devel@nongnu.org; Mon, 16 Apr 2018 07:17:56 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34858 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f828v-00041F-BJ for qemu-devel@nongnu.org; Mon, 16 Apr 2018 07:17:53 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F157DE44B5; Mon, 16 Apr 2018 11:17:52 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF91F2023227; Mon, 16 Apr 2018 11:17:51 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Date: Mon, 16 Apr 2018 12:17:41 +0100 Message-Id: <20180416111743.8473-2-berrange@redhat.com> In-Reply-To: <20180416111743.8473-1-berrange@redhat.com> References: <20180416111743.8473-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 16 Apr 2018 11:17:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 16 Apr 2018 11:17:53 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'berrange@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 1/3] accel: use g_strsplit for parsing accelerator names X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , Markus Armbruster , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Instead of re-using the get_opt_name() method from QemuOpts to split a string on ':', just use g_strsplit(). Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- accel/accel.c | 16 +++++++--------- include/qemu/option.h | 1 - util/qemu-option.c | 3 ++- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/accel/accel.c b/accel/accel.c index 93e2434c87..4981e7fff3 100644 --- a/accel/accel.c +++ b/accel/accel.c @@ -70,8 +70,8 @@ static int accel_init_machine(AccelClass *acc, MachineSta= te *ms) =20 void configure_accelerator(MachineState *ms) { - const char *accel, *p; - char buf[10]; + const char *accel; + char **accel_list, **tmp; int ret; bool accel_initialised =3D false; bool init_failed =3D false; @@ -83,13 +83,10 @@ void configure_accelerator(MachineState *ms) accel =3D "tcg"; } =20 - p =3D accel; - while (!accel_initialised && *p !=3D '\0') { - if (*p =3D=3D ':') { - p++; - } - p =3D get_opt_name(buf, sizeof(buf), p, ':'); - acc =3D accel_find(buf); + accel_list =3D g_strsplit(accel, ":", 0); + + for (tmp =3D accel_list; !accel_initialised && tmp && *tmp; tmp++) { + acc =3D accel_find(*tmp); if (!acc) { continue; } @@ -107,6 +104,7 @@ void configure_accelerator(MachineState *ms) accel_initialised =3D true; } } + g_strfreev(accel_list); =20 if (!accel_initialised) { if (!init_failed) { diff --git a/include/qemu/option.h b/include/qemu/option.h index 306fdb5f7a..1cfe5cbc2d 100644 --- a/include/qemu/option.h +++ b/include/qemu/option.h @@ -28,7 +28,6 @@ =20 #include "qemu/queue.h" =20 -const char *get_opt_name(char *buf, int buf_size, const char *p, char deli= m); const char *get_opt_value(char *buf, int buf_size, const char *p); =20 void parse_option_size(const char *name, const char *value, diff --git a/util/qemu-option.c b/util/qemu-option.c index d0756fda58..baca40fb94 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -49,7 +49,8 @@ * The return value is the position of the delimiter/zero byte after the o= ption * name in p. */ -const char *get_opt_name(char *buf, int buf_size, const char *p, char deli= m) +static const char *get_opt_name(char *buf, int buf_size, const char *p, + char delim) { char *q; =20 --=20 2.14.3