From nobody Mon Feb 9 03:31:55 2026 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=1612285006; cv=none; d=zohomail.com; s=zohoarc; b=Hj1jWicRisuAXBC5ot+6oKHg9ptNH76A/phwLNsNZ8r/bQcECBRZXrK2GzoNlf6HtTLcXJanH8iRIYZ3Ij7GMOqBvly8p41zByBx6bGn/gX0kq3+H7WL8XM/zMiJ6guTkPW2sMul09FeRKbBh4YPkdEXwQ/0OXVMCp4WS8yDxG0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285006; 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=oi9jb9auUd5bchyD22SAxZEBtXIkVxjEBPAKu0WTTno=; b=G7JlR68fZSBGsBt6RfEteRMfd82lr0inENy3J2evTFo+dRHz+oBmbKRmXf0ZLmGyRJ0Tgbnl1tZAWlnTaGxTcEfv7nACss17HXN7ULrFZQ3HwB4Q9LwP8PUCJm9bz1finNG06rrjdqK1Joq4NOtnlw3z6IZ3t/h7T4H76fobAUw= 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 1612285006933618.6397878822141; Tue, 2 Feb 2021 08:56:46 -0800 (PST) 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-45-ax2HE-NIOiaYuW4RVGMT1Q-1; Tue, 02 Feb 2021 11:56:40 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB191107ACFA; Tue, 2 Feb 2021 16:56:34 +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 B87245D722; Tue, 2 Feb 2021 16:56:34 +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 81B111809C92; Tue, 2 Feb 2021 16:56:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 112GuL26014917 for ; Tue, 2 Feb 2021 11:56:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id 16C5460862; Tue, 2 Feb 2021 16:56:21 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B7786EF45 for ; Tue, 2 Feb 2021 16:56:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285005; 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=oi9jb9auUd5bchyD22SAxZEBtXIkVxjEBPAKu0WTTno=; b=LTSfDpV1JlSCtIswGEQXtXZn26cg/PpaugGNOzthA5ioT2p5opxyU/DIWzmognjp4u2AUI zXeEhKz8JkpjmnbG8VzBJvP9U2rY2uVGZ76bFG0GIdc/OZVlaYnuoxt3PlI7uIcnoa1vtn j7i7IGtlWHQYb3fgdo7sD8h3KStIQI4= X-MC-Unique: ax2HE-NIOiaYuW4RVGMT1Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 06/27] virNetLibsshSessionAuthAddPrivKeyAuth: Refactor cleanup Date: Tue, 2 Feb 2021 17:55:43 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.15 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) Content-Type: text/plain; charset="utf-8" Shuffle the code around to remove the need for temporary variables and labels for cleaning them. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/rpc/virnetlibsshsession.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index ed697c7ce4..9671a0f98d 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -1013,10 +1013,7 @@ virNetLibsshSessionAuthAddPrivKeyAuth(virNetLibsshSe= ssionPtr sess, const char *keyfile, const char *password) { - int ret; virNetLibsshAuthMethodPtr auth; - VIR_AUTODISPOSE_STR pass =3D NULL; - char *file =3D NULL; if (!keyfile) { virReportError(VIR_ERR_LIBSSH, "%s", @@ -1026,28 +1023,18 @@ virNetLibsshSessionAuthAddPrivKeyAuth(virNetLibsshS= essionPtr sess, virObjectLock(sess); - file =3D g_strdup(keyfile); - pass =3D g_strdup(password); - if (!(auth =3D virNetLibsshSessionAuthMethodNew(sess))) { - ret =3D -1; - goto error; + virObjectUnlock(sess); + return -1; } - auth->password =3D g_steal_pointer(&pass); - auth->filename =3D file; + auth->password =3D g_strdup(password); + auth->filename =3D g_strdup(keyfile); auth->method =3D VIR_NET_LIBSSH_AUTH_PRIVKEY; auth->ssh_flags =3D SSH_AUTH_METHOD_PUBLICKEY; - ret =3D 0; - - cleanup: virObjectUnlock(sess); - return ret; - - error: - VIR_FREE(file); - goto cleanup; + return 0; } int --=20 2.29.2