From nobody Sun Feb 8 16:05:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639404092; cv=none; d=zohomail.com; s=zohoarc; b=Ws7Z0LIS0FSKz42uRL6nNsEH+WxyRSvQ+y827Ka1f4zhb6DDyXPtDV1313ePmk2bOhP5yLXjpSIlwkRditKaCOTjPdt80/jJpDe9jQJXBJDQJce7TYekeCLYF4XzsMwwmTW2kfq6oXNvAq3go/49/1T4LUFqVJcIDwt8kwfw25s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639404092; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SYnytbAX0l5Ir9/7yePrOHatzNbekdlMFiCpRV33nHA=; b=BC6idcE6AENwXdSAPpIiq1ApFPVtSj3ppMxWqcW6QRJD1MR54kzISjJWNVSQDn/G5i53lMfE8oJtrEYCOTbPUqYEaLqNelOrkapIgrOaXv/dy3Cbg8ueL8QLXdaENQDtOyKyzWSfkTyyNvXA+5bf5UdYkuUR+GSTqGBoeGHQXtE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 16394040925591012.0984026865864; Mon, 13 Dec 2021 06:01:32 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-436-qwEyC1H1ONWxKLktjkCcng-1; Mon, 13 Dec 2021 09:00:25 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB79C1DDF1; Mon, 13 Dec 2021 14:00:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF630709AA; Mon, 13 Dec 2021 14:00:00 +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 923A81802FEB; Mon, 13 Dec 2021 14:00:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BDDxnqW002525 for ; Mon, 13 Dec 2021 08:59:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2578B22E00; Mon, 13 Dec 2021 13:59:49 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E07622DFC for ; Mon, 13 Dec 2021 13:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639404091; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=SYnytbAX0l5Ir9/7yePrOHatzNbekdlMFiCpRV33nHA=; b=VQsKsV/1lkaQN51V8XcQx9Roz80UWoBQTzyWtZZkgErEBIFRuiw4VRiHrhHVkpl0+ISlJm ksAnSwpohykAnOhCNTMmusUpBgJN66az9vTjRzpLsJRkfqrY4+AW6FG9ZZeX7mlQT1LY4f KRL36lJBYeDD3FmmER/gvYGxhzs/cxA= X-MC-Unique: qwEyC1H1ONWxKLktjkCcng-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 04/14] bhyve: refactor bhyveConnectDomainXMLToNative Date: Mon, 13 Dec 2021 14:59:33 +0100 Message-Id: <16df61fe0afb0bd1d5a905ebc24906aeeab8d038.1639403837.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639404115313100001 Use g_auto and remove the ret variable, as well as the cleanup label. Signed-off-by: J=C3=A1n Tomko --- src/bhyve/bhyve_driver.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 21407a3957..f291f12e50 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -671,27 +671,26 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn, g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; struct _bhyveConn *privconn =3D conn->privateData; g_autoptr(virDomainDef) def =3D NULL; - virCommand *cmd =3D NULL; - virCommand *loadcmd =3D NULL; - char *ret =3D NULL; + g_autoptr(virCommand) cmd =3D NULL; + g_autoptr(virCommand) loadcmd =3D NULL; =20 virCheckFlags(0, NULL); =20 if (virConnectDomainXMLToNativeEnsureACL(conn) < 0) - goto cleanup; + return NULL; =20 if (STRNEQ(format, BHYVE_CONFIG_FORMAT_ARGV)) { virReportError(VIR_ERR_INVALID_ARG, _("Unsupported config type %s"), format); - goto cleanup; + return NULL; } =20 if (!(def =3D virDomainDefParseString(xmlData, privconn->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIV= E))) - goto cleanup; + return NULL; =20 if (bhyveDomainAssignAddresses(def, NULL) < 0) - goto cleanup; + return NULL; =20 if (def->os.bootloader =3D=3D NULL && def->os.loader) { @@ -699,35 +698,30 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn, if (!virDomainDefHasOldStyleROUEFI(def)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Only read-only pflash is supported.")); - goto cleanup; + return NULL; } =20 if ((bhyveDriverGetBhyveCaps(privconn) & BHYVE_CAP_LPC_BOOTROM) = =3D=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Installed bhyve binary does not support " "bootrom")); - goto cleanup; + return NULL; } } else { if (!(loadcmd =3D virBhyveProcessBuildLoadCmd(privconn, def, "", NULL))) - goto cleanup; + return NULL; =20 virCommandToStringBuf(loadcmd, &buf, false, false); virBufferAddChar(&buf, '\n'); } =20 if (!(cmd =3D virBhyveProcessBuildBhyveCmd(privconn, def, true))) - goto cleanup; + return NULL; =20 virCommandToStringBuf(cmd, &buf, false, false); =20 - ret =3D virBufferContentAndReset(&buf); - - cleanup: - virCommandFree(loadcmd); - virCommandFree(cmd); - return ret; + return virBufferContentAndReset(&buf); } =20 static int --=20 2.31.1