From nobody Sun Feb 8 22:54:00 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=1669801709; cv=none; d=zohomail.com; s=zohoarc; b=cYz5zB7WPUcn+wcl4ZZzlSQx9tlBT4gUpyjMsAg1VN4XdFOdcSMNbNJqQJErI1UF43dGUxRxeC5z9bbxUQ3RlG5yluUpWPt+tISHx8oTa+Ead612riPM+97TVwQmKRAirmqfYydm58+smqNzzS9jFWbQSmu193gTHOjghINKz3Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669801709; 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=ftsd3DV/PBgZx386dcZuEd+MZAy9kJ4MiBhfmEKMpsM=; b=cr9Mlh1+G8txvBfopppEqxD1T9xAUTz8+7Q+AZaB4QHSgalDo3nIJKryFkpaBYL6m30kL7vBv58V52XVZwWC/ZGDbTn0rVtyBDS7B0ixqr9YkRAdoJ3W1qxBB/UwU657sEu4B9tOW0robeAsa2tuyIkGSH+NtqcBy9vs2YDWdvg= 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 1669801709197746.6169743427728; Wed, 30 Nov 2022 01:48:29 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-472-853G6YN4PbiwZ4DyPCsRuw-1; Wed, 30 Nov 2022 04:48:24 -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 891991C008AB; Wed, 30 Nov 2022 09:48:22 +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 74EBC2166B2D; Wed, 30 Nov 2022 09:48:22 +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 6541219465A8; Wed, 30 Nov 2022 09:48:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9A5C019465A0 for ; Wed, 30 Nov 2022 09:48:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8E7CE4B3FCE; Wed, 30 Nov 2022 09:48:15 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3249A4B3FDF for ; Wed, 30 Nov 2022 09:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669801707; 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=ftsd3DV/PBgZx386dcZuEd+MZAy9kJ4MiBhfmEKMpsM=; b=AiVezKYfl08rAOyFCpA0Ek3ARH+QFDCNBqN4AsdQqmOVDSZ3ilt551RjKKPz1EELg2J9TE 0EEDdavyCYiObZUmb6dHMTtR0pqiuKIcTu6kJk7KG4kAVBOPQy+SZqvs6wKT9EC2qml/dQ WBgI2f8C6vJUEf862oxQBPK3p8RjiZQ= X-MC-Unique: 853G6YN4PbiwZ4DyPCsRuw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/9] virCommandSetSendBuffer: Take double pointer of @buffer Date: Wed, 30 Nov 2022 10:48:06 +0100 Message-Id: <06993770963a937e0f15e7232bb3f39363847ad7.1669801586.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: 1669801710797100004 Content-Type: text/plain; charset="utf-8"; x-default="true" The virCommandSetSendBuffer() function consumes passed @buffer, but takes it only as plain pointer. Switch to a double pointer to make this obvious. This allows us then to drop all g_steal_pointer() in callers. Signed-off-by: Michal Privoznik --- src/qemu/qemu_tpm.c | 2 +- src/util/vircommand.c | 6 +++--- src/util/vircommand.h | 2 +- tests/commandtest.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index bdce060db8..d2f5bfb055 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -265,7 +265,7 @@ qemuTPMSetupEncryption(const unsigned char *secretuuid, &secret, &secret_len) < 0) return -1; =20 - *fd =3D virCommandSetSendBuffer(cmd, g_steal_pointer(&secret), secret_= len); + *fd =3D virCommandSetSendBuffer(cmd, &secret, secret_len); return 0; } =20 diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 4f60432c0a..0917bc9cfb 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -1699,10 +1699,10 @@ virCommandFreeSendBuffers(virCommand *cmd) */ int virCommandSetSendBuffer(virCommand *cmd, - unsigned char *buffer, + unsigned char **buffer, size_t buflen) { - g_autofree unsigned char *localbuf =3D g_steal_pointer(&buffer); + g_autofree unsigned char *localbuf =3D g_steal_pointer(buffer); int pipefd[2] =3D { -1, -1 }; size_t i; =20 @@ -2901,7 +2901,7 @@ int virCommandHandshakeNotify(virCommand *cmd) #else /* WIN32 */ int virCommandSetSendBuffer(virCommand *cmd, - unsigned char *buffer G_GNUC_UNUSED, + unsigned char **buffer G_GNUC_UNUSED, size_t buflen G_GNUC_UNUSED) { if (virCommandHasError(cmd)) diff --git a/src/util/vircommand.h b/src/util/vircommand.h index 98788bcbf7..e0002103b6 100644 --- a/src/util/vircommand.h +++ b/src/util/vircommand.h @@ -132,7 +132,7 @@ void virCommandSetWorkingDirectory(virCommand *cmd, const char *pwd) ATTRIBUTE_NONNULL(2); =20 int virCommandSetSendBuffer(virCommand *cmd, - unsigned char *buffer, + unsigned char **buffer, size_t buflen) ATTRIBUTE_NONNULL(2); =20 diff --git a/tests/commandtest.c b/tests/commandtest.c index 9bbf6fb260..8c5a9245a1 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -1075,8 +1075,8 @@ static int test27(const void *unused G_GNUC_UNUSED) errexpect =3D g_strdup_printf(TEST27_ERREXPECT_TEMP, buffer0, buffer1, buffer2); =20 - buf1fd =3D virCommandSetSendBuffer(cmd, g_steal_pointer(&buffer1), buf= len - 1); - buf2fd =3D virCommandSetSendBuffer(cmd, g_steal_pointer(&buffer2), buf= len - 1); + buf1fd =3D virCommandSetSendBuffer(cmd, &buffer1, buflen - 1); + buf2fd =3D virCommandSetSendBuffer(cmd, &buffer2, buflen - 1); =20 virCommandAddArg(cmd, "--readfd"); virCommandAddArgFormat(cmd, "%d", buf1fd); --=20 2.37.4