From nobody Mon Feb 9 19:30:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1675181004; cv=none; d=zohomail.com; s=zohoarc; b=HpJLUDpHy0Fjy5trE+T9OKlE3omjIGHsa/Y+/d7S/DdsZcuMUqLEBt4RqWeIznapbpsn8Bm7gydmt07xx2pWMHRk7j1dwV4vsMZX0DQ8WZEIKIa9i/XN0ot10ORUWlIhL54TzFSs9patXkVkoybigQPT0wyWkDX5Kol5FfUJRL4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675181004; 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=KLTSXoYVY00VeRFZ+OVH4oFuvvUqiQNjTBk4VlW1B6w=; b=DINEdIe9ynhw0yrM9hscgEx3aSswTXonLII/TOi0TsbCiwMZtIXeM5XFTUxtldWxe9FQcdjFNFAfJ9FxXinxo2xlNlKFoHLwIiSGIZCG8VqtYoBJOYJfr3EivQ9F+nCNCwObCd8YAKGtnH2mxB00/1cQOGE0IxLCIh+uBqTijms= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1675181004607933.9361253723441; Tue, 31 Jan 2023 08:03:24 -0800 (PST) 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-554-VtGBn4_EPK2c62blvb6VTw-1; Tue, 31 Jan 2023 11:02:48 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 92812857A81; Tue, 31 Jan 2023 16:02:35 +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 7BA092026D4B; Tue, 31 Jan 2023 16:02:35 +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 7166D1946589; Tue, 31 Jan 2023 16:02:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1B9F21946594 for ; Tue, 31 Jan 2023 16:02:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F2A134015319; Tue, 31 Jan 2023 16:02:33 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-29.brq.redhat.com [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6912E40C141B for ; Tue, 31 Jan 2023 16:02:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675181003; 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=KLTSXoYVY00VeRFZ+OVH4oFuvvUqiQNjTBk4VlW1B6w=; b=DE+W6Yf2Y7B53lILpBZZXPQwWR4QCgwCbalFqjgqQEHyYX2meqZP8tgTkZlGjzvqeZGAHS qj+I8LWIzk4c1LBpeROaRTJ4BgUa09WPZ/xhfRGND1/dSil7cS/uS/mGFtNKQnzpTScO3j G1NJfdgGzlPCdtzPesLbFl4Ibs9oI7c= X-MC-Unique: VtGBn4_EPK2c62blvb6VTw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 6/7] libxlMakeNetworkDiskSrc: Refactor cleanup Date: Tue, 31 Jan 2023 17:02:18 +0100 Message-Id: <26043c0c7d0c9f4c6867d328e3784741fa80cf2e.1675180728.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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 3.1 on 10.11.54.4 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: 1675181005331100001 Content-Type: text/plain; charset="utf-8" Automatically unref the 'conn' object and remove the 'cleanup' section and 'ret' variable. Signed-off-by: Peter Krempa --- src/libxl/libxl_conf.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 17ac880634..cee9f827f7 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1026,10 +1026,9 @@ libxlMakeNetworkDiskSrcStr(virStorageSource *src, static int libxlMakeNetworkDiskSrc(virStorageSource *src, char **srcstr) { - virConnectPtr conn =3D NULL; + g_autoptr(virConnect) conn =3D NULL; g_autofree char *base64secret =3D NULL; char *username =3D NULL; - int ret =3D -1; *srcstr =3D NULL; if (src->auth && src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_RBD) { @@ -1038,16 +1037,16 @@ libxlMakeNetworkDiskSrc(virStorageSource *src, char= **srcstr) VIR_IDENTITY_AUTORESTORE virIdentity *oldident =3D virIdentityElev= ateCurrent(); if (!oldident) - goto cleanup; + return -1; username =3D src->auth->username; if (!(conn =3D virConnectOpen("xen:///system"))) - goto cleanup; + return -1; if (virSecretGetSecretString(conn, &src->auth->seclookupdef, VIR_SECRET_USAGE_TYPE_CEPH, &secret, &secretlen) < 0) - goto cleanup; + return -1; /* RBD expects an encoded secret */ base64secret =3D g_base64_encode(secret, secretlen); @@ -1058,13 +1057,9 @@ libxlMakeNetworkDiskSrc(virStorageSource *src, char = **srcstr) virSecureEraseString(base64secret); if (!*srcstr) - goto cleanup; - - ret =3D 0; + return -1; - cleanup: - virObjectUnref(conn); - return ret; + return 0; } int --=20 2.39.1