From nobody Mon May 6 05:06:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1598271125; cv=none; d=zohomail.com; s=zohoarc; b=GT3u2sBXRKaDwmlDTRY+QcfwaM3PUYtUHGAFycqQpCr49+ZUALl/XWiPBqJk859GzVT5l7w5GMSHyzIfMouN/04CBu16LAWX4VcCq48ewL6Q1SmjHuisU3g1h5wDcfAxUKuqO7n5Wg2K03U6bNyHTUzErnkhuo3OJC8PdgDSNw4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598271125; 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=rRSoNID+1yeZIJmYnvP2uVq/Npv5fW0Z4QiZVezR4l8=; b=NJkokpPdkH6IragwM4BJLpFU0bDlh6lwWUj3WurARwRFa1BhnrSU0l+XJMu1iYe1pEp/DhbsTAgF+zBaxMJDOQfryqa3hc9uxs8AgSp+dUGaEbBSq0rE9mOZY6tQF1lE6WiT+fG0/RuWtvwQ48qO7Wj7sdIUz+9FhkX9rJ5qLnY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1598271125139514.8655937811321; Mon, 24 Aug 2020 05:12:05 -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-315-t9H3a4JZMCW0oYHuxXHXsw-1; Mon, 24 Aug 2020 08:11:11 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F0482801AF9; Mon, 24 Aug 2020 12:11:03 +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 CC09F1001B2B; Mon, 24 Aug 2020 12:11:03 +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 942ED18A0B66; Mon, 24 Aug 2020 12:11:03 +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 07OC654d030794 for ; Mon, 24 Aug 2020 08:06:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 14B1510013C1; Mon, 24 Aug 2020 12:06:05 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B59F10013D9 for ; Mon, 24 Aug 2020 12:06:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598271123; 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=rRSoNID+1yeZIJmYnvP2uVq/Npv5fW0Z4QiZVezR4l8=; b=RhHncjg5BwCYckrJJxPOEVOn8mV6aR/wJSSOjcXkC5Y0uQKTaDz6fO9fDhQzcmZff5AS1c bhIJNSOqGPt87kHQuRd1xz6p0CwBTDboINzaK7lAW6FSqH09qnJWQca/VoAbspKTx9Kdre +gGoXwWN93eepYI8TO8MMcCHDFAmOI8= X-MC-Unique: t9H3a4JZMCW0oYHuxXHXsw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/7] qemuMigrationParamsNew: Use new memory allocation to simplify code Date: Mon, 24 Aug 2020 14:05:53 +0200 Message-Id: <23e69dae1089851f21e6e58fb139d182fb07fc78.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.84 on 10.5.11.22 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 cleaning and allocate via g_new0. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration_params.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 04434e9557..f466c3c4f6 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -244,20 +244,14 @@ qemuMigrationParamsGetAlwaysOnCaps(qemuMigrationParty= party) qemuMigrationParamsPtr qemuMigrationParamsNew(void) { - qemuMigrationParamsPtr params; + g_autoptr(qemuMigrationParams) params =3D NULL; - if (VIR_ALLOC(params) < 0) - return NULL; - - params->caps =3D virBitmapNew(QEMU_MIGRATION_CAP_LAST); - if (!params->caps) - goto error; + params =3D g_new0(qemuMigrationParams, 1); - return params; + if (!(params->caps =3D virBitmapNew(QEMU_MIGRATION_CAP_LAST))) + return NULL; - error: - qemuMigrationParamsFree(params); - return NULL; + return g_steal_pointer(¶ms); } --=20 2.26.2 From nobody Mon May 6 05:06:38 2024 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=1598271092; cv=none; d=zohomail.com; s=zohoarc; b=SWg0R+9al6VCs+j1/qO+76F3yooaJffyDIcJxwklWPtPUbSQ6CUzWg5eGFJT7P2hI4V06RsI8Ui+Ze74m3oJ8kSu5zbFRPK0CW+EdNPv6XmIbqSOUiEEiMcPiGP/r0wEUYuiBnul7D8W1QrtYzg33VLcT+tqzWqZ8pN+m05AP1U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598271092; 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=KW3bNmIhlsJeKJFpmKtDSwSJBBpYn7oIMssObBnDpMI=; b=jn0wEfTDAmriK5SxTlHKQG3PEUXI5blI9nYLLuEO4A4O98yhuDCoXWnqLc9YqfvQIpASjzrFFBG7eNMXaHpVLIMwSMoZdjl53QZ7GEYCnymnlkuVkF7mViH9GSnfadq82w56tjP4+3Hh2KB81o+eQKYNcfMujOlj6BUNGSwoooI= 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 1598271092854264.15031194468713; Mon, 24 Aug 2020 05:11:32 -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-21-6iahL1NOP3yLZ5sH1taVLA-1; Mon, 24 Aug 2020 08:11:29 -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 75AB38030DA; Mon, 24 Aug 2020 12:11:23 +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 56E7C7C674; Mon, 24 Aug 2020 12:11:23 +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 23F9866915; Mon, 24 Aug 2020 12:11:23 +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 07OC669A030802 for ; Mon, 24 Aug 2020 08:06:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2AEC710013C1; Mon, 24 Aug 2020 12:06:06 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8761110013D9 for ; Mon, 24 Aug 2020 12:06:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598271091; 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=KW3bNmIhlsJeKJFpmKtDSwSJBBpYn7oIMssObBnDpMI=; b=OZB9Y0FhDEU3EGL410S5S/OQF2ahyX9qnEConCWG/xQzFVBoaOxOQhYsmYFRDjDRbIS8qk o9u1TGBCWxJpsC1oBaxKpNH4IXOwZaMBSTLYHGLf/EkyFZk/DjwcPcZuGAdtXSag0CMzde AGvtDb43fZn7SQGfQ88+mY1fc+svfWo= X-MC-Unique: 6iahL1NOP3yLZ5sH1taVLA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/7] qemuMigrationParamsFromFlags: Use 'g_autoptr' to remove 'error:' label Date: Mon, 24 Aug 2020 14:05:54 +0200 Message-Id: <16ac42155104f7f85058d5e5ef89bf201199e820.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" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration_params.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index f466c3c4f6..03d8d4fb49 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -534,7 +534,7 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr param= s, unsigned long flags, qemuMigrationParty party) { - qemuMigrationParamsPtr migParams; + g_autoptr(qemuMigrationParams) migParams =3D NULL; size_t i; if (!(migParams =3D qemuMigrationParamsNew())) @@ -565,14 +565,14 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr par= ams, if (qemuMigrationParamsGetTPInt(migParams, item->param, params, nparams, item->typedParam, item->unit) < 0) - goto error; + return NULL; break; case QEMU_MIGRATION_PARAM_TYPE_ULL: if (qemuMigrationParamsGetTPULL(migParams, item->param, params, nparams, item->typedParam, item->unit) < 0) - goto error; + return NULL; break; case QEMU_MIGRATION_PARAM_TYPE_BOOL: @@ -581,7 +581,7 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr param= s, case QEMU_MIGRATION_PARAM_TYPE_STRING: if (qemuMigrationParamsGetTPString(migParams, item->param, par= ams, nparams, item->typedParam) = < 0) - goto error; + return NULL; break; } } @@ -591,24 +591,20 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr par= ams, !(flags & VIR_MIGRATE_AUTO_CONVERGE)) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("Turn auto convergence on to tune it")); - goto error; + return NULL; } if (migParams->params[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS].set && !(flags & VIR_MIGRATE_PARALLEL)) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("Turn parallel migration on to tune it")); - goto error; + return NULL; } if (qemuMigrationParamsSetCompression(params, nparams, flags, migParam= s) < 0) - goto error; - - return migParams; + return NULL; - error: - qemuMigrationParamsFree(migParams); - return NULL; + return g_steal_pointer(&migParams); } --=20 2.26.2 From nobody Mon May 6 05:06:38 2024 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=1598271018; cv=none; d=zohomail.com; s=zohoarc; b=O2KpL9uxMZIkzn2cehUV1IGSqVNoYzhri0UJ7IPP5vTlgfisLUXV19D5uijE34BpANfxl246GuCLDPhYjkO+ra5bUsBABvunndxTSynRDLP26dhh57oRz99nJpaOjUIHF4fuVE/gpzG2YJ6aB0ciraIIj46gFbXFicDbvdvuVw0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598271018; 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=C2yEo4SHz/aFw5FAmSARxsfXWGYtV9Sms3WXwvLdQts=; b=f44mUlfE0vdo0CUMct2ymzEuJq0hDxupbAqTbqFDnQL822Fr6A5b+UisbpRhirKaTbwQTEDhzlgXtJn+kIWsYSSiqyDTaDhekR+6KgshPnyLriIeEqiiwAgoXOGupLEgevrgelbWIaWzkx6xkukwnF58BvrXBr/AZaBHWwcO2EU= 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 159827101830297.85600605275079; Mon, 24 Aug 2020 05:10:18 -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-337-O_VjVl-lOL2q2doGZaQWBg-1; Mon, 24 Aug 2020 08:10:14 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1122A81F00C; Mon, 24 Aug 2020 12:10:09 +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 9E1B81972B; Mon, 24 Aug 2020 12:10:08 +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 C1FF5668E0; Mon, 24 Aug 2020 12:10:06 +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 07OC6754030812 for ; Mon, 24 Aug 2020 08:06:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3BB0F10013C4; Mon, 24 Aug 2020 12:06:07 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E7F010013C1 for ; Mon, 24 Aug 2020 12:06:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598271016; 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=C2yEo4SHz/aFw5FAmSARxsfXWGYtV9Sms3WXwvLdQts=; b=FssVQJkMO85T5Yxtg7ABRgpCTP+V2gw5+lW4ie4SOX/5ICCs1EplDV4ln/5Xx8g4GOT4Dw Rg0Ch+nDByS3ft4AHaim8OPYVzTnadSoOf+DFU7l2NZjrZXeHYyMcPGatVMYwPb1CmGtpB zmkWjrfsy1WLUz9QZq+PooHox3872E4= X-MC-Unique: O_VjVl-lOL2q2doGZaQWBg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/7] qemuMigrationParamsFromJSON: Unify return value handling with other functions Date: Mon, 24 Aug 2020 14:05:55 +0200 Message-Id: <06e2295ff43ab44be5cf08441a701f11b9016455.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.84 on 10.5.11.23 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" This function doesn't have an overly verbose cleanup section as there isn't any error code path. Unify it with the rest of the functions which will simplify adding a possible error path. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration_params.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 03d8d4fb49..3ed55c2ab4 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -670,7 +670,7 @@ qemuMigrationParamsDump(qemuMigrationParamsPtr migParam= s, qemuMigrationParamsPtr qemuMigrationParamsFromJSON(virJSONValuePtr params) { - qemuMigrationParamsPtr migParams; + g_autoptr(qemuMigrationParams) migParams =3D NULL; qemuMigrationParamValuePtr pv; const char *name; const char *str; @@ -680,7 +680,7 @@ qemuMigrationParamsFromJSON(virJSONValuePtr params) return NULL; if (!params) - return migParams; + return g_steal_pointer(&migParams); for (i =3D 0; i < QEMU_MIGRATION_PARAM_LAST; i++) { name =3D qemuMigrationParamTypeToString(i); @@ -711,7 +711,7 @@ qemuMigrationParamsFromJSON(virJSONValuePtr params) } } - return migParams; + return g_steal_pointer(&migParams); } --=20 2.26.2 From nobody Mon May 6 05:06:38 2024 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 From nobody Mon May 6 05:06:38 2024 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=1598271114; cv=none; d=zohomail.com; s=zohoarc; b=J7nBxOdOaQYuEdkLbi2y8pD6BNBeSGt53UmdDxWpF2UFLdhJ3X+Ld8dCYwQWnGJCCDL4b0ttyjuq6Q/+VJxYJNT1U4UHPPBzJThAR2XBxRj7VEftd0Cs9pfwHkx7I151n7qBrlbFdyVcfr7F85nPcGud2Twsrrt6liCpfWf+SEA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598271114; 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=0o9qO7RMFtGtELlCR1TjwQjJjkBLOQXee6KudLSfO5g=; b=mfHGhLs8Q9BPV94SvMMIVqKaGQeXg09pZSdOylWAKOphq5bg2gFCluYzZU2ar/JDjbFjRiF82ucY+ThEyNwHN55nQBGlFaJJ6Hly4AUKZfcBfnO6MSWBwTBMqMvNbPQeqKLxb5f8PGWEm/R8GfLe3P0o6rT4yI5ojo/nCanOfEc= 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 1598271114116834.8799705395413; Mon, 24 Aug 2020 05:11:54 -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-15-CHWaOmAlPouypQD2q3x1Xw-1; Mon, 24 Aug 2020 08:11:50 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9A4BE81F010; Mon, 24 Aug 2020 12:11:44 +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 7A14E5DA2A; Mon, 24 Aug 2020 12:11:44 +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 86B8218A0B69; Mon, 24 Aug 2020 12:11:43 +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 07OC69VB030825 for ; Mon, 24 Aug 2020 08:06:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 70DC310013C4; Mon, 24 Aug 2020 12:06:09 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC6CF10013C1 for ; Mon, 24 Aug 2020 12:06:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598271112; 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=0o9qO7RMFtGtELlCR1TjwQjJjkBLOQXee6KudLSfO5g=; b=hDb+YZflie7WmOUbPEIfk42nl2p1s0zmiaJqad4QTFq8c50Ef7KaMcpQZTdlNOlNcsdmWr k8bYp16sRGmZzk2xhIYoVvga17imt9SSXg8y8Lvd/AOMKu8+j5NQHeKqlD0pgJE02A5+CF XcZTT8oLn1DFAtHzF3pVw3oJ4wLGc+o= X-MC-Unique: CHWaOmAlPouypQD2q3x1Xw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/7] qemuMigrationCapsToJSON: Refactor variable cleanup Date: Mon, 24 Aug 2020 14:05:57 +0200 Message-Id: <05092bb347545b2acf357e7d77803e1e4acec6d4.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.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.002 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 | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index c22362735a..9b6601367a 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -759,14 +759,12 @@ virJSONValuePtr qemuMigrationCapsToJSON(virBitmapPtr caps, virBitmapPtr states) { - virJSONValuePtr json =3D NULL; - virJSONValuePtr cap =3D NULL; + g_autoptr(virJSONValue) json =3D virJSONValueNewArray(); qemuMigrationCapability bit; - const char *name; - - json =3D virJSONValueNewArray(); for (bit =3D 0; bit < QEMU_MIGRATION_CAP_LAST; bit++) { + g_autoptr(virJSONValue) cap =3D virJSONValueNewObject(); + const char *name =3D qemuMigrationCapabilityTypeToString(bit); bool supported =3D false; bool state =3D false; @@ -776,27 +774,19 @@ qemuMigrationCapsToJSON(virBitmapPtr caps, ignore_value(virBitmapGetBit(states, bit, &state)); - cap =3D virJSONValueNewObject(); - - name =3D qemuMigrationCapabilityTypeToString(bit); if (virJSONValueObjectAppendString(cap, "capability", name) < 0) - goto error; + return NULL; if (virJSONValueObjectAppendBoolean(cap, "state", state) < 0) - goto error; + return NULL; if (virJSONValueArrayAppend(json, cap) < 0) - goto error; + return NULL; cap =3D NULL; } - return json; - - error: - virJSONValueFree(json); - virJSONValueFree(cap); - return NULL; + return g_steal_pointer(&json); } --=20 2.26.2 From nobody Mon May 6 05:06:38 2024 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 From nobody Mon May 6 05:06:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1598271136; cv=none; d=zohomail.com; s=zohoarc; b=oGvqUP/z0fJSptB/qgYk6wX2HqWTRrIqwURwHxjlpCJQN83D9XbMvBTyupiHD/6nSvwomuikRifQrFpHaebXZEWfj0XIypkCb1yxQU7BVoR9/V7gPbRQyDnBs6YYUFQDwoesBAcefNO5BAY7JdzIpCt/y8axW4ZrXRbLx+CkGfY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598271136; 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=IRwqEbRn4H0Z25w8REOuIWjw3vDt2xSe/abQ03aPikM=; b=KKYUKFpxAFjxA2P6tR37uUM4DqHO+QmYNtzAY3l4w3gj9jTiuwnYBYLNmbFN/OCNJzk0L5k1RltcCRuTwg3NuemHOPUAVwKGejkEJ3c979KSQ8iDf23rtia2n8skhazO3s7sJL1KLorgakxfCHWNoBBUswYg4td6unO0ojqoopA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 159827113647254.05442616885057; Mon, 24 Aug 2020 05:12:16 -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-184-TmgEewimNLGS2spfI9i_Tg-1; Mon, 24 Aug 2020 08:12:10 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6E05D801AE6; Mon, 24 Aug 2020 12:12:05 +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 4D0FD5FC3B; Mon, 24 Aug 2020 12:12:05 +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 1B76B18A0B6A; Mon, 24 Aug 2020 12:12:05 +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 07OC6BgQ030850 for ; Mon, 24 Aug 2020 08:06:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9FFE410013C4; Mon, 24 Aug 2020 12:06:11 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0052E10013C1 for ; Mon, 24 Aug 2020 12:06:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598271135; 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=IRwqEbRn4H0Z25w8REOuIWjw3vDt2xSe/abQ03aPikM=; b=go496uWUGMt3mcNHcStzl0I+p0RStf7vpqh1QF/7t8aLjk04OFexxlfgC3IB3iW631yZfz U+1kOg8wfRBnFxhm+HkixmdrWgjmo3pkRWLuIXRWWRDpn9rdAujSeTLyyRXingmqzltiDz Ohmo+6yOWuFzQHL8F8JlPu3lxgOp3UA= X-MC-Unique: TmgEewimNLGS2spfI9i_Tg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 7/7] qemuMigrationCapsCheck: Refactor variable cleanup Date: Mon, 24 Aug 2020 14:05:59 +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.16 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 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 | 33 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 38a5a91f2a..c785f87ab8 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -1352,11 +1352,10 @@ qemuMigrationCapsCheck(virQEMUDriverPtr driver, int asyncJob) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - virBitmapPtr migEvent =3D NULL; - virJSONValuePtr json =3D NULL; - char **caps =3D NULL; + g_autoptr(virBitmap) migEvent =3D NULL; + g_autoptr(virJSONValue) json =3D NULL; + VIR_AUTOSTRINGLIST caps =3D NULL; char **capStr; - int ret =3D -1; int rc; if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) @@ -1365,16 +1364,14 @@ qemuMigrationCapsCheck(virQEMUDriverPtr driver, rc =3D qemuMonitorGetMigrationCapabilities(priv->mon, &caps); if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) - goto cleanup; + return -1; - if (!caps) { - ret =3D 0; - goto cleanup; - } + if (!caps) + return 0; priv->migrationCaps =3D virBitmapNew(QEMU_MIGRATION_CAP_LAST); if (!priv->migrationCaps) - goto cleanup; + return -1; for (capStr =3D caps; *capStr; capStr++) { int cap =3D qemuMigrationCapabilityTypeFromString(*capStr); @@ -1390,21 +1387,21 @@ qemuMigrationCapsCheck(virQEMUDriverPtr driver, if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT)) { migEvent =3D virBitmapNew(QEMU_MIGRATION_CAP_LAST); if (!migEvent) - goto cleanup; + return -1; ignore_value(virBitmapSetBit(migEvent, QEMU_MIGRATION_CAP_EVENTS)); if (!(json =3D qemuMigrationCapsToJSON(migEvent, migEvent))) - goto cleanup; + return -1; if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - goto cleanup; + return -1; rc =3D qemuMonitorSetMigrationCapabilities(priv->mon, json); json =3D NULL; if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; + return -1; if (rc < 0) { virResetLastError(); @@ -1420,13 +1417,7 @@ qemuMigrationCapsCheck(virQEMUDriverPtr driver, ignore_value(virBitmapClearBit(priv->migrationCaps, QEMU_MIGRATION_CAP_EVENTS)); - ret =3D 0; - - cleanup: - virBitmapFree(migEvent); - virJSONValueFree(json); - g_strfreev(caps); - return ret; + return 0; } --=20 2.26.2