diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 0686ed6..15425fb 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
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) {
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);