From nobody Sun Feb 8 21:29:14 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1598271047; cv=none; d=zohomail.com; s=zohoarc; b=UtTp9cTTbA8PsvHfIVPN/bocuF3Gfh0x5WpIZYgFq9U4xzI+Qi9zEqg9tVNMzeZBdyS6u3iFw6pTaTSgPqReYHJW4JdaR3suTze7SrjC2CcLSSU6IByFpn6YtbZuo4UePOUlpPneMpZd1rpAou4S4SQsOoDrADd9Ab2JcWwocl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598271047; 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=a3wzNTTBIbAEKbXZ3Mjq6vwccssaao6RCJV9J+jMnW4=; b=O93k+1hhnA4NqPFk6byLnUoTrvwAMUX276B2jERdKKj3SkVs+U4Z389oeknWTnxjJyUNJPQv1sUPytCxWo7fXfTogR22f99dmzmW8Z83zsWNjqEjSTrCriyDeD3qnK+FQ1uS3NPfs+NmngfQ6P7xYmsyWX6W3JaLQH7WtNgS2kg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1598271047856327.7745985285958; Mon, 24 Aug 2020 05:10:47 -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-73-iE7j04OAPJKya6KdzoMrKA-1; Mon, 24 Aug 2020 08:10:42 -0400 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 E2FFB425E6; Mon, 24 Aug 2020 12:10:36 +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 299B77C80E; Mon, 24 Aug 2020 12:10:36 +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 CDC6466915; Mon, 24 Aug 2020 12:10:35 +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 07OC689p030817 for ; Mon, 24 Aug 2020 08:06:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5529910013C1; Mon, 24 Aug 2020 12:06:08 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id A465010013D9 for ; Mon, 24 Aug 2020 12:06:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598271046; 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=a3wzNTTBIbAEKbXZ3Mjq6vwccssaao6RCJV9J+jMnW4=; b=TdeYs9jk77jUaoAcgnsSEzesKq/n/R1KAFPspMhm7RcbaQN/vGD9WWW7g8vaDgjkmxu+yz BzyiFkOutwttbj8/snb0g3hfFcgV5apmuT/WAOXQa9ZAOZFOi7GTjXfBErnPe51kxN14EX Cy+OkQHQB3woKqSEGntLTgT8g9qFs/A= X-MC-Unique: iE7j04OAPJKya6KdzoMrKA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/7] qemuMigrationParamsToJSON: Refactor variable cleanup Date: Mon, 24 Aug 2020 14:05:56 +0200 Message-Id: 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.13 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 'error:' label. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration_params.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 3ed55c2ab4..c22362735a 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -718,20 +718,17 @@ qemuMigrationParamsFromJSON(virJSONValuePtr params) virJSONValuePtr qemuMigrationParamsToJSON(qemuMigrationParamsPtr migParams) { - virJSONValuePtr params =3D virJSONValueNewObject(); - qemuMigrationParamValuePtr pv; - const char *name; + g_autoptr(virJSONValue) params =3D virJSONValueNewObject(); size_t i; - int rc; for (i =3D 0; i < QEMU_MIGRATION_PARAM_LAST; i++) { - name =3D qemuMigrationParamTypeToString(i); - pv =3D &migParams->params[i]; + const char *name =3D qemuMigrationParamTypeToString(i); + qemuMigrationParamValuePtr pv =3D &migParams->params[i]; + int rc =3D 0; if (!pv->set) continue; - rc =3D 0; switch (qemuMigrationParamTypes[i]) { case QEMU_MIGRATION_PARAM_TYPE_INT: rc =3D virJSONValueObjectAppendNumberInt(params, name, pv->val= ue.i); @@ -751,14 +748,10 @@ qemuMigrationParamsToJSON(qemuMigrationParamsPtr migP= arams) } if (rc < 0) - goto error; + return NULL; } - return params; - - error: - virJSONValueFree(params); - return NULL; + return g_steal_pointer(¶ms); } --=20 2.26.2