}
}
- if (action == ACTION_PRINT)
- return do_print(fdi_ptrs, fdi_cnt, logfile_callback, &(struct logfile_callback_data) {
+ if (action == ACTION_PRINT) {
+ int r = do_print(fdi_ptrs, fdi_cnt, logfile_callback, &(struct logfile_callback_data) {
.file = &l_file,
.sort_by = proper_sort_by,
- }, sorting_needed, proper_sort_by, &conf, &opt) == 0 ? 0 : 1;
+ }, sorting_needed, proper_sort_by, &conf, &opt);
+ if (r < 0) {
+ ERR("Error while printing logs: %s\n", strerror(-r));
+ return r;
+ }
+ }
return 0;
}
assert(fd >= 0);
int ret = ioctl(fd, ioctl_id);
- if (ret < 0) {
- int saved_errno = errno;
- DBG("Android Logger ioctl %d failed %s\n", ioctl_id, strerror(saved_errno));
- return -saved_errno;
- }
+ if (ret < 0)
+ return -errno;
return ret;
}
assert(ppd);
assert(ppd->sock_fd >= 0);
- int r = send_dlog_request(ppd->sock_fd, DLOG_REQ_CLEAR, NULL, 0);
- if (r < 0)
- ERR("Error: could not send a CLEAR request to logger %s\n", strerror(-r));
-
- return r;
+ return send_dlog_request(ppd->sock_fd, DLOG_REQ_CLEAR, NULL, 0);
}
/**
len += needed;
}
- int r = send_dlog_request(sock_fd, DLOG_REQ_HANDLE_LOGUTIL, request_string, len);
- if (r < 0)
- ERR("Error: could not send a logger request; socket write failed\n");
-
- return r;
+ return send_dlog_request(sock_fd, DLOG_REQ_HANDLE_LOGUTIL, request_string, len);
}
/**
snprintf(conf_key, sizeof(conf_key), "%s_ctl_sock", name);
const char *sock_path = log_config_get(conf, conf_key);
- if (!sock_path) {
- ERR("Error: no config entry for %s!\n", conf_key);
+ if (!sock_path)
return -ENOENT;
- }
int sock_fd = connect_sock(sock_path);
- if (sock_fd < 0) {
- ERR("Error: Could not connect to socket %s %s!\n", sock_path, strerror(-sock_fd));
+ if (sock_fd < 0)
return sock_fd;
- }
struct pipe_priv_data *ppd = malloc(sizeof *ppd);
if (!ppd) {
- ERR("Error: not enough memory\n");
close(sock_fd);
return -ENOMEM;
}
*/
char* log_buffer_get_tag(const struct logger_entry *entry)
{
- if (entry->len - (int) sizeof(struct logger_entry) < 2) {
- fprintf(stderr, "Entry too small\n");
+ if (entry->len - (int) sizeof(struct logger_entry) < 2)
return NULL;
- }
return (char*)entry->msg;
}
*/
char* log_buffer_get_message(const struct logger_entry *entry)
{
- if (entry->len - (int) sizeof(struct logger_entry) < 2) {
- fprintf(stderr, "Entry too small\n");
+ if (entry->len - (int) sizeof(struct logger_entry) < 2)
return NULL;
- }
return (char*)entry->msg + entry->tag_len + 1 /* NULL delimiter */;
}
int validate_buffers(int *enabled_buffers)
{
if (*enabled_buffers & (1 << LOG_ID_KMSG)
- && *enabled_buffers & ~(1 << LOG_ID_KMSG)) {
- ERR("Error: mixing KMSG and other buffers is not allowed\n");
+ && *enabled_buffers & ~(1 << LOG_ID_KMSG))
return -EINVAL;
- }
if (!*enabled_buffers)
*enabled_buffers = default_buffers;
int r = fdi->ops->create(fdi, conf, bufname, &used_paths);
if (r < 0) {
- if (r == -EINVAL)
- ERR("Error: buffer \"%s\" is not supported (disabled in configuration)\n", bufname);
- else if (r != -EALREADY)
- ERR("Error: unable to access buffer \"%s\"\n", bufname);
+ // TODO: Inform about that again somewhere else
fdi_free(fdi);
continue;
}
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 ret;
- }
+ if (epollfd < 0)
+ return -errno;
__attribute__ ((cleanup(sort_vector_free))) struct sort_vector logs;
sort_vector_init(&logs);
logs.size = sorting_needed ? opt->logs_size : 0;
logs.sort_by = sort_by;
clock_gettime(get_proper_clock(sort_by), &logs.start);
- if (!sort_vector_finalize(&logs)) {
- ERR("Error: unable to allocate memory\n");
+ if (!sort_vector_finalize(&logs))
return -ENOMEM;
- }
for (int nfds = 0; nfds < fd_count; ++nfds) {
int r = data_fds[nfds]->ops->prepare_print(data_fds[nfds], logs.dump, opt->filter_list, opt->filter_object);
+ if (r < 0)
+ return r;
if (r > 0) {
// everything went fine, but we're not printing this one
fdi_free(data_fds[nfds]);
data_fds[nfds] = NULL;
continue;
- } else if (r < 0) {
- ERR("Error while preparing for printing: %s", strerror(-r));
- return r;
}
int fd = data_fds[nfds]->fd;
r = fd_set_flags(fd, O_NONBLOCK);
}
__attribute__((cleanup(free_ptr))) struct epoll_event *evs = calloc(epoll_cnt, sizeof *evs);
- if (!evs) {
- ERR("Error: no memory for epoll array");
+ if (!evs)
return -ENOMEM;
- }
while (epoll_cnt > 0) {
int nfds;