From nobody Sun Feb 8 23:06:17 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=1670603363; cv=none; d=zohomail.com; s=zohoarc; b=VnQQOZZQwLZDIK7aPZiCS5ENgpdz/vL9MXKoPxOzGpR5wKeZcYaKH3CXwNSyTQXNKOfGzsRI27oIOS1CflJheWdwKOyIFPeZgstgqKZOla6PvYFSgSNs6uj6pjIX/iZKouRfejDThPqpbUzKyWCmRSX6LcMv9ngd7dKGxvkci20= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670603363; 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=sk9e2KGQCbpG0qH8KGDNXgk8eQpOqXviptVqb6R8koQ=; b=LqxLXu/7aupvRsk4yfdqeXha/ABZaU8U2Ac1bz4Uq5fDvaiE8fqXcFFl6GRR5XUtJ8oqnMwBcn80YXXCuvXeKNrTHRF+FzafvOkCni+8iSLVinnA8GDEquB14Q2d2kLfeb7Uo8peOFceMl9o6eyjehXZ6fT12OZLwAMNc0FHcbM= 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 1670603363707210.5021460004457; Fri, 9 Dec 2022 08:29:23 -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-443-bSg4SG-IObmedMF6Uau9Hw-1; Fri, 09 Dec 2022 11:29:19 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 64FEC802559; Fri, 9 Dec 2022 16:29:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38D9B2166B31; Fri, 9 Dec 2022 16:29:14 +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 B0AA2194706C; Fri, 9 Dec 2022 16:29:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CBBF2194704F for ; Fri, 9 Dec 2022 16:29:11 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C253F42222; Fri, 9 Dec 2022 16:29:11 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D61C1759E for ; Fri, 9 Dec 2022 16:29:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670603362; 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=sk9e2KGQCbpG0qH8KGDNXgk8eQpOqXviptVqb6R8koQ=; b=R8ef7QYbOUSQIb5y1dXkRb01AlD3Ps74aErrztnV1m8TjG/aJikAFiRtzZBqQi0LFMrdX1 jp0pBnc8mcJhnB06EO6vWdJhmLBwY//j29ljFKLnIAQNaTaGGSNfmDFHw7wdB1r2BRtR6i jsCmVyAlN5cqtV3FZ5S16fBfYy4N1sw= X-MC-Unique: bSg4SG-IObmedMF6Uau9Hw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/11] virStorageBackendISCSISetAuth: Refactor cleanup Date: Fri, 9 Dec 2022 17:28:58 +0100 Message-Id: <07ce7b04df20db9a3e69b5007f820ba131e6c007.1670603205.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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.6 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: 1670603364696100003 Content-Type: text/plain; charset="utf-8" Automatically free 'conn' and remove the 'cleanup' section and 'ret' variable. 'datatypes.h' contains the declaration of the autoptr cleanup function for virConnect. Signed-off-by: Peter Krempa --- src/storage/storage_backend_iscsi.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_back= end_iscsi.c index 9f9aa01f05..c5e3130a4f 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -26,6 +26,7 @@ #include #include +#include "datatypes.h" #include "driver.h" #include "storage_backend_iscsi.h" #include "viralloc.h" @@ -254,8 +255,7 @@ virStorageBackendISCSISetAuth(const char *portal, size_t secret_size; g_autofree char *secret_str =3D NULL; virStorageAuthDef *authdef =3D source->auth; - int ret =3D -1; - virConnectPtr conn =3D NULL; + g_autoptr(virConnect) conn =3D NULL; VIR_IDENTITY_AUTORESTORE virIdentity *oldident =3D NULL; if (!authdef || authdef->authType =3D=3D VIR_STORAGE_AUTH_TYPE_NONE) @@ -279,7 +279,7 @@ virStorageBackendISCSISetAuth(const char *portal, if (virSecretGetSecretString(conn, &authdef->seclookupdef, VIR_SECRET_USAGE_TYPE_ISCSI, &secret_value, &secret_size) < 0) - goto cleanup; + return -1; /* '\0' terminate the data into a string */ secret_str =3D g_strndup((char *) secret_value, secret_size); @@ -296,13 +296,9 @@ virStorageBackendISCSISetAuth(const char *portal, source->devices[0].path, "node.session.auth.password", secret_str) < 0) - goto cleanup; - - ret =3D 0; + return -1; - cleanup: - virObjectUnref(conn); - return ret; + return 0; } static int --=20 2.38.1