- rc = read(fd, buf, len - 1);
- if (rc < 0) {
- llapi_error(LLAPI_MSG_ERROR, -errno,
- "read('%s') failed: %s\n", proc_path);
- rc = -3;
- } else if (rc == 0) {
- llapi_err_noerrno(LLAPI_MSG_ERROR,
- "read('%s') zero bytes\n", proc_path);
- rc = -4;
- } else if (/* rc > 0 && */ buf[rc - 1] == '\n') {
- buf[rc - 1] = '\0'; /* Remove trailing newline */
- }
- close(fd);
+ rc = read(fd, buf, len - 1);
+ if (rc < 0) {
+ llapi_error(LLAPI_MSG_ERROR, -errno,
+ "error reading from '%s'", proc_path);
+ rc = -3;
+ } else if (rc == 0) {
+ llapi_err_noerrno(LLAPI_MSG_ERROR,
+ "read zero bytes from '%s'", proc_path);
+ rc = -4;
+ } else if (buf[rc - 1] == '\n') {
+ buf[rc - 1] = '\0'; /* Remove trailing newline */
+ }