OSDN Git Service

BandwidthController: correctly handle the iptables command exit code
authorJP Abgrall <jpa@google.com>
Thu, 14 Feb 2013 00:30:00 +0000 (16:30 -0800)
committerJP Abgrall <jpa@google.com>
Thu, 14 Feb 2013 00:30:00 +0000 (16:30 -0800)
The return code from android_fork_execvp() needed to be massaged because
a status ptr was passed in.

Bug: 8185095
Change-Id: I205884f09b563dd729423a74f22fd5b8c2d59c64

BandwidthController.cpp

index 8f3a738..e4171d6 100644 (file)
@@ -198,11 +198,10 @@ int BandwidthController::runIptablesCmd(const char *cmd, IptRejectOp rejectHandl
     argv[argc] = NULL;
     res = android_fork_execvp(argc, (char **)argv, &status, false,
             failureHandling == IptFailShow);
-
-    if ((res || !WIFEXITED(status) || WEXITSTATUS(status)) &&
-            failureHandling == IptFailShow) {
-        ALOGE("runIptablesCmd(): failed %s res=%d status=%d", fullCmd.c_str(),
-                res, status);
+    res = res || !WIFEXITED(status) || WEXITSTATUS(status);
+    if (res && failureHandling == IptFailShow) {
+      ALOGE("runIptablesCmd(): res=%d status=%d failed %s", res, status,
+            fullCmd.c_str());
     }
     return res;
 }