summaryrefslogtreecommitdiff
path: root/server/TetherController.cpp
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2017-09-15 11:40:01 +0900
committerLorenzo Colitti <lorenzo@google.com>2017-09-15 11:47:03 +0900
commit38fd1360ae940079ab81c018565d95295bcd12bd (patch)
tree715eaacba71c439c35c65a095a76b07b42c1003b /server/TetherController.cpp
parent5e03a893d999d04b7329ab8825782d75872d680f (diff)
Don't complain when finding no tether stats.
TetherController::addForwardChainStats returns an error if it doesn't find any tethering stats. This was fine when we were still using CommandListener, which would not attempt to fetch the stats if tethering was not enabled. Instead of returning an error when no stats are found, return an error only if the output was empty (implying that no headers were found and thus the required rules do not exist). If the output contains headers but no stats, don't return an error. Returning an error was a necessity in the previous code because it had no unit or integration tests, but such measures are not necessary now that we have test coverage. Fix: 65550883 Bug: 65369386 Test: bullhead builds, boots Test: netd_{unit,integration}_test pass Change-Id: Ie32f4d941dd52c8dc9ff09fde26cc97cedf96bc3
Diffstat (limited to 'server/TetherController.cpp')
-rw-r--r--server/TetherController.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/server/TetherController.cpp b/server/TetherController.cpp
index 13cf1d89..baf477af 100644
--- a/server/TetherController.cpp
+++ b/server/TetherController.cpp
@@ -645,7 +645,6 @@ int TetherController::addForwardChainStats(TetherStatsList& statsList,
const TetherStats empty;
const char *buffPtr;
int64_t packets, bytes;
- int statsFound = 0;
std::stringstream stream(statsOutput);
@@ -702,13 +701,12 @@ int TetherController::addForwardChainStats(TetherStatsList& statsList,
if (stats.rxBytes != -1 && stats.txBytes != -1) {
ALOGV("rx_bytes=%" PRId64" tx_bytes=%" PRId64, stats.rxBytes, stats.txBytes);
addStats(statsList, stats);
- statsFound++;
stats = empty;
}
}
/* It is always an error to find only one side of the stats. */
- if (((stats.rxBytes == -1) != (stats.txBytes == -1)) || !statsFound) {
+ if (((stats.rxBytes == -1) != (stats.txBytes == -1))) {
return -EREMOTEIO;
}
return 0;