[Top][All Lists]

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

Re: [Qemu-trivial] [Qemu-devel] [trivial for-2.6] util/id: fully allocat

From: Kevin Wolf
Subject: Re: [Qemu-trivial] [Qemu-devel] [trivial for-2.6] util/id: fully allocate names table
Date: Wed, 25 Nov 2015 10:41:40 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Am 25.11.2015 um 09:18 hat Markus Armbruster geschrieben:
> John Snow <address@hidden> writes:
> > Trivial: this array should be allocated to have ID_MAX entries always.
> > Otherwise if someone were to forget to expand this table, the assertion
> > in the id generator won't actually trigger; it will read junk data.
> You mean this one:
>     assert(id < ID_MAX);
> The assertion is crap, because it fails to protect array access
> id_subsys_str[id].  Here's one that does:
>     assert(0 <= id && id < ARRAY_SIZE(id_subsys_str));

Or without the kraxelism id >= 0. However, depending on whether enums
are signed or unsigned, I seem to remember that this could trigger
compiler warnings (comparison is always true). And this one should be
unsigned with gcc because it doesn't include negative values.


reply via email to

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