OSDN Git Service

wifi: Skip adding interface prefix if exists
authorDmitry Shmidt <dimitrysh@google.com>
Thu, 6 Jun 2013 17:45:48 +0000 (10:45 -0700)
committerDmitry Shmidt <dimitrysh@google.com>
Thu, 6 Jun 2013 17:45:48 +0000 (10:45 -0700)
Bug: 9313188

Change-Id: I63784493c84ac4ffcc9810a7798b1c0de1b0f68b
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
wifi/wifi.c

index fca36f8..cbf8303 100644 (file)
@@ -860,12 +860,14 @@ int wifi_command(const char *ifname, char *command, size_t commandlen,
     size_t cmdlen = strlen(command) + 1;
     size_t iflen = strlen(ifname) + IFNAMELEN + 1;
 
-    if (commandlen >= cmdlen + iflen) {
-        memmove((&command[iflen]), command, cmdlen);
-        snprintf(command, iflen, "%s%s", IFNAME, ifname);
-        command[iflen - 1] = ' ';
-    } else {
-        ALOGE("CmdBuf is too small (%d) for %s", commandlen, command);
+    if (strncmp(command, IFNAME, IFNAMELEN) != 0) {
+        if (commandlen >= cmdlen + iflen) {
+            memmove((&command[iflen]), command, cmdlen);
+            snprintf(command, iflen, "%s%s", IFNAME, ifname);
+            command[iflen - 1] = ' ';
+        } else {
+            ALOGE("CmdBuf is too small (%d) for %s", commandlen, command);
+        }
     }
     if (is_primary_interface(ifname)) {
         return wifi_send_command(PRIMARY, command, reply, reply_len);