Skip to content

Commit beb470a

Browse files
author
The Android Automerger
committed
Revert "Merge "BatteryService(jni): properly handle read's return value" into ics-mr0"
This reverts commit f0ad147, reversing changes made to bd9b152.
1 parent 8e31988 commit beb470a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

services/jni/com_android_server_BatteryService.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ static int readFromFile(const char* path, char* buf, size_t size)
141141
return -1;
142142
}
143143

144-
ssize_t count = read(fd, buf, size);
144+
size_t count = read(fd, buf, size);
145145
if (count > 0) {
146-
while (count > 0 && buf[count-1] == '\n')
147-
count--;
146+
count = (count < size) ? count : size - 1;
147+
while (count > 0 && buf[count-1] == '\n') count--;
148148
buf[count] = '\0';
149149
} else {
150150
buf[0] = '\0';

0 commit comments

Comments
 (0)