From nobody Thu May 15 21:27:41 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1506943517690540.788113077092; Mon, 2 Oct 2017 04:25:17 -0700 (PDT) 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 51E7C806A7; Mon, 2 Oct 2017 11:25:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1C0568E7B5; Mon, 2 Oct 2017 11:25:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A4A3E4EE4F; Mon, 2 Oct 2017 11:25:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v92B1UFc012879 for ; Mon, 2 Oct 2017 07:01:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6A92F503B0; Mon, 2 Oct 2017 11:01:30 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id E51108E7A2 for ; Mon, 2 Oct 2017 11:01:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 51E7C806A7 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 2 Oct 2017 13:01:18 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/3] qemuParseCommandLineNet: Make more readable X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@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.26]); Mon, 02 Oct 2017 11:25:16 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/qemu/qemu_parse_command.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c index c9112dd90..37e1149c0 100644 --- a/src/qemu/qemu_parse_command.c +++ b/src/qemu/qemu_parse_command.c @@ -1055,9 +1055,7 @@ qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt, if (virStrToLong_i(values[i], NULL, 10, &wantvlan) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse vlan in '%s'"), val); - virDomainNetDefFree(def); - def =3D NULL; - goto cleanup; + goto error; } } else if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_ETHERNET && STREQ(keywords[i], "script") && STRNEQ(values[i], "")) { @@ -1076,18 +1074,13 @@ qemuParseCommandLineNet(virDomainXMLOptionPtr xmlop= t, */ =20 nic =3D qemuFindNICForVLAN(nnics, nics, wantvlan); - if (!nic) { - virDomainNetDefFree(def); - def =3D NULL; - goto cleanup; - } + if (!nic) + goto error; =20 if (!STRPREFIX(nic, "nic")) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse NIC definition '%s'"), nic); - virDomainNetDefFree(def); - def =3D NULL; - goto cleanup; + goto error; } =20 for (i =3D 0; i < nkeywords; i++) { @@ -1103,9 +1096,7 @@ qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt, &values, &nkeywords, 0) < 0) { - virDomainNetDefFree(def); - def =3D NULL; - goto cleanup; + goto error; } } else { nkeywords =3D 0; @@ -1118,9 +1109,7 @@ qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt, virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to parse mac address '%s'"), values[i]); - virDomainNetDefFree(def); - def =3D NULL; - goto cleanup; + goto error; } } else if (STREQ(keywords[i], "model")) { def->model =3D values[i]; @@ -1135,9 +1124,7 @@ qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt, if (virStrToLong_ul(values[i], NULL, 10, &def->tune.sndbuf) < = 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse sndbuf size in '%s'"), val); - virDomainNetDefFree(def); - def =3D NULL; - goto cleanup; + goto error; } def->tune.sndbuf_specified =3D true; } @@ -1154,6 +1141,11 @@ qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt, VIR_FREE(keywords); VIR_FREE(values); return def; + + error: + virDomainNetDefFree(def); + def =3D NULL; + goto cleanup; } =20 =20 --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list