qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PULL 18/20] hw/i386/pc: Unify vmport=auto handling


From: Richard Henderson
Subject: Re: [PULL 18/20] hw/i386/pc: Unify vmport=auto handling
Date: Wed, 21 Aug 2024 08:45:04 +1000
User-agent: Mozilla Thunderbird

On 8/21/24 06:32, Kamil Szczęk wrote:
Also, just as a test I added a single line of code before the assert:

pcms->vmport = -1;

And, to my surprise, it compiled successfully without any warning and as 
expected, aborted on the assert:

qemu-system-x86_64: ../hw/i386/pc.c:1225: pc_basic_device_init: Assertion 'pcms->vmport >= 0 
&& pcms->vmport < ON_OFF_AUTO__MAX' failed.

Is this expected behavior?

Yes.

The underlying integral type for enum in C is implementation defined.
It can and does vary between compilers, leading to this sort of thing.

The only reasonable fix is

  (unsigned)foo < max

But you could also question whether the assert is really useful.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]