assert(conf);
if (validate_buffers(&enabled_buffers) < 0)
- return 1;
+ return -EINVAL;
struct fd_info **fdi_ptrs = calloc(bit_count(enabled_buffers) + 1 /* NULL terminator */, sizeof *fdi_ptrs);
if (!fdi_ptrs)
int epoll_cnt = 0;
__attribute__((cleanup(close_fd))) int epollfd = epoll_create1(0);
if (epollfd < 0) {
+ int ret = -errno;
DBG("epoll_create failed: %m");
- return -1;
+ return ret;
}
__attribute__ ((cleanup(sort_vector_free))) struct sort_vector logs;
clock_gettime(get_proper_clock(sort_by), &logs.start);
if (!sort_vector_finalize(&logs)) {
ERR("Error: unable to allocate memory\n");
- return -1;
+ return -ENOMEM;
}
for (int nfds = 0; nfds < fd_count; ++nfds) {
continue;
} else if (r < 0) {
ERR("Error while preparing for printing: %s", strerror(-r));
- return -1;
+ return r;
}
int fd = data_fds[nfds]->fd;
- if (fd_set_flags(fd, O_NONBLOCK) < 0)
- return -1;
+ r = fd_set_flags(fd, O_NONBLOCK);
+ if (r < 0)
+ return r;
struct epoll_event ev = {
.data.ptr = data_fds[nfds],
.events = EPOLLIN,
__attribute__((cleanup(free_ptr))) struct epoll_event *evs = calloc(epoll_cnt, sizeof *evs);
if (!evs) {
ERR("Error: no memory for epoll array");
- return -1;
+ return -ENOMEM;
}
while (epoll_cnt > 0) {
nfds = epoll_wait(epollfd, evs, epoll_cnt, 100);
while (nfds < 0 && errno == EINTR);
if (nfds < 0)
- return -1;
+ return -errno;
for (int i = 0; i < nfds; ++i) {
struct fd_info *fdi = evs[i].data.ptr;