From nobody Mon Feb 9 07:43:54 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=1673972459; cv=none; d=zohomail.com; s=zohoarc; b=bkgKF+se54Skmm+DSf5tQXo++Mu9Zv9REqMU/zhvbTHtJNUSkuNEoYuSxM6G1MBC49bizSjRLQBP8Lw82lif1f6SLuZzKfvpv2xoJCor/f+pnRoJytWs6K60UvHrfRdjpF/mM7GTgQEk+YNeg0wDXbwrzswyljuUZuTP3CI4XwQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673972459; 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=QYI8/6DNccXmxB43UCj6fEyzi/f2olkSZJiN6Qk/Veg=; b=ZLELFMnXapmAW+yZYPG1xSyyC9PTWqEezMmttAan9m6i8eEgsIRvmUehTYCtKKjcL/UMazigYFM8fiRd70f7Ko0074IQ3FNxqXGoyN9bcc/BZXpwubqOBMNeskI+51qWaNk3+7JuUiQzVPMK3zh1Qb0J1PBCr0CBOR4PgmXq/2I= 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 1673972459226796.6656854309864; Tue, 17 Jan 2023 08:20:59 -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-164-yFAxQLj2MPm-rHo8a58DSA-1; Tue, 17 Jan 2023 11:20:53 -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 52684857D0D; Tue, 17 Jan 2023 16:20:51 +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 3EC3440444C3; Tue, 17 Jan 2023 16:20:51 +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 3023219465A4; Tue, 17 Jan 2023 16:20:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9BA9E19465A3 for ; Tue, 17 Jan 2023 16:20:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 729881121315; Tue, 17 Jan 2023 16:20:48 +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 E196B1121318 for ; Tue, 17 Jan 2023 16:20:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673972457; 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=QYI8/6DNccXmxB43UCj6fEyzi/f2olkSZJiN6Qk/Veg=; b=iCqiTx9s+H3jfogxbQNMUkONZIDOlv4HmuvzNslH4sGV7Cnr4Qczu96P38WxPzHaU+Zmt6 oruL8B1LxNanDkJxUEd/n9PjCchHAw1DXeqqoEiQMcpiOXhOKLJZM1HdT4VKDOzeYkX9Oz lMbeho+3Qj91iE8ui1l+9nKGB1HgDk8= X-MC-Unique: yFAxQLj2MPm-rHo8a58DSA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/15] virNetSSHSessionAuthAddPrivKeyAuth: Refactor cleanup Date: Tue, 17 Jan 2023 17:20:31 +0100 Message-Id: <871dc585965374237c8534b5769697767849d202.1673972406.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1673972460588100003 Content-Type: text/plain; charset="utf-8" With g_strdup not failing we can remove all of the 'error' section. Signed-off-by: Peter Krempa --- src/rpc/virnetsshsession.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c index 08f246be61..9f2aa17131 100644 --- a/src/rpc/virnetsshsession.c +++ b/src/rpc/virnetsshsession.c @@ -1060,9 +1060,6 @@ virNetSSHSessionAuthAddPrivKeyAuth(virNetSSHSession *= sess, { virNetSSHAuthMethod *auth; - char *user =3D NULL; - char *file =3D NULL; - if (!username || !keyfile) { virReportError(VIR_ERR_SSH, "%s", _("Username and key file path must be provided " @@ -1072,24 +1069,15 @@ virNetSSHSessionAuthAddPrivKeyAuth(virNetSSHSession= *sess, virObjectLock(sess); - user =3D g_strdup(username); - file =3D g_strdup(keyfile); - if (!(auth =3D virNetSSHSessionAuthMethodNew(sess))) - goto error; + return -1; - auth->username =3D user; - auth->filename =3D file; + auth->username =3D g_strdup(username); + auth->filename =3D g_strdup(keyfile); auth->method =3D VIR_NET_SSH_AUTH_PRIVKEY; virObjectUnlock(sess); return 0; - - error: - VIR_FREE(user); - VIR_FREE(file); - virObjectUnlock(sess); - return -1; } int --=20 2.38.1