diff options
author | Dima Zavin <dima@android.com> | 2011-11-01 15:29:42 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-11-01 15:29:42 -0700 |
commit | f0ad147fc33cf55cd9427010b2cdb3eb89b9eec3 (patch) | |
tree | ffd79ddb820b298e29598a2eb8ca70c3daf22f64 | |
parent | bd9b1528051a1b257768fdbc5077a2d4473b02dd (diff) | |
parent | 98e044a6090fa239eca6736436d6a7efa8028066 (diff) | |
download | base-f0ad147fc33cf55cd9427010b2cdb3eb89b9eec3.tar.gz |
Merge "BatteryService(jni): properly handle read's return value" into ics-mr0
-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 b9f2c1f182d1..2ceb5356e624 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; } - size_t count = read(fd, buf, size); + ssize_t count = read(fd, buf, size); if (count > 0) { - count = (count < size) ? count : size - 1; - while (count > 0 && buf[count-1] == '\n') count--; + while (count > 0 && buf[count-1] == '\n') + count--; buf[count] = '\0'; } else { buf[0] = '\0'; |