Re: git: f7d45c5443ed - main - bhyve: avoid side effect in assertion

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Sat, 18 May 2024 00:57:08 UTC

> On May 18, 2024, at 4:00 AM, Ed Maste <emaste@freebsd.org> wrote:
> 
> The branch main has been updated by emaste:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=f7d45c5443edc99857fdda19c68301b5ec4a8971
> 
> commit f7d45c5443edc99857fdda19c68301b5ec4a8971
> Author:     Pierre Pronchery <pierre@freebsdfoundation.org>
> AuthorDate: 2024-05-17 07:31:32 +0000
> Commit:     Ed Maste <emaste@FreeBSD.org>
> CommitDate: 2024-05-17 19:45:18 +0000
> 
>    bhyve: avoid side effect in assertion
> 
>    An assert() was setting the error variable instead of checking it.
> 
>    Reported by:    Coverity Scan
>    CID:            1521431
>    Reviewed by:    jhb
>    Sponsored by:   The FreeBSD Foundation
>    Pull Request:   https://github.com/freebsd/freebsd-src/pull/1244
> ---
> usr.sbin/bhyve/tpm_ppi_qemu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/usr.sbin/bhyve/tpm_ppi_qemu.c b/usr.sbin/bhyve/tpm_ppi_qemu.c
> index ad66ecb09683..239d39184589 100644
> --- a/usr.sbin/bhyve/tpm_ppi_qemu.c
> +++ b/usr.sbin/bhyve/tpm_ppi_qemu.c
> @@ -161,7 +161,7 @@ tpm_ppi_deinit(void *sc)
> 	ppi = sc;
> 
> 	error = unregister_mem(&ppi_mmio);
> -	assert(error = 0);
> +	assert(error == 0);

Emm, does that not get caught by compilers ?

> 
> 	free(ppi);
> }