From ab103f9f29de2658f7917770a5c2afd876e2a8db Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 12 Feb 2015 21:59:35 +0200 Subject: [PATCH] tools/btmgmt: Fix end of array checks in cmd_generator() --- tools/btmgmt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/btmgmt.c b/tools/btmgmt.c index 0686ed656..15425fb02 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -3375,7 +3375,7 @@ static struct cmd_info interactive_cmd[] = { static char *cmd_generator(const char *text, int state) { - static int i, j, len; + static size_t i, j, len; const char *cmd; if (!state) { @@ -3384,15 +3384,15 @@ static char *cmd_generator(const char *text, int state) len = strlen(text); } - while ((cmd = all_cmd[i].cmd)) { - i++; + while (i < NELEM(all_cmd)) { + cmd = all_cmd[i++].cmd; if (!strncmp(cmd, text, len)) return strdup(cmd); } - while ((cmd = interactive_cmd[j].cmd)) { - j++; + while (j++ < NELEM(interactive_cmd)) { + cmd = interactive_cmd[j++].cmd; if (!strncmp(cmd, text, len)) return strdup(cmd); -- 2.47.3