From nobody Fri Nov 14 15:22:06 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1762458138; cv=none; d=zohomail.com; s=zohoarc; b=kfbl8aBlO7tQpnoFdQ4NNzrVDWoTmc7deh0SrVaRY+DNO+icAqdA5D15sJ/U9/oF/G9xn+D+9E9XKxeouYz8EGRd255DBsCXO+lj+BgNolm2LSrcNQ1dB8Tgax9zpFQVrQ+7PmMOzNk6kJ39InRjl5u2pd3V5j3RrUW4DMuZhjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762458138; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aIRM3K7hrDbUqO+by7P6KHpZ+7hD8y8j3fymeYTlzFA=; b=h/VnLSIt4ZojOV4iB0IMOxCZR3gRXJa3e7AvrMfuUESJNrb6CmTDDq2pCfORPUxcZBzujnznkssOi15NO/NXIzeay5wWGtAoja9yyFOQs6zx/lxqXPcQMBqOT/BilswrP02rwvqq3xpvyrNyiXDFcjf0erGLOemi+1vMdp2/HY4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762458137742563.0144848430415; Thu, 6 Nov 2025 11:42:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vH5rU-0003kM-Nw; Thu, 06 Nov 2025 14:41:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vH5rT-0003k4-NX for qemu-devel@nongnu.org; Thu, 06 Nov 2025 14:41:35 -0500 Received: from forwardcorp1d.mail.yandex.net ([2a02:6b8:c41:1300:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vH5rR-0005b0-6i for qemu-devel@nongnu.org; Thu, 06 Nov 2025 14:41:35 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:1a8f:0:640:2fa2:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 8B6CC80940; Thu, 06 Nov 2025 22:41:29 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:95c::1:2]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id RfspdL0FKeA0-DjWY94PE; Thu, 06 Nov 2025 22:41:29 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1762458089; bh=aIRM3K7hrDbUqO+by7P6KHpZ+7hD8y8j3fymeYTlzFA=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=1uAw1mO12CwllDuoCmhB+9yizzCgaXtys0uE5Y1AtFBVRhBiHkb+hhl6ZNZ6U7i05 1rav9Qk9HsglDrBQf4qvzdJQydV9TjqfkWw/mQUW0iFLbg1e52IbaHYwnGxjMF4jE6 3sz0J7kq4b1aEiUHUao3CwaN4pCLJYMgedLOSRso= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: stefanb@linux.vnet.ibm.com Cc: qemu-devel@nongnu.org, armbru@redhat.com, peterx@redhat.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH 1/3] tpm_emulator: print error on error-ignore path Date: Thu, 6 Nov 2025 22:41:24 +0300 Message-ID: <20251106194126.569037-2-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251106194126.569037-1-vsementsov@yandex-team.ru> References: <20251106194126.569037-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c41:1300:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1762458143042154100 Content-Type: text/plain; charset="utf-8" Commit 3469a56fa3dc985 introduced errp passthrough for many errors in the file. But in this specific case in tpm_emulator_get_buffer_size(), it simply used errp=3DNULL, so we lose printed error. Let's bring it back Note also, that 3469a56fa3dc985 was fixing another commit, 42e556fa3f7a "backends/tpm: Propagate vTPM error on migration failure" and didn't mention it. Fixes: 3469a56fa3dc985 "tmp_emulator: improve and fix use of errp" Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Markus Armbruster Reviewed-by: Stefan Berger --- backends/tpm/tpm_emulator.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c index f10b9074fb..24aa18302e 100644 --- a/backends/tpm/tpm_emulator.c +++ b/backends/tpm/tpm_emulator.c @@ -560,8 +560,10 @@ static TPMVersion tpm_emulator_get_tpm_version(TPMBack= end *tb) static size_t tpm_emulator_get_buffer_size(TPMBackend *tb) { size_t actual_size; + Error *local_err =3D NULL; =20 - if (tpm_emulator_set_buffer_size(tb, 0, &actual_size, NULL) < 0) { + if (tpm_emulator_set_buffer_size(tb, 0, &actual_size, &local_err) < 0)= { + error_report_err(local_err); return 4096; } =20 --=20 2.48.1 From nobody Fri Nov 14 15:22:06 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1762458140; cv=none; d=zohomail.com; s=zohoarc; b=SKy9uZINkcfPrvNjpqdkNwccUbvhFWITco1YES5n2ULcMcrUYYEip824s4ICyzm7TeHAvEWNVZAIS8NoVFLMqsWKGbaB91mS2Dll1mvPs4I7glRGP2Qhoa0MM0KaQt6bkyPrgPvJ1EbS9sRGI4JBlVysLP+7FX2CNeNMjmr3PnA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762458140; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=v6HP1T8GOduMM4bGIjnnBFiziHrer4bW5QVb1bfaNfc=; b=l4QP37B9vKJfjc1nZwnQMxXQngdwq4t55uq6zCHVG4XHuo3Esc9o0Sj3Z3PVeb7mJdXYYSgVjVCrTeVuw9mG+/yFBEVU5R78/9qVA4dayQuqUewoaq93nUfpWCRLm0NyNoodJj1jvusuyQXn314e12wAq9o+zOeBbG9DN4xdu2c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762458139995791.1869204931467; Thu, 6 Nov 2025 11:42:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vH5rW-0003lZ-C1; Thu, 06 Nov 2025 14:41:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vH5rV-0003kn-7g for qemu-devel@nongnu.org; Thu, 06 Nov 2025 14:41:37 -0500 Received: from forwardcorp1d.mail.yandex.net ([2a02:6b8:c41:1300:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vH5rR-0005bJ-6i for qemu-devel@nongnu.org; Thu, 06 Nov 2025 14:41:37 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:1a8f:0:640:2fa2:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 5018680E79; Thu, 06 Nov 2025 22:41:30 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:95c::1:2]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id RfspdL0FKeA0-FNyxTx50; Thu, 06 Nov 2025 22:41:29 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1762458089; bh=v6HP1T8GOduMM4bGIjnnBFiziHrer4bW5QVb1bfaNfc=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=Qz4uic5QLa5+yQ8hoDZzgT8Q3UtMfjtY8OD5Blv3TBCwn16kRWmuzHT1cl9Jzpzkn 43orewy9aBaiOIxaAe15ApuF6Up2xMgJ2yaG8NtjBht2/9CrmyJ6RVU7ScYZUW1jDQ 5b789q8rwyeMS7MRLI2Od0Hpd68h+8OF61VTcUzY= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: stefanb@linux.vnet.ibm.com Cc: qemu-devel@nongnu.org, armbru@redhat.com, peterx@redhat.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH 2/3] tpm_emulator: drop direct use of errno variable Date: Thu, 6 Nov 2025 22:41:25 +0300 Message-ID: <20251106194126.569037-3-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251106194126.569037-1-vsementsov@yandex-team.ru> References: <20251106194126.569037-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c41:1300:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1762458143133154100 Content-Type: text/plain; charset="utf-8" The code tends to include errno into error messages after tpm_util_test_tpmdev() and tpm_emulator_ctrlcmd() calls. Both has error paths, where errno is not set, examples: tpm_emulator_ctrlcmd() qemu_chr_fe_write_all() qemu_chr_write() replay_char_write_event_load() ... *res =3D replay_get_dword(); ... tpm_util_test_tpmdev() tpm_util_test() tpm_util_request() ... if (n !=3D requestlen) { return -EFAULT; } ... Both doesn't document that they set errno. Let's drop these explicit usage of errno. If we need this information, it should be added to errp deeper in the stack. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Markus Armbruster Reviewed-by: Stefan Berger --- backends/tpm/tpm_emulator.c | 44 ++++++++++++++----------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c index 24aa18302e..79f3e6b1f2 100644 --- a/backends/tpm/tpm_emulator.c +++ b/backends/tpm/tpm_emulator.c @@ -225,8 +225,7 @@ static int tpm_emulator_set_locality(TPMEmulator *tpm_e= mu, uint8_t locty_number, if (tpm_emulator_ctrlcmd(tpm_emu, CMD_SET_LOCALITY, &loc, sizeof(loc), sizeof(loc.u.resp.tpm_result), sizeof(loc)) < 0) { - error_setg(errp, "tpm-emulator: could not set locality : %s", - strerror(errno)); + error_setg(errp, "tpm-emulator: could not set locality"); return -1; } =20 @@ -264,7 +263,7 @@ static int tpm_emulator_probe_caps(TPMEmulator *tpm_emu) if (tpm_emulator_ctrlcmd(tpm_emu, CMD_GET_CAPABILITY, &cap_n, 0, sizeof(cap_n.u.resp.tpm_result), sizeof(cap_n)) < 0) { - error_report("tpm-emulator: probing failed : %s", strerror(errno)); + error_report("tpm-emulator: probing failed"); return -1; } =20 @@ -315,8 +314,7 @@ static int tpm_emulator_stop_tpm(TPMBackend *tb, Error = **errp) =20 if (tpm_emulator_ctrlcmd(tpm_emu, CMD_STOP, &res, 0, sizeof(ptm_res), sizeof(res)) < 0) { - error_setg(errp, "tpm-emulator: Could not stop TPM: %s", - strerror(errno)); + error_setg(errp, "tpm-emulator: Could not stop TPM"); return -1; } =20 @@ -344,8 +342,7 @@ static int tpm_emulator_lock_storage(TPMEmulator *tpm_e= mu) if (tpm_emulator_ctrlcmd(tpm_emu, CMD_LOCK_STORAGE, &pls, sizeof(pls.u= .req), sizeof(pls.u.resp.tpm_result), sizeof(pls.u.resp)) < 0) { - error_report("tpm-emulator: Could not lock storage within 3 second= s: " - "%s", strerror(errno)); + error_report("tpm-emulator: Could not lock storage within 3 second= s"); return -1; } =20 @@ -377,8 +374,7 @@ static int tpm_emulator_set_buffer_size(TPMBackend *tb, if (tpm_emulator_ctrlcmd(tpm_emu, CMD_SET_BUFFERSIZE, &psbs, sizeof(psbs.u.req), sizeof(psbs.u.resp.tpm_re= sult), sizeof(psbs.u.resp)) < 0) { - error_setg(errp, "tpm-emulator: Could not set buffer size: %s", - strerror(errno)); + error_setg(errp, "tpm-emulator: Could not set buffer size"); return -1; } =20 @@ -426,8 +422,7 @@ static int tpm_emulator_startup_tpm_resume(TPMBackend *= tb, size_t buffersize, if (tpm_emulator_ctrlcmd(tpm_emu, CMD_INIT, &init, sizeof(init), sizeof(init.u.resp.tpm_result), sizeof(init)) < 0) { - error_setg(errp, "tpm-emulator: could not send INIT: %s", - strerror(errno)); + error_setg(errp, "tpm-emulator: could not send INIT"); goto err_exit; } =20 @@ -482,8 +477,7 @@ static bool tpm_emulator_get_tpm_established_flag(TPMBa= ckend *tb) if (tpm_emulator_ctrlcmd(tpm_emu, CMD_GET_TPMESTABLISHED, &est, 0, sizeof(est) /* always returns resp.bit */, sizeof(est)) < 0) { - error_report("tpm-emulator: Could not get the TPM established flag= : %s", - strerror(errno)); + error_report("tpm-emulator: Could not get the TPM established flag= "); return false; } trace_tpm_emulator_get_tpm_established_flag(est.u.resp.bit); @@ -511,8 +505,7 @@ static int tpm_emulator_reset_tpm_established_flag(TPMB= ackend *tb, &reset_est, sizeof(reset_est), sizeof(reset_est.u.resp.tpm_result), sizeof(reset_est)) < 0) { - error_report("tpm-emulator: Could not reset the establishment bit:= %s", - strerror(errno)); + error_report("tpm-emulator: Could not reset the establishment bit"= ); return -1; } =20 @@ -542,8 +535,7 @@ static void tpm_emulator_cancel_cmd(TPMBackend *tb) /* FIXME: make the function non-blocking, or it may block a VCPU */ if (tpm_emulator_ctrlcmd(tpm_emu, CMD_CANCEL_TPM_CMD, &res, 0, sizeof(ptm_res), sizeof(res)) < 0) { - error_report("tpm-emulator: Could not cancel command: %s", - strerror(errno)); + error_report("tpm-emulator: Could not cancel command: %s"); } else if (res !=3D 0) { error_report("tpm-emulator: Failed to cancel TPM: 0x%x", be32_to_cpu(res)); @@ -604,8 +596,7 @@ static int tpm_emulator_prepare_data_fd(TPMEmulator *tp= m_emu) =20 if (tpm_emulator_ctrlcmd(tpm_emu, CMD_SET_DATAFD, &res, 0, sizeof(ptm_res), sizeof(res)) < 0 || res !=3D= 0) { - error_report("tpm-emulator: Failed to send CMD_SET_DATAFD: %s", - strerror(errno)); + error_report("tpm-emulator: Failed to send CMD_SET_DATAFD"); goto err_exit; } =20 @@ -662,8 +653,8 @@ static int tpm_emulator_handle_device_opts(TPMEmulator = *tpm_emu, QemuOpts *opts) */ if (tpm_util_test_tpmdev(QIO_CHANNEL_SOCKET(tpm_emu->data_ioc)->fd, &tpm_emu->tpm_version)) { - error_report("'%s' is not emulating TPM device. Error: %s", - tpm_emu->options->chardev, strerror(errno)); + error_report("'%s' is not emulating TPM device.", + tpm_emu->options->chardev); goto err; } =20 @@ -753,8 +744,7 @@ static int tpm_emulator_get_state_blob(TPMEmulator *tpm= _emu, /* always returns up to resp.data */ offsetof(ptm_getstate, u.resp.data), offsetof(ptm_getstate, u.resp.data)) < 0) { - error_report("tpm-emulator: could not get state blob type %d : %s", - type, strerror(errno)); + error_report("tpm-emulator: could not get state blob type %d", typ= e); return -1; } =20 @@ -856,9 +846,8 @@ static int tpm_emulator_set_state_blob(TPMEmulator *tpm= _emu, /* write the header only */ if (tpm_emulator_ctrlcmd(tpm_emu, CMD_SET_STATEBLOB, &pss, offsetof(ptm_setstate, u.req.data), 0, 0) < 0= ) { - error_setg_errno(errp, errno, - "tpm-emulator: could not set state blob type %d", - type); + error_setg(errp, "tpm-emulator: could not set state blob type %d", + type); return -1; } =20 @@ -1040,8 +1029,7 @@ static void tpm_emulator_shutdown(TPMEmulator *tpm_em= u) =20 if (tpm_emulator_ctrlcmd(tpm_emu, CMD_SHUTDOWN, &res, 0, sizeof(ptm_res), sizeof(res)) < 0) { - error_report("tpm-emulator: Could not cleanly shutdown the TPM: %s= ", - strerror(errno)); + error_report("tpm-emulator: Could not cleanly shutdown the TPM"); } else if (res !=3D 0) { error_report("tpm-emulator: TPM result for shutdown: 0x%x %s", be32_to_cpu(res), tpm_emulator_strerror(be32_to_cpu(r= es))); --=20 2.48.1 From nobody Fri Nov 14 15:22:06 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1762458152; cv=none; d=zohomail.com; s=zohoarc; b=GxSCk4ZXjjAh2sasBZtXH0rlvMdGZ/kg+QknSulYvSfDQUQz73hLXK3WvKfkUmfCbRUNed1GFXfv6NZrN4dhnKgfdMQhqzIuScvtsJkEf7PfSsnwL4lkjVKGqw/EPxgiCuRmGEJ/dzvsPA9OsSa3MoD3YbL4g4HNVYAM5GBDXhU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762458152; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WRSWwJjugz5gbC1LAoiahIUfa+K65oR/zZ3p/rr4nL4=; b=cGopohwN9vbMWIPGsk6ybXdQ8Fq6V/KUvCfejFBoTrrVRpqU6npursm9PuXovNYDdqUzVlA0Vxju7nCY7zdOQty121q3hDWW1NW4UgDPXdKDocLD607Qvw69DNx73sP9Q5pw1tcyhdo9vFVT7F8BHHWljBgt+hCt2A5VjDnE8yc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762458151622789.6095049421706; Thu, 6 Nov 2025 11:42:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vH5rX-0003m5-N7; Thu, 06 Nov 2025 14:41:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vH5rU-0003kS-TR for qemu-devel@nongnu.org; Thu, 06 Nov 2025 14:41:36 -0500 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vH5rR-0005bL-6j for qemu-devel@nongnu.org; Thu, 06 Nov 2025 14:41:36 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:1a8f:0:640:2fa2:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id D2505C01A6; Thu, 06 Nov 2025 22:41:30 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:95c::1:2]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id RfspdL0FKeA0-qSZWJnck; Thu, 06 Nov 2025 22:41:30 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1762458090; bh=WRSWwJjugz5gbC1LAoiahIUfa+K65oR/zZ3p/rr4nL4=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=A3lP6SK7TQgyiB95kDepnCkg7DujRsEaorW2Bg3uDudRuy4XVQWS4lk9gEaZ47ilL kVRE5y300moLl8Ab3tVFddUEMXnLFpe5kYdmqXUtNnO4HpfPRHEN1TMYSYtZdfKXTA 5fuT4LR+jYXlz6grLE2HtsAAC5VeExoakVYKwGcM= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: stefanb@linux.vnet.ibm.com Cc: qemu-devel@nongnu.org, armbru@redhat.com, peterx@redhat.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH 3/3] tpm_emulator: tpm_emulator_set_state_blobs(): move to boolean return Date: Thu, 6 Nov 2025 22:41:26 +0300 Message-ID: <20251106194126.569037-4-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251106194126.569037-1-vsementsov@yandex-team.ru> References: <20251106194126.569037-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1762458155853158500 Content-Type: text/plain; charset="utf-8" The returned error is only used to check for success, so no reason to use specific errno values. Also, this is the only function with -errno contract in the file, so converting it simplifies the whole file from three types of contract (0/-1, 0/-errno, true/false) to only two (0/-1, true/false). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Markus Armbruster Reviewed-by: Stefan Berger --- backends/tpm/tpm_emulator.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c index 79f3e6b1f2..3c62bfa3ed 100644 --- a/backends/tpm/tpm_emulator.c +++ b/backends/tpm/tpm_emulator.c @@ -885,10 +885,8 @@ static int tpm_emulator_set_state_blob(TPMEmulator *tp= m_emu, =20 /* * Set all the TPM state blobs. - * - * Returns a negative errno code in case of error. */ -static int tpm_emulator_set_state_blobs(TPMBackend *tb, Error **errp) +static bool tpm_emulator_set_state_blobs(TPMBackend *tb, Error **errp) { TPMEmulator *tpm_emu =3D TPM_EMULATOR(tb); TPMBlobBuffers *state_blobs =3D &tpm_emu->state_blobs; @@ -897,7 +895,7 @@ static int tpm_emulator_set_state_blobs(TPMBackend *tb,= Error **errp) =20 if (tpm_emulator_stop_tpm(tb, errp) < 0) { trace_tpm_emulator_set_state_blobs_error("Could not stop TPM"); - return -EIO; + return false; } =20 if (tpm_emulator_set_state_blob(tpm_emu, PTM_BLOB_TYPE_PERMANENT, @@ -909,12 +907,12 @@ static int tpm_emulator_set_state_blobs(TPMBackend *t= b, Error **errp) tpm_emulator_set_state_blob(tpm_emu, PTM_BLOB_TYPE_SAVESTATE, &state_blobs->savestate, state_blobs->savestate_flags, errp) < = 0) { - return -EIO; + return false; } =20 trace_tpm_emulator_set_state_blobs_done(); =20 - return 0; + return true; } =20 static int tpm_emulator_pre_save(void *opaque) @@ -959,8 +957,7 @@ static bool tpm_emulator_post_load(void *opaque, int ve= rsion_id, Error **errp) TPMBackend *tb =3D opaque; int ret; =20 - ret =3D tpm_emulator_set_state_blobs(tb, errp); - if (ret < 0) { + if (!tpm_emulator_set_state_blobs(tb, errp)) { return false; } =20 --=20 2.48.1