mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
qapi: Avoid unnecessary use of enum lookup table's sentinel
Currently, the FOO_lookup[] generated for QAPI enum types are terminated by a NULL sentinel. A future patch will generate enums with "holes". NULL-termination will cease to work then. To prepare for that, replace "have we reached the sentinel?" predicates by "have we reached the FOO__MAX value?" predicates. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1503564371-26090-12-git-send-email-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
113e47ae6d
commit
1c236ba531
4 changed files with 5 additions and 5 deletions
|
@ -61,7 +61,7 @@ int index_from_key(const char *key, size_t key_length)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; QKeyCode_lookup[i] != NULL; i++) {
|
||||
for (i = 0; i < Q_KEY_CODE__MAX; i++) {
|
||||
if (!strncmp(key, QKeyCode_lookup[i], key_length) &&
|
||||
!QKeyCode_lookup[i][key_length]) {
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue