From eb5df470e6e0402006030b76315f06bcb4f17882 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Mon, 31 Jan 2011 14:23:56 +0100 Subject: [PATCH] adb: Fix command-line parser. This fixes the command-line parser to accept both "daemon server" and "server nodaemon". Before the patch, the second string would ignore the "nodaemon" flag. Fixes b/2191598 Change-Id: Ie922b3e7bf57a6e334fc448cec33fb340ca6abc4 --- adb/commandline.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/adb/commandline.c b/adb/commandline.c index 3600e5a0b..5ed1b522b 100644 --- a/adb/commandline.c +++ b/adb/commandline.c @@ -683,6 +683,7 @@ int adb_commandline(int argc, char **argv) char buf[4096]; int no_daemon = 0; int is_daemon = 0; + int is_server = 0; int persist = 0; int r; int quote; @@ -719,7 +720,9 @@ int adb_commandline(int argc, char **argv) /* modifiers and flags */ while(argc > 0) { - if(!strcmp(argv[0],"nodaemon")) { + if(!strcmp(argv[0],"server")) { + is_server = 1; + } else if(!strcmp(argv[0],"nodaemon")) { no_daemon = 1; } else if (!strcmp(argv[0], "fork-server")) { /* this is a special flag used only when the ADB client launches the ADB Server */ @@ -766,7 +769,7 @@ int adb_commandline(int argc, char **argv) adb_set_transport(ttype, serial); adb_set_tcp_specifics(server_port); - if ((argc > 0) && (!strcmp(argv[0],"server"))) { + if (is_server) { if (no_daemon || is_daemon) { r = adb_main(is_daemon, server_port); } else {