diff options
author | The Android Automerger <android-build@android.com> | 2011-11-02 04:41:24 -0700 |
---|---|---|
committer | The Android Automerger <android-build@android.com> | 2011-11-02 04:41:24 -0700 |
commit | 116d12b87f319767618e2c0827544412e7e3fd67 (patch) | |
tree | 754141e6c7b2e6d3cf1a95ca42cebc4f6c40735c | |
parent | 953005e8243e4dc898a00d9a1612ae82772913b9 (diff) | |
download | base-116d12b87f319767618e2c0827544412e7e3fd67.tar.gz |
Revert "Merge "BatteryService(jni): properly handle read's return value" into ics-mr0"
This reverts commit f0ad147fc33cf55cd9427010b2cdb3eb89b9eec3, reversing
changes made to bd9b1528051a1b257768fdbc5077a2d4473b02dd.
-rw-r--r-- | services/jni/com_android_server_BatteryService.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/services/jni/com_android_server_BatteryService.cpp b/services/jni/com_android_server_BatteryService.cpp index 2ceb5356e624..b9f2c1f182d1 100644 --- a/services/jni/com_android_server_BatteryService.cpp +++ b/services/jni/com_android_server_BatteryService.cpp @@ -141,10 +141,10 @@ static int readFromFile(const char* path, char* buf, size_t size) return -1; } - ssize_t count = read(fd, buf, size); + size_t count = read(fd, buf, size); if (count > 0) { - while (count > 0 && buf[count-1] == '\n') - count--; + count = (count < size) ? count : size - 1; + while (count > 0 && buf[count-1] == '\n') count--; buf[count] = '\0'; } else { buf[0] = '\0'; |