Luiz Capitulino <lcapitul...@redhat.com> writes: > On Thu, 04 Aug 2011 11:02:06 +0200 > Markus Armbruster <arm...@redhat.com> wrote: > >> Luiz Capitulino <lcapitul...@redhat.com> writes: >> >> > Currently, only vm_start() and vm_stop() change the VM state. That's, >> > the state is only changed when starting or stopping the VM. >> > >> > This commit adds the qemu_state_set() function, making it possible >> > to also do state transitions when qemu is stopped or running. >> > >> > Additional states are also added and the current state is stored. >> > This is going to be used by the next commits. [...] >> > diff --git a/vl.c b/vl.c >> > index faa7c5f..2619c8e 100644 >> > --- a/vl.c >> > +++ b/vl.c >> > @@ -320,6 +320,22 @@ static int default_driver_check(QemuOpts *opts, void >> > *opaque) >> > } >> > >> > /***********************************************************/ >> > +/* QEMU state */ >> > + >> > +static QemuState qemu_current_state = QSTATE_NOSTATE; >> > + >> > +QemuState qemu_state_get(void) >> > +{ >> > + return qemu_current_state; >> > +} >> > + >> > +void qemu_state_set(QemuState state) >> > +{ >> > + assert(state < QSTATE_MAX); >> >> Beware, comparison is signed if QemuState is signed (implementation >> defined; QSTATE_MAX is int). > > It's unsigned here and I got the expected warning when I did: > > assert(state >= 0); > > Don't how to address that (besides dropping the check).
It's not likely to catch anthing the compiler doesn't. If you want to check, and want to check thoroughly, then I'm afraid you need to cast state. >> > + qemu_current_state = state; >> > +} >> > + >> > +/***********************************************************/ >> [...]