From nobody Mon Feb 9 09:08:36 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=1652713984; cv=none; d=zohomail.com; s=zohoarc; b=mCFWIrbCQqyi1BhEo6kEtMoIizj4sTQqq6SXhBO2pC4rsjr+1wt5jyWkzg8zWep+5PeiLkLSnjBHwAvHpPcwWhAMuhtyLSjjfubl6QZ+6pp9ahSkUwA1jWi2qqMstfk5E8Ky4lr1mdSG8WJlv1YT/ate7tbVZtUd4eUOV618qAs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652713984; 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=+AgRmt8kK4sG0J9A3AYQkWf0JWZge/718OVYOeAwRuM=; b=Z0MfwfIKHO6pAZ0wp3uSr1LNNIgw8VV8tPPwlR/BKSmggBxuWC2oiQw4kaFINpdQZnxY3ucACegiFbuVgvpG2fdhPSPr6cwtDnJNfeVIHUp2kG0o63ZEs3rgXkaYip+NtvAAjS/DoTkXYevRvk9np5D0ZJLdAMiVuGHNinCJgJ0= 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 1652713984530296.9835114759454; Mon, 16 May 2022 08:13:04 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-301-_5Q25Y_HOLuRnjiMP4LFDg-1; Mon, 16 May 2022 11:12:59 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 628E0811E80; Mon, 16 May 2022 15:12:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F3D2492C14; Mon, 16 May 2022 15:12:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2AAA31947054; Mon, 16 May 2022 15:12:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D17A4194704E for ; Mon, 16 May 2022 15:12:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AFFB2403152; Mon, 16 May 2022 15:12:50 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B52340316E for ; Mon, 16 May 2022 15:12:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652713983; 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=+AgRmt8kK4sG0J9A3AYQkWf0JWZge/718OVYOeAwRuM=; b=UDwPX99iSwkHmMErnUU/uL9NiLwJIfM8HLdxhbON0H/5rJzgKTFRc1A+gVrqfRItyvqdvb XrzZdHIHKWjInNi++yJ1IuLqHSK2hHCQ9b1/bK/5Yf79UAbg7jPZ+9N4M0s5G4eXVC6xXV 5hsp7hKEscFxKVx1D92rJg0nva+eq7Y= X-MC-Unique: _5Q25Y_HOLuRnjiMP4LFDg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/11] qemuConnectDomainXMLToNative: Refactor cleanup Date: Mon, 16 May 2022 17:12:37 +0200 Message-Id: <9f0d4d78239f51666c7057b73523d7dd46da87a3.1652710341.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652713986491100005 Content-Type: text/plain; charset="utf-8" Automatically free the 'vm' temporary domain object and remove the 'cleanup' label and 'ret' helper variable. Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 96ca67dfca..b862208327 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6337,30 +6337,29 @@ static char *qemuConnectDomainXMLToNative(virConnec= tPtr conn, unsigned int flags) { virQEMUDriver *driver =3D conn->privateData; - virDomainObj *vm =3D NULL; + g_autoptr(virDomainObj) vm =3D NULL; g_autoptr(virCommand) cmd =3D NULL; unsigned int commandlineflags =3D QEMU_BUILD_COMMAND_LINE_CPUS_RUNNING; - char *ret =3D NULL; size_t i; virCheckFlags(0, NULL); if (virConnectDomainXMLToNativeEnsureACL(conn) < 0) - goto cleanup; + return NULL; if (STRNEQ(format, QEMU_CONFIG_FORMAT_ARGV)) { virReportError(VIR_ERR_INVALID_ARG, _("unsupported config type %s"), format); - goto cleanup; + return NULL; } if (!(vm =3D virDomainObjNew(driver->xmlopt))) - goto cleanup; + return NULL; if (!(vm->def =3D virDomainDefParseString(xmlData, driver->xmlopt, NUL= L, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_ABI_UPDAT= E))) - goto cleanup; + return NULL; /* Since we're just exporting args, we can't do bridge/network/direct * setups, since libvirt will normally create TAP/macvtap devices @@ -6372,7 +6371,7 @@ static char *qemuConnectDomainXMLToNative(virConnectP= tr conn, virDomainNetDef *newNet =3D virDomainNetDefNew(driver->xmlopt); if (!newNet) - goto cleanup; + return NULL; newNet->type =3D VIR_DOMAIN_NET_TYPE_ETHERNET; newNet->info.bootIndex =3D net->info.bootIndex; @@ -6387,21 +6386,17 @@ static char *qemuConnectDomainXMLToNative(virConnec= tPtr conn, if (qemuProcessCreatePretendCmdPrepare(driver, vm, NULL, VIR_QEMU_PROCESS_START_COLD) < = 0) - goto cleanup; + return NULL; if (qemuConnectDomainXMLToNativePrepareHost(vm) < 0) - goto cleanup; + return NULL; if (!(cmd =3D qemuProcessCreatePretendCmdBuild(driver, vm, NULL, qemuCheckFips(vm), commandlineflags))) - goto cleanup; - - ret =3D virCommandToString(cmd, false); + return NULL; - cleanup: - virObjectUnref(vm); - return ret; + return virCommandToString(cmd, false); } --=20 2.35.3