From nobody Mon Feb 9 11:05:53 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1598271064; cv=none; d=zohomail.com; s=zohoarc; b=m9dfMN17wVvjxUr2F9COn8YugTEWinijfPoSpXirU0wVsPFzKINzjVp3NOGmIasLIT1fIHHIlWaXQbvEVPBgSGxft9n6C90Xk5qnispFNF8RIyev49rRLkxK04kA30WVayoc4ZqQrJUKqMVf23sc3nFBSMsJv9XVsK+5MPaull8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598271064; 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=GmoHFQ2xdDIoZSq6kMdyMGVQKcfDwnttk65HUR8p6bk=; b=dQMrCKdLXgb/WBaH8jzUJFXXtoZHPgFoENxwt83qDtonCO9zw32OgJWTgjSl3evdQo3/pC9x9Q0OYuiSdLRRSOdQjqIcPp5rlNkkzWp6ZGlMku+dv4RNK143b/TLf5X7zYz+F5UMVvgFk+B4EhFuQ7LmYU9b5K3mmJO8ujZA2ZA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1598271064819394.5907851538766; Mon, 24 Aug 2020 05:11:04 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-319-Bo_RXt9eNkSw3Vms9uMHJg-1; Mon, 24 Aug 2020 08:11:01 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 840E018BA296; Mon, 24 Aug 2020 12:10:55 +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 65AE27C653; Mon, 24 Aug 2020 12:10:55 +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 0CE8218A0B65; Mon, 24 Aug 2020 12:10:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 07OC6AGv030841 for ; Mon, 24 Aug 2020 08:06:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8EDB310013C4; Mon, 24 Aug 2020 12:06:10 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id D53F810013C1 for ; Mon, 24 Aug 2020 12:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598271063; 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=GmoHFQ2xdDIoZSq6kMdyMGVQKcfDwnttk65HUR8p6bk=; b=NBMO5LVuenZAWEIvY5ePRchZe2hH8nCfzvXAZ30nYQYwJkqkdwBq7s/3UzUlzxwqJPK9mG Ixky2UCvyC3zGJSUwHCrBCr8Y4QEQd6fQVvCNhUTT1CSuAEl88O5OxNyIGu6gFb1fu9hdK 86FHPRdEIExOcTcNpzL1AuWEzKWKeN8= X-MC-Unique: Bo_RXt9eNkSw3Vms9uMHJg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 6/7] qemuMigrationParamsParse: Refactor variable cleanup Date: Mon, 24 Aug 2020 14:05:58 +0200 Message-Id: <9f0ddd78fe75bcd720ac176df92695ac8274f8cf.1598270694.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use automatic memory allocation and move variables into correct scope to simplify the code and remove the need for a 'cleanup:' label. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration_params.c | 40 ++++++++++++-------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 9b6601367a..38a5a91f2a 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -1265,44 +1265,42 @@ int qemuMigrationParamsParse(xmlXPathContextPtr ctxt, qemuMigrationParamsPtr *migParams) { - qemuMigrationParamsPtr params =3D NULL; + g_autoptr(qemuMigrationParams) params =3D NULL; qemuMigrationParamValuePtr pv; - xmlNodePtr *nodes =3D NULL; - char *name =3D NULL; - char *value =3D NULL; - int param; + g_autofree xmlNodePtr *nodes =3D NULL; size_t i; int rc; int n; - int ret =3D -1; *migParams =3D NULL; if ((rc =3D virXPathBoolean("boolean(./migParams)", ctxt)) < 0) - goto cleanup; + return -1; - if (rc =3D=3D 0) { - ret =3D 0; - goto cleanup; - } + if (rc =3D=3D 0) + return 0; if ((n =3D virXPathNodeSet("./migParams[1]/param", ctxt, &nodes)) < 0) return -1; if (!(params =3D qemuMigrationParamsNew())) - goto cleanup; + return -1; for (i =3D 0; i < n; i++) { + g_autofree char *name =3D NULL; + g_autofree char *value =3D NULL; + int param; + if (!(name =3D virXMLPropString(nodes[i], "name"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing migration parameter name")); - goto cleanup; + return -1; } if ((param =3D qemuMigrationParamTypeFromString(name)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown migration parameter '%s'"), name); - goto cleanup; + return -1; } pv =3D ¶ms->params[param]; @@ -1310,7 +1308,7 @@ qemuMigrationParamsParse(xmlXPathContextPtr ctxt, virReportError(VIR_ERR_INTERNAL_ERROR, _("missing value for migration parameter '%s'"), name); - goto cleanup; + return -1; } rc =3D 0; @@ -1336,23 +1334,15 @@ qemuMigrationParamsParse(xmlXPathContextPtr ctxt, virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid value '%s' for migration parameter '= %s'"), value, name); - goto cleanup; + return -1; } pv->set =3D true; - VIR_FREE(name); - VIR_FREE(value); } *migParams =3D g_steal_pointer(¶ms); - ret =3D 0; - cleanup: - qemuMigrationParamsFree(params); - VIR_FREE(nodes); - VIR_FREE(name); - VIR_FREE(value); - return ret; + return 0; } --=20 2.26.2