+ while (1) {
+ if ((buffer_size == 0) || (buffer_fill >= buffer_size - 1)) {
+ if (buffer_size == 0)
+ buffer_size = 1024;
+ else
+ buffer_size *= 2;
+ if (buffer_size > HDDTEMP_MAX_RECV_BUF) {
+ WARNING("hddtemp plugin: Message from hddtemp has been "
+ "truncated.");
+ break;
+ }
+ new_buffer = realloc(buffer, buffer_size);
+ if (new_buffer == NULL) {
+ close(fd);
+ free(buffer);
+ ERROR("hddtemp plugin: Allocation failed.");
+ return NULL;
+ }
+ buffer = new_buffer;
+ }
+ status = read(fd, buffer + buffer_fill, buffer_size - buffer_fill - 1);
+ if (status == 0) {
+ break;
+ } else if (status == -1) {