> On May 18, 2024, at 8:57 AM, Zhenlei Huang <z...@freebsd.org> wrote:
>
>
>
>> On May 18, 2024, at 4:00 AM, Ed Maste <ema...@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 <pie...@freebsdfoundation.org>
>> AuthorDate: 2024-05-17 07:31:32 +0000
>> Commit: Ed Maste <ema...@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 ?
Unfortunately not. assert is defined as a macro as such
```
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
__LINE__, #e))
```
So `e` is enclosed with () and compiler can not catch that.
>
>>
>> free(ppi);
>> }
>
>
>