am f0ad147f: Merge "BatteryService(jni): properly handle read\'s return value" into ics-mr0

* commit 'f0ad147fc33cf55cd9427010b2cdb3eb89b9eec3':
  BatteryService(jni): properly handle read's return value
This commit is contained in:
Dima Zavin
2011-11-01 22:32:06 +00:00
committed by Android Git Automerger

View File

@@ -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';