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 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 --- monitor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'monitor.c') diff --git a/monitor.c b/monitor.c index 135ec2de8f..86438f4b75 100644 --- a/monitor.c +++ b/monitor.c @@ -3249,7 +3249,7 @@ void netdev_add_completion(ReadLineState *rs, int nb_args, const char *str) } len = strlen(str); readline_set_completion_index(rs, len); - for (i = 0; NetClientDriver_lookup[i]; i++) { + for (i = 0; i < NET_CLIENT_DRIVER__MAX; i++) { add_completion_option(rs, str, NetClientDriver_lookup[i]); } } @@ -3537,7 +3537,7 @@ void watchdog_action_completion(ReadLineState *rs, int nb_args, const char *str) return; } readline_set_completion_index(rs, strlen(str)); - for (i = 0; WatchdogExpirationAction_lookup[i]; i++) { + for (i = 0; i < WATCHDOG_EXPIRATION_ACTION__MAX; i++) { add_completion_option(rs, str, WatchdogExpirationAction_lookup[i]); } } -- cgit v1.2.3-55-g7522