From nobody Thu Oct 30 15:33:06 2025 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; dkim=fail; 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 1525819035231634.144086017401; Tue, 8 May 2018 15:37:15 -0700 (PDT) Received: from localhost ([::1]:53632 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGBEL-00065r-Ha for importer@patchew.org; Tue, 08 May 2018 18:37:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGAt2-00030i-73 for qemu-devel@nongnu.org; Tue, 08 May 2018 18:15:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGAt1-0001Ok-8T for qemu-devel@nongnu.org; Tue, 08 May 2018 18:15:08 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:33423) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fGAt1-0001O5-1W for qemu-devel@nongnu.org; Tue, 08 May 2018 18:15:07 -0400 Received: by mail-wm0-x241.google.com with SMTP id x12-v6so20840485wmc.0 for ; Tue, 08 May 2018 15:15:06 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-189-60.clienti.tiscali.it. [78.12.189.60]) by smtp.gmail.com with ESMTPSA id c15-v6sm14020129edr.78.2018.05.08.15.15.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 May 2018 15:15:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EejOk23zrkp7/lgJjltwByXxyXFDx0ATFvJU3WycGls=; b=ki9S3TwOkTsrGOveEeUPbxkqXno4kZ1PLKDB7RHa3SWSOJTnuWseKX9CoUU0Tk7mmb Wlo/Ootv/onFydh/LoAiOodNsnzwu68AhG11mXN1wnyHMop9Vp8KDStBZaQkppvza+lE lvrj2bBi/3CgPa+VJSx9O3IK6YfYwsOlg1Jw3eFrvvuRE3fQLPhMSiVctApHZJWdCedK LWBNEwVCOuEw+uJPD/bstdJrkMae08L9WIUhuywLp7Jrt02VNGgO7fNV98/ak4JKs6sW GelH/p5P6BZ5vla+jtuYIvvmmTVMvTj13TM0SGIC0FQpz49kpmg1e8kVmBgYlGM5TlLd Uf5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=EejOk23zrkp7/lgJjltwByXxyXFDx0ATFvJU3WycGls=; b=q+k86thMbaTq7Qh4GkFnC3d2XzZNVA4D+xewKhuipO77hEE8ODz/9EPOQC4LOh7ONo 5VYND4D5kH5UVjNLhm7FAjdUB4MNNHtewv/k+tVKXbLHB8dBmPfO4qdxxQ0NGdE2mTzH 00sFsU8L52kV2c1Cm03u5hKfXLZwgPZ3FB+0O047GtK6htJMUb3kuCSnplgDwPX3XgQp r0hGq1wszXbrIudJA23AaQMVRa7I/tNjkzXUuDLNg0gqU/n01HbraxRPKUtJTxPoboHM 8//kysUkpiVWAvGN73mrQtQomZIDAxRLWqvAdfTnMNNGvEZmSsZy1xazOGp4pexgOLgi xvJQ== X-Gm-Message-State: ALQs6tDegiEX3RKhiQp5AY3uXnKF80CYZkYY6ZID8JCjUqThqpatEdpI dNK34DIcqGPQxLCR/Q4eBZBIQsVx X-Google-Smtp-Source: AB8JxZpQKCPo+6+jbL06NUB7oFKC033x9xtM6udilsCi8CB4oW5BNk4Vo2oEQ30p+698Paq6KvCxqw== X-Received: by 2002:a50:b62c:: with SMTP id b41-v6mr57345806ede.255.1525817705769; Tue, 08 May 2018 15:15:05 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 9 May 2018 00:14:30 +0200 Message-Id: <1525817687-34620-14-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1525817687-34620-1-git-send-email-pbonzini@redhat.com> References: <1525817687-34620-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PULL 13/30] 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Daniel P. Berrang=C3=A9 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=83=C2=A9 Message-Id: <20180416111743.8473-2-berrange@redhat.com> Signed-off-by: Paolo Bonzini Signed-off-by: Daniel P. Berrang=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 9cfab11..966b2d8 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 306fdb5..1cfe5cb 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 d0756fd..baca40f 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 1.8.3.1