qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.ibm.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>,
	stefanb@linux.vnet.ibm.com
Cc: qemu-devel@nongnu.org, armbru@redhat.com, peterx@redhat.com
Subject: Re: [PATCH 3/3] tpm_emulator: tpm_emulator_set_state_blobs(): move to boolean return
Date: Fri, 7 Nov 2025 14:35:14 -0500	[thread overview]
Message-ID: <b4c55d4c-cd96-4a10-994c-65c7dac61dd2@linux.ibm.com> (raw)
In-Reply-To: <20251106194126.569037-4-vsementsov@yandex-team.ru>



On 11/6/25 2:41 PM, Vladimir Sementsov-Ogievskiy wrote:
> 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 <vsementsov@yandex-team.ru>
> ---
>   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 *tpm_emu,
>   
>   /*
>    * 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 = TPM_EMULATOR(tb);
>       TPMBlobBuffers *state_blobs = &tpm_emu->state_blobs;
> @@ -897,7 +895,7 @@ static int tpm_emulator_set_state_blobs(TPMBackend *tb, Error **errp)
>   
>       if (tpm_emulator_stop_tpm(tb, errp) < 0) {
>           trace_tpm_emulator_set_state_blobs_error("Could not stop TPM");
> -        return -EIO;
> +        return false;
>       }
>   
>       if (tpm_emulator_set_state_blob(tpm_emu, PTM_BLOB_TYPE_PERMANENT,
> @@ -909,12 +907,12 @@ static int tpm_emulator_set_state_blobs(TPMBackend *tb, 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;
>       }
>   
>       trace_tpm_emulator_set_state_blobs_done();
>   
> -    return 0;
> +    return true;
>   }
>   
>   static int tpm_emulator_pre_save(void *opaque)
> @@ -959,8 +957,7 @@ static bool tpm_emulator_post_load(void *opaque, int version_id, Error **errp)
>       TPMBackend *tb = opaque;
>       int ret;
>   
> -    ret = tpm_emulator_set_state_blobs(tb, errp);
> -    if (ret < 0) {
> +    if (!tpm_emulator_set_state_blobs(tb, errp)) {
>           return false;
>       }
>   

Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>



  reply	other threads:[~2025-11-07 19:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-06 19:41 [PATCH 0/3] follow-up for tpm_emulator errp story Vladimir Sementsov-Ogievskiy
2025-11-06 19:41 ` [PATCH 1/3] tpm_emulator: print error on error-ignore path Vladimir Sementsov-Ogievskiy
2025-11-07 19:27   ` Stefan Berger
2025-11-06 19:41 ` [PATCH 2/3] tpm_emulator: drop direct use of errno variable Vladimir Sementsov-Ogievskiy
2025-11-07 19:31   ` Stefan Berger
2025-11-07 19:53     ` Vladimir Sementsov-Ogievskiy
2025-11-08  9:35     ` Markus Armbruster
2025-11-10 14:51   ` Stefan Berger
2025-11-06 19:41 ` [PATCH 3/3] tpm_emulator: tpm_emulator_set_state_blobs(): move to boolean return Vladimir Sementsov-Ogievskiy
2025-11-07 19:35   ` Stefan Berger [this message]
2025-11-07  8:39 ` [PATCH 0/3] follow-up for tpm_emulator errp story Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b4c55d4c-cd96-4a10-994c-65c7dac61dd2@linux.ibm.com \
    --to=stefanb@linux.ibm.com \
    --cc=armbru@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanb@linux.vnet.ibm.com \
    --cc=vsementsov@yandex-team.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).