[PATCH] tools/btmgmt: Fix end of array checks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



all_cmd arrays is not terminated by zeroed element.
---
 tools/btmgmt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 15425fb..75f64c2 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -3406,9 +3406,9 @@ static char **cmd_completion(const char *text, int start, int end)
 	char **matches = NULL;
 
 	if (start > 0) {
-		int i;
+		unsigned int i;
 
-		for (i = 0; all_cmd[i].cmd; i++) {
+		for (i = 0; i < NELEM(all_cmd); i++) {
 			struct cmd_info *c = &all_cmd[i];
 
 			if (strncmp(c->cmd, rl_line_buffer, start - 1))
@@ -3519,7 +3519,7 @@ done:
 
 static void usage(void)
 {
-	int i;
+	unsigned int i;
 
 	printf("btmgmt ver %s\n", VERSION);
 	printf("Usage:\n"
@@ -3531,7 +3531,7 @@ static void usage(void)
 		"\t--help\tDisplay help\n");
 
 	printf("Commands:\n");
-	for (i = 0; all_cmd[i].cmd; i++)
+	for (i = 0; i < NELEM(all_cmd); i++)
 		printf("\t%-15s\t%s\n", all_cmd[i].cmd, all_cmd[i].doc);
 
 	printf("\n"
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux