From nobody Sun Nov 9 16:20:15 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.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 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551348848427119.87348185794019; Thu, 28 Feb 2019 02:14:08 -0800 (PST) Received: from localhost ([127.0.0.1]:35503 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzIhZ-0006I8-D7 for importer@patchew.org; Thu, 28 Feb 2019 05:14:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzIcq-00033A-Qg for qemu-devel@nongnu.org; Thu, 28 Feb 2019 05:09:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzIco-0000yb-UH for qemu-devel@nongnu.org; Thu, 28 Feb 2019 05:09:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48252) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gzIco-0000rP-Me for qemu-devel@nongnu.org; Thu, 28 Feb 2019 05:09:10 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3A3648E3EF for ; Thu, 28 Feb 2019 10:09:02 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-248.ams2.redhat.com [10.36.117.248]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5522B60BE0; Thu, 28 Feb 2019 10:08:59 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 8E8E31750A; Thu, 28 Feb 2019 11:08:58 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 28 Feb 2019 11:08:54 +0100 Message-Id: <20190228100858.28397-2-kraxel@redhat.com> In-Reply-To: <20190228100858.28397-1-kraxel@redhat.com> References: <20190228100858.28397-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 28 Feb 2019 10:09:02 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/5] audio: Use g_strdup_printf instead of manual building a string 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: Gerd Hoffmann , Frediano Ziglio Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Frediano Ziglio Instead of using lot of low level function and manually allocate the temporary string in audio_process_options use more high level GLib function. The function is not used in hot path but to read some initial setting. Signed-off-by: Frediano Ziglio Message-id: 20190225154335.11397-1-fziglio@redhat.com Signed-off-by: Gerd Hoffmann --- audio/audio.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index d163ffbc88f4..472721a7a9f0 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -454,9 +454,7 @@ static void audio_print_options (const char *prefix, static void audio_process_options (const char *prefix, struct audio_option *opt) { - char *optname; - const char qemu_prefix[] =3D "QEMU_"; - size_t preflen, optlen; + gchar *prefix_upper; =20 if (audio_bug(__func__, !prefix)) { dolog ("prefix =3D NULL\n"); @@ -468,10 +466,10 @@ static void audio_process_options (const char *prefix, return; } =20 - preflen =3D strlen (prefix); + prefix_upper =3D g_utf8_strup(prefix, -1); =20 for (; opt->name; opt++) { - size_t len, i; + char *optname; int def; =20 if (!opt->valp) { @@ -480,21 +478,7 @@ static void audio_process_options (const char *prefix, continue; } =20 - len =3D strlen (opt->name); - /* len of opt->name + len of prefix + size of qemu_prefix - * (includes trailing zero) + zero + underscore (on behalf of - * sizeof) */ - optlen =3D len + preflen + sizeof (qemu_prefix) + 1; - optname =3D g_malloc (optlen); - - pstrcpy (optname, optlen, qemu_prefix); - - /* copy while upper-casing, including trailing zero */ - for (i =3D 0; i <=3D preflen; ++i) { - optname[i + sizeof (qemu_prefix) - 1] =3D qemu_toupper(prefix[= i]); - } - pstrcat (optname, optlen, "_"); - pstrcat (optname, optlen, opt->name); + optname =3D g_strdup_printf("QEMU_%s_%s", prefix_upper, opt->name); =20 def =3D 1; switch (opt->tag) { @@ -532,6 +516,7 @@ static void audio_process_options (const char *prefix, *opt->overriddenp =3D !def; g_free (optname); } + g_free(prefix_upper); } =20 static void audio_print_settings (struct audsettings *as) --=20 2.9.3