summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorDima Zavin <dima@android.com>2011-10-28 18:05:47 -0700
committerDima Zavin <dima@android.com>2011-10-28 23:15:11 -0700
commit98e044a6090fa239eca6736436d6a7efa8028066 (patch)
tree31e4a36d2e5833664aff8994bfcf37b0a2ee5f88 /services
parentfe9a2a5471616a3267b30013bce36b13a455c0cd (diff)
downloadframeworks_base-98e044a6090fa239eca6736436d6a7efa8028066.zip
frameworks_base-98e044a6090fa239eca6736436d6a7efa8028066.tar.gz
frameworks_base-98e044a6090fa239eca6736436d6a7efa8028066.tar.bz2
BatteryService(jni): properly handle read's return value
Change-Id: I10f5cf3728424e7f5a0c1b460049102fd00a6246 Signed-off-by: Dima Zavin <dima@android.com>
Diffstat (limited to 'services')
-rw-r--r--services/jni/com_android_server_BatteryService.cpp6
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 b9f2c1f..2ceb535 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';