Fix build of adb with gcc-4.9.
Without this patch we get:
system/core/adb/commandline.c:1629:16: error: array subscript is above
array bounds [-Werror=array-bounds]
Change-Id: I494eb8b4d0e8082f8ff57bdd33d8d46c8c481c6f
Signed-off-by: Alexander Ivchenko <alexander.ivchenko@intel.com>
diff --git a/adb/commandline.c b/adb/commandline.c
index 1ba6049..cb5e75d 100644
--- a/adb/commandline.c
+++ b/adb/commandline.c
@@ -1607,9 +1607,10 @@
return 1;
}
+#define MAX_ARGV_LENGTH 16
static int do_cmd(transport_type ttype, char* serial, char *cmd, ...)
{
- char *argv[16];
+ char *argv[MAX_ARGV_LENGTH];
int argc;
va_list ap;
@@ -1626,7 +1627,9 @@
}
argv[argc++] = cmd;
- while((argv[argc] = va_arg(ap, char*)) != 0) argc++;
+ while(argc < MAX_ARGV_LENGTH &&
+ (argv[argc] = va_arg(ap, char*)) != 0) argc++;
+ assert(argc < MAX_ARGV_LENGTH);
va_end(ap);
#if 0