From nobody Mon Feb 9 19:30:24 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=1675180971; cv=none; d=zohomail.com; s=zohoarc; b=Kp+BWFxFMcrvYC2405n8A4bPoT+/pOFtxZXzD7ov9kRSyRU9Ys21IvSVY+v1tS3QRQvvBPrnM+IwLu46MGdD1LJfTIz7/ZKiryHcJjQHYSnKx8hsT5Txk4vqtSBrNTbTAvj5jLg/qDRGaoxrfMiK7TrgRjZRm6C9M8pfsZPrb+o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675180971; 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=YmZrG9PuhL7JRg2pu9D6eU7UpxNyhdDjP0cASceK2U0=; b=fWNn13rW0JXsPefQBwGpUTIrSjjk8/dPFbYL2OWRvfyxUQYrvoxxbw15Yd4ms4Xo80gWLY/oGvDQdW/WUMsC+YJlBAAcqdUSqvkIzRdke01oSAa3lzAC2tIeuBEHzhof/ASuvqFcT4ILhb9qFmUyABAXlJbhNpcq7l8JqBbOnSE= 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 1675180971289548.2707308459302; Tue, 31 Jan 2023 08:02:51 -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-176-iz1p36_DOWCpjbGtv14COg-1; Tue, 31 Jan 2023 11:02:43 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6B65881DB86; Tue, 31 Jan 2023 16:02:33 +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 5146140C2064; Tue, 31 Jan 2023 16:02:33 +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 38CFB1946589; Tue, 31 Jan 2023 16:02:33 +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 16E0A1946A47 for ; Tue, 31 Jan 2023 16:02:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F01E14010E36; Tue, 31 Jan 2023 16:02:31 +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 4AFFF40C141B for ; Tue, 31 Jan 2023 16:02:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675180970; 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=YmZrG9PuhL7JRg2pu9D6eU7UpxNyhdDjP0cASceK2U0=; b=P05WZt/HE7o5FXHsYn4t4t3TKrZdpBx0l8PcFOjCla8qcDZJh5aCr3F0cuqpoAK10ceufX 5tqi3kEhZM+Uhu6b2EW+YnXFKKXSsTBaVsAx22yNDy+Jzs2A8yLROfRjh1LALT3TllbmZU P7sO7XjgcxkR2MhqxWb9zrlYBU4QsGw= X-MC-Unique: iz1p36_DOWCpjbGtv14COg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/7] virStorageBackendISCSIDirectSetAuth: Refactor cleanup Date: Tue, 31 Jan 2023 17:02:16 +0100 Message-Id: <311ae7c5edaf8f62ec3845aae91144a882f6b2f0.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.1 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: 1675180973112100006 Content-Type: text/plain; charset="utf-8" Use automatic pointer for 'conn' and remove the 'cleanup' label and 'ret' variable. Signed-off-by: Peter Krempa --- src/storage/storage_backend_iscsi_direct.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/storage/storage_backend_iscsi_direct.c b/src/storage/stora= ge_backend_iscsi_direct.c index 5df5447066..63225c533e 100644 --- a/src/storage/storage_backend_iscsi_direct.c +++ b/src/storage/storage_backend_iscsi_direct.c @@ -91,8 +91,7 @@ virStorageBackendISCSIDirectSetAuth(struct iscsi_context = *iscsi, 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) @@ -104,19 +103,19 @@ virStorageBackendISCSIDirectSetAuth(struct iscsi_cont= ext *iscsi, if (authdef->authType !=3D VIR_STORAGE_AUTH_TYPE_CHAP) { virReportError(VIR_ERR_XML_ERROR, "%s", _("iscsi-direct pool only supports 'chap' auth type= ")); - return ret; + return -1; } if (!(oldident =3D virIdentityElevateCurrent())) return -1; if (!(conn =3D virGetConnectSecret())) - return ret; + return -1; if (virSecretGetSecretString(conn, &authdef->seclookupdef, VIR_SECRET_USAGE_TYPE_ISCSI, &secret_value, &secret_size) < 0) - goto cleanup; + return -1; secret_str =3D g_new0(char, secret_size + 1); memcpy(secret_str, secret_value, secret_size); @@ -125,17 +124,15 @@ virStorageBackendISCSIDirectSetAuth(struct iscsi_cont= ext *iscsi, if (iscsi_set_initiator_username_pwd(iscsi, authdef->username, secret_str) < = 0) { + virSecureErase(secret_str, secret_size); virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to set credential: %s"), iscsi_get_error(iscsi)); - goto cleanup; + return -1; } - - ret =3D 0; - cleanup: virSecureErase(secret_str, secret_size); - virObjectUnref(conn); - return ret; + + return 0; } static int --=20 2.39.1