From nobody Mon Feb 9 01:34:51 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=1652865749; cv=none; d=zohomail.com; s=zohoarc; b=Bb1BPbOYP75+d195m8odMRJmrmKnrMVwky0e7K39BZKoU5XBzwdW8CcvyIvGCrir2ZSc/KwIQK4noIlKxE5aTKsmXncaGmCdImxj41/6xtfgBj7Op/VrdaLFytCougJI18w0iMSSF2i+8yIWsgJW0aJQtoInCdIkTa02QIrYjn4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652865749; 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=B+aOTzu9mFkZiDhZl41DN3MmHvWnzBGmOzxUE6Aa/yk=; b=eY3dWmm7kObiBsMdNbLmQFXoMvRty1Flt0ueQf1n8R/amnfu6qoJDtL/Jyz3dPZimh3GTFqrM3QFW27ancEUSXby4FQtOq/ApvGRgDTph9hSm3dGFaUI2AAfKrh+P6OU9oN5XQuX7KQsx97fTIMV8s6JFbM9ze/5E0ccUB5NfEs= 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 1652865749087530.084390887447; Wed, 18 May 2022 02:22:29 -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-609-7WLj_RQmMtSUJ5yqOCWHvA-1; Wed, 18 May 2022 05:22:24 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 493A985A5BC; Wed, 18 May 2022 09:22:22 +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 34A2A1410DD5; Wed, 18 May 2022 09:22:22 +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 02C4F1947B8F; Wed, 18 May 2022 09:22:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 89EFE19259FB for ; Wed, 18 May 2022 09:22:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6BD5B40CF8F0; Wed, 18 May 2022 09:22:18 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id E299640CF8EE for ; Wed, 18 May 2022 09:22:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652865748; 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=B+aOTzu9mFkZiDhZl41DN3MmHvWnzBGmOzxUE6Aa/yk=; b=f/OIksZABcTX5uKHNHoqSr5xkFU3G4rSUm65L6sqoT73Okv75l/KS51vozGmg1KUmrukP4 UnxzB8xsx0RrQXd8cRs1D4bEQ0EfNbQEeYhExNCwUZFkbee6jjBEeEjDv2LTQnv14+IeuU IIVlfsLe0HG0B3qCU1AAMaEr021l/G0= X-MC-Unique: 7WLj_RQmMtSUJ5yqOCWHvA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/4] doRemoteOpen: Refactor control flow Date: Wed, 18 May 2022 11:22:13 +0200 Message-Id: <47a96a30025981733267d48d5affc77b6c111994.1652865683.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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.7 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: 1652865750849100001 Content-Type: text/plain; charset="utf-8" Use a temporary variable 'newconn' to hold the newly opened connection until we are ready to pass it back instead of the original connection. This way we can avoid complicated 'error'/'cleanup' sections. Signed-off-by: Peter Krempa --- src/remote/remote_daemon_dispatch.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 39953f46cf..c1f85925a3 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -1794,7 +1794,7 @@ remoteOpenConn(const char *uri, virConnectPtr *conn) { g_autoptr(virTypedParamList) identparams =3D NULL; - int ret =3D -1; + g_autoptr(virConnect) newconn =3D NULL; VIR_DEBUG("Getting secondary uri=3D%s readonly=3D%d preserveIdent=3D%d= conn=3D%p", NULLSTR(uri), readonly, preserveIdentity, conn); @@ -1814,34 +1814,30 @@ remoteOpenConn(const char *uri, return -1; if (!(identparams =3D virIdentityGetParameters(ident))) - goto error; + return -1; } VIR_DEBUG("Opening driver %s", uri); if (readonly) - *conn =3D virConnectOpenReadOnly(uri); + newconn =3D virConnectOpenReadOnly(uri); else - *conn =3D virConnectOpen(uri); - if (!*conn) - goto error; - VIR_DEBUG("Opened driver %p", *conn); + newconn =3D virConnectOpen(uri); + + if (!newconn) + return -1; + + VIR_DEBUG("Opened driver %p", newconn); if (preserveIdentity) { if (virConnectSetIdentity(*conn, identparams->par, identparams->np= ar, 0) < 0) - goto error; + return -1; VIR_DEBUG("Forwarded current identity to secondary driver"); } - ret =3D 0; - cleanup: - return ret; + *conn =3D g_steal_pointer(&newconn); - error: - if (*conn) { - g_clear_pointer(conn, virConnectClose); - } - goto cleanup; + return 0; } --=20 2.35.3