From 1c236ba5319d6141964fddb38f1d942cebcaed05 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 24 Aug 2017 10:46:06 +0200 Subject: qapi: Avoid unnecessary use of enum lookup table's sentinel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Message-Id: <1503564371-26090-12-git-send-email-armbru@redhat.com> Reviewed-by: Marc-André Lureau --- ui/input-legacy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/input-legacy.c b/ui/input-legacy.c index 7159747404..a5f1e829c3 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -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; -- cgit v1.2.3