From nobody Tue Sep 9 19:04:48 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1752754808; cv=none; d=zohomail.com; s=zohoarc; b=B8nww2BiTunNxFk5XD1l6blKfdIOGeuXQYuX4m16lCdq00GB5yXcvZcNVXXkbJVHwnhBVsJm+I8dZIp1ORTls4ikt7ftpJyJDkE0PsQJLyZN9mb+s5VEdRmdlP2IZ/ANc7M5G49GsaNQ3OOsQErJ3mvd7/m+ySjNWIhH+uylYRg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752754808; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=WCXqI6682X4XT5Z/08HV3FrB7l6gGfYk6cUVH3P0Nlw=; b=aX+qGB8y6dyi/LNWaIhyhWuZ86lActb2XPxbXhsCOOmq8ZtevZMZaTPz4tWjxk2WXOLLbXvqCME0bGJM+8RqRkOT3nJDHhyDXxdI9SbXuzsGTXJLXeN1UoiQ8XshkbuOvGwbZnBfTkOzMpN37ebGdS6v00mxVM4ZQ3ZX8SCTOao= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1752754808918716.1780369782514; Thu, 17 Jul 2025 05:20:08 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id EA07B1477; Thu, 17 Jul 2025 08:20:07 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5557614E3; Thu, 17 Jul 2025 08:19:10 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 8255011D4; Thu, 17 Jul 2025 08:19:03 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 0A5CD11BC for ; Thu, 17 Jul 2025 08:19:03 -0400 (EDT) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-64-UE8IkgoqNZyoo89bnDhmcg-1; Thu, 17 Jul 2025 08:19:01 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C0DF919560A2 for ; Thu, 17 Jul 2025 12:19:00 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.3.236]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 188DE19560A0 for ; Thu, 17 Jul 2025 12:18:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752754742; h=from:from: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; bh=CoOP0pwZSrBt/09tinZF15YWpShpwwabx0xKl2A6mPs=; b=cnyiDkw+mxkQibnr1zM47SRW3Czn6+51igJt+leBRsd6JjrFX283IvCqJ4gOJlTDYj2eHj 7XLdAZaQbUXgXITw2nFMpXqBsGhx7z85aXvBR0NdCMHy7/20J7A3G7MxCTpJnl3DdDu4F1 +E0t67zsZ/jQU/B54xrqDogGg00fZ08= X-MC-Unique: UE8IkgoqNZyoo89bnDhmcg-1 X-Mimecast-MFC-AGG-ID: UE8IkgoqNZyoo89bnDhmcg_1752754740 To: devel@lists.libvirt.org Subject: [PATCH 2/2] qemu_tpm: Don't report uninitialized variable in error message Date: Thu, 17 Jul 2025 14:18:55 +0200 Message-ID: <6f7e3f97eac3fe79cfff2da48d82dbc31bac5d96.1752754566.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: P1PP7Z081bIAVrJz6QrQKoDDE5-kcWKbVAVXnD5HMK0_1752754740 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: YBSAEGTLD7FZHR64WNGAZAO33XUSEF5T X-Message-ID-Hash: YBSAEGTLD7FZHR64WNGAZAO33XUSEF5T X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1752754811156116600 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik Inside to qemu_tpm.c there are three functions that use the same pattern (qemuTPMEmulatorRunSetup(), qemuTPMEmulatorReconfigure() and qemuTPMEmulatorUpdateProfileName()): int exitstatus; ... if (virCommandRun(cmd, &exitstatus) < 0 || exitstatus !=3D 0) { virReportError(..., exitstatus); return -1; } Problem with this pattern is that if virCommandRun() fails then exitstatus is left untouched and a garbage value is then passed to virReportError(). Signed-off-by: Michal Privoznik --- src/qemu/qemu_tpm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index b2f76e6b8b..5ff08fccad 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -439,7 +439,7 @@ qemuTPMEmulatorRunSetup(const virDomainTPMEmulatorDef *= emulator, bool incomingMigration) { g_autoptr(virCommand) cmd =3D NULL; - int exitstatus; + int exitstatus =3D -1; char uuid[VIR_UUID_STRING_BUFLEN]; g_autofree char *vmid =3D NULL; g_autofree char *swtpm_setup =3D virTPMGetSwtpmSetup(); @@ -547,7 +547,7 @@ qemuTPMEmulatorReconfigure(const virDomainTPMEmulatorDe= f *emulator, const unsigned char *secretuuid) { g_autoptr(virCommand) cmd =3D NULL; - int exitstatus; + int exitstatus =3D -1; g_autofree char *activePcrBanksStr =3D NULL; g_autofree char *swtpm_setup =3D virTPMGetSwtpmSetup(); g_autofree char *tpm_state =3D qemuTPMGetSwtpmSetupStateArg(emulator->= source_type, @@ -670,7 +670,7 @@ qemuTPMEmulatorUpdateProfileName(virDomainTPMEmulatorDe= f *emulator, g_autofree char *swtpm =3D NULL; virJSONValue *active_profile; const char *profile_name; - int exitstatus; + int exitstatus =3D -1; =20 if (emulator->version !=3D VIR_DOMAIN_TPM_VERSION_2_0 || !virTPMSwtpmCapsGet(VIR_TPM_SWTPM_FEATURE_CMDARG_PRINT_INFO)) --=20 2.49.1