Am 25.11.2015 um 09:18 hat Markus Armbruster geschrieben: > John Snow <js...@redhat.com> 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. Kevin