int count = 0;
n = sd_listen_fds(true);
- if (n < 0) {
- log_error_errno(n, "Failed to read listening file descriptors from environment: %m");
- return n;
- }
+ if (n < 0)
+ return log_error_errno(n, "Failed to read listening file descriptors from environment: %m");
if (n > 0) {
log_info("Received %i descriptors via the environment.", n);
int r;
r = sysview_session_take_control(session);
- if (r < 0) {
- log_error_errno(r, "Cannot request session control on '%s': %m",
- sysview_session_get_name(session));
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot request session control on '%s': %m",
+ sysview_session_get_name(session));
r = session_new(&s, m, session);
if (r < 0) {
m->running_as == SYSTEMD_SYSTEM ? "system" : "user",
m->running_as == SYSTEMD_SYSTEM, &p);
- if (m->kdbus_fd < 0) {
- log_debug_errno(m->kdbus_fd, "Failed to set up kdbus: %m");
- return m->kdbus_fd;
- }
+ if (m->kdbus_fd < 0)
+ return log_debug_errno(m->kdbus_fd, "Failed to set up kdbus: %m");
log_debug("Successfully set up kdbus on %s", p);
#endif
return log_oom();
r = get_writer(s, name, &writer);
- if (r < 0) {
- log_warning_errno(r, "Failed to get writer for source %s: %m",
- name);
- return r;
- }
+ if (r < 0)
+ return log_warning_errno(r, "Failed to get writer for source %s: %m",
+ name);
if (s->sources[fd] == NULL) {
s->sources[fd] = source_new(fd, false, name, writer);
return 0;
r = get_writer(server, hostname, &writer);
- if (r < 0) {
- log_warning_errno(r, "Failed to get writer for source %s: %m",
- hostname);
- return r;
- }
+ if (r < 0)
+ return log_warning_errno(r, "Failed to get writer for source %s: %m",
+ hostname);
source = source_new(fd, true, hostname, writer);
if (!source) {
return r;
n = sd_listen_fds(true);
- if (n < 0) {
- log_error_errno(n, "Failed to read listening file descriptors from environment: %m");
- return n;
- } else
+ if (n < 0)
+ return log_error_errno(n, "Failed to read listening file descriptors from environment: %m");
+ else
log_info("Received %d descriptors", n);
if (MAX(http_socket, https_socket) >= SD_LISTEN_FDS_START + n) {
int r;
r = read_full_file(arg_key ?: PRIV_KEY_FILE, key, NULL);
- if (r < 0) {
- log_error_errno(r, "Failed to read key from file '%s': %m",
- arg_key ?: PRIV_KEY_FILE);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to read key from file '%s': %m",
+ arg_key ?: PRIV_KEY_FILE);
r = read_full_file(arg_cert ?: CERT_FILE, cert, NULL);
- if (r < 0) {
- log_error_errno(r, "Failed to read certificate from file '%s': %m",
- arg_cert ?: CERT_FILE);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to read certificate from file '%s': %m",
+ arg_cert ?: CERT_FILE);
if (arg_trust_all)
log_info("Certificate checking disabled.");
else {
r = read_full_file(arg_trust ?: TRUST_FILE, trust, NULL);
- if (r < 0) {
- log_error_errno(r, "Failed to read CA certificate file '%s': %m",
- arg_trust ?: TRUST_FILE);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to read CA certificate file '%s': %m",
+ arg_trust ?: TRUST_FILE);
}
return 0;
u->current_cursor = NULL;
r = sd_journal_get_cursor(u->journal, &u->current_cursor);
- if (r < 0) {
- log_error_errno(r, "Failed to get cursor: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to get cursor: %m");
r = snprintf(buf + pos, size - pos,
"__CURSOR=%s\n", u->current_cursor);
usec_t realtime;
r = sd_journal_get_realtime_usec(u->journal, &realtime);
- if (r < 0) {
- log_error_errno(r, "Failed to get realtime timestamp: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to get realtime timestamp: %m");
r = snprintf(buf + pos, size - pos,
"__REALTIME_TIMESTAMP="USEC_FMT"\n", realtime);
sd_id128_t boot_id;
r = sd_journal_get_monotonic_usec(u->journal, &monotonic, &boot_id);
- if (r < 0) {
- log_error_errno(r, "Failed to get monotonic timestamp: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to get monotonic timestamp: %m");
r = snprintf(buf + pos, size - pos,
"__MONOTONIC_TIMESTAMP="USEC_FMT"\n", monotonic);
char sid[33];
r = sd_journal_get_monotonic_usec(u->journal, NULL, &boot_id);
- if (r < 0) {
- log_error_errno(r, "Failed to get monotonic timestamp: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to get monotonic timestamp: %m");
r = snprintf(buf + pos, size - pos,
"_BOOT_ID=%s\n", sd_id128_to_string(boot_id, sid));
r = sd_journal_enumerate_data(u->journal,
&u->field_data,
&u->field_length);
- if (r < 0) {
- log_error_errno(r, "Failed to move to next field in entry: %m");
- return r;
- } else if (r == 0) {
+ if (r < 0)
+ return log_error_errno(r, "Failed to move to next field in entry: %m");
+ else if (r == 0) {
u->entry_state = ENTRY_OUTRO;
continue;
}
int r;
r = sd_journal_next_skip(u->journal, skip);
- if (r < 0) {
- log_error_errno(r, "Failed to skip to next entry: %m");
- return r;
- } else if (r < skip)
+ if (r < 0)
+ return log_error_errno(r, "Failed to skip to next entry: %m");
+ else if (r < skip)
return 0;
/* have data */
if (follow) {
fd = sd_journal_get_fd(j);
- if (fd < 0) {
- log_error_errno(fd, "sd_journal_get_fd failed: %m");
- return fd;
- }
+ if (fd < 0)
+ return log_error_errno(fd, "sd_journal_get_fd failed: %m");
events = sd_journal_get_events(j);
r = sd_event_add_io(u->events, &u->input_event,
fd, events, dispatch_journal_input, u);
- if (r < 0) {
- log_error_errno(r, "Failed to register input event: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to register input event: %m");
log_debug("Listening for journal events on fd:%d, timeout %d",
fd, u->timeout == (uint64_t) -1 ? -1 : (int) u->timeout);
if (cursor) {
r = sd_journal_seek_cursor(j, cursor);
if (r < 0) {
- log_error_errno(r, "Failed to seek to cursor %s: %m",
- cursor);
- return r;
+ return log_error_errno(r, "Failed to seek to cursor %s: %m",
+ cursor);
}
}
return 0;
r = mkdir_parents(u->state_file, 0755);
- if (r < 0) {
- log_error_errno(r, "Cannot create parent directory of state file %s: %m",
- u->state_file);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot create parent directory of state file %s: %m",
+ u->state_file);
r = fopen_temporary(u->state_file, &f, &temp_path);
- if (r < 0) {
- log_error_errno(r, "Cannot save state to %s: %m",
- u->state_file);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot save state to %s: %m",
+ u->state_file);
unlink(temp_path);
return 0;
if (r == -ENOENT)
log_debug("State file %s is not present.", u->state_file);
- else if (r < 0) {
- log_error_errno(r, "Failed to read state file %s: %m",
- u->state_file);
- return r;
- } else
+ else if (r < 0)
+ return log_error_errno(r, "Failed to read state file %s: %m",
+ u->state_file);
+ else
log_debug("Last cursor was %s", u->last_cursor);
return 0;
r = sd_event_add_io(u->events, &u->input_event,
fd, EPOLLIN, dispatch_fd_input, u);
if (r < 0) {
- if (r != -EPERM || arg_follow > 0) {
- log_error_errno(r, "Failed to register input event: %m");
- return r;
- }
+ if (r != -EPERM || arg_follow > 0)
+ return log_error_errno(r, "Failed to register input event: %m");
/* Normal files should just be consumed without polling. */
r = start_upload(u, fd_input_callback, u);
u->state_file = state_file;
r = sd_event_default(&u->events);
- if (r < 0) {
- log_error_errno(r, "sd_event_default failed: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "sd_event_default failed: %m");
r = setup_signals(u);
- if (r < 0) {
- log_error_errno(r, "Failed to set up signals: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to set up signals: %m");
return load_cursor_state(u);
}
case ARG_FILE:
r = glob_extend(&arg_file, optarg);
- if (r < 0) {
- log_error_errno(r, "Failed to add paths: %m");
- return r;
- };
+ if (r < 0)
+ return log_error_errno(r, "Failed to add paths: %m");
break;
case ARG_CURSOR:
return log_oom();
r = mkdir_p(d, 0775);
- if (r < 0) {
- log_error_errno(r, "Recursive mkdir %s: %m", d);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Recursive mkdir %s: %m", d);
r = fopen_temporary(database, &w, &p);
- if (r < 0) {
- log_error_errno(r, "Failed to open database for writing: %s: %m",
- database);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to open database for writing: %s: %m",
+ database);
zero(header);
memcpy(header.signature, CATALOG_SIGNATURE, sizeof(header.signature));
/* TODO: add a fallback keymap that's compiled-in */
r = kbdmap_new_from_names(&km, kc, kc->last_x11_model, kc->last_x11_layout,
kc->last_x11_variant, kc->last_x11_options);
- if (r < 0) {
- log_debug_errno(r, "idev-keyboard: cannot create keymap from locale1: %m");
- return r;
- }
+ if (r < 0)
+ return log_debug_errno(r, "idev-keyboard: cannot create keymap from locale1: %m");
kbdmap_unref(kc->kbdmap);
kc->kbdmap = km;
return 0;
error:
- log_debug_errno(r, "idev-keyboard: %s/%s: cannot adopt new compose table: %m",
- d->session->name, d->name);
- return r;
+ return log_debug_errno(r, "idev-keyboard: %s/%s: cannot adopt new compose table: %m",
+ d->session->name, d->name);
}
static const idev_device_vtable keyboard_vtable = {
return 0;
r = device_new_ud(&device, seat, type, d);
- if (r < 0) {
- log_debug_errno(r, "sysview: cannot create device for udev-device '%s': %m",
- syspath);
- return r;
- }
+ if (r < 0)
+ return log_debug_errno(r, "sysview: cannot create device for udev-device '%s': %m",
+ syspath);
context_add_device(c, device);
}
int r;
r = sd_bus_message_read(signal, "so", &id, &path);
- if (r < 0) {
- log_debug_errno(r, "sysview: cannot parse SeatNew from logind: %m");
- return r;
- }
+ if (r < 0)
+ return log_debug_errno(r, "sysview: cannot parse SeatNew from logind: %m");
context_add_seat(c, id);
return 0;
int r;
r = sd_bus_message_read(signal, "so", &id, &path);
- if (r < 0) {
- log_debug_errno(r, "sysview: cannot parse SeatRemoved from logind: %m");
- return r;
- }
+ if (r < 0)
+ return log_debug_errno(r, "sysview: cannot parse SeatRemoved from logind: %m");
seat = sysview_find_seat(c, id);
if (!seat)
int r;
r = sd_bus_message_read(signal, "so", &id, &path);
- if (r < 0) {
- log_debug_errno(r, "sysview: cannot parse SessionNew from logind: %m");
- return r;
- }
+ if (r < 0)
+ return log_debug_errno(r, "sysview: cannot parse SessionNew from logind: %m");
/*
* As the dbus message didn't contain enough information, we
return 0;
error:
- log_debug_errno(r, "sysview: failed retrieving information for new session '%s': %m",
- id);
- return r;
+ return log_debug_errno(r, "sysview: failed retrieving information for new session '%s': %m",
+ id);
}
static int context_ld_session_removed(sysview_context *c, sd_bus_message *signal) {
int r;
r = sd_bus_message_read(signal, "so", &id, &path);
- if (r < 0) {
- log_debug_errno(r, "sysview: cannot parse SessionRemoved from logind: %m");
- return r;
- }
+ if (r < 0)
+ return log_debug_errno(r, "sysview: cannot parse SessionRemoved from logind: %m");
session = sysview_find_session(c, id);
if (!session)
return 0;
error:
- log_debug_errno(r, "sysview: erroneous ListSeats response from logind: %m");
- return r;
+ return log_debug_errno(r, "sysview: erroneous ListSeats response from logind: %m");
}
static int context_ld_list_sessions_fn(sd_bus *bus,
return 0;
error:
- log_debug_errno(r, "sysview: erroneous ListSessions response from logind: %m");
- return r;
+ return log_debug_errno(r, "sysview: erroneous ListSessions response from logind: %m");
}
static int context_ld_scan(sysview_context *c) {
if (!c->scanned) {
r = context_ld_scan(c);
- if (r < 0) {
- log_debug_errno(r, "sysview: logind scan failed: %m");
- return r;
- }
+ if (r < 0)
+ return log_debug_errno(r, "sysview: logind scan failed: %m");
}
/* skip device scans if no sessions are available */
if (hashmap_size(c->session_map) > 0) {
r = context_ud_scan(c);
- if (r < 0) {
- log_debug_errno(r, "sysview: udev scan failed: %m");
- return r;
- }
+ if (r < 0)
+ return log_debug_errno(r, "sysview: udev scan failed: %m");
HASHMAP_FOREACH(seat, c->seat_map, i)
seat->scanned = true;
r = sd_rtnl_message_new_addr(link->manager->rtnl, &req, RTM_DELADDR,
link->ifindex, address->family);
- if (r < 0) {
- log_error_errno(r, "Could not allocate RTM_DELADDR message: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not allocate RTM_DELADDR message: %m");
r = sd_rtnl_message_addr_set_prefixlen(req, address->prefixlen);
- if (r < 0) {
- log_error_errno(r, "Could not set prefixlen: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not set prefixlen: %m");
if (address->family == AF_INET)
r = sd_rtnl_message_append_in_addr(req, IFA_LOCAL, &address->in_addr.in);
else if (address->family == AF_INET6)
r = sd_rtnl_message_append_in6_addr(req, IFA_LOCAL, &address->in_addr.in6);
- if (r < 0) {
- log_error_errno(r, "Could not append IFA_LOCAL attribute: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not append IFA_LOCAL attribute: %m");
r = sd_rtnl_call_async(link->manager->rtnl, req, callback, link, 0, NULL);
- if (r < 0) {
- log_error_errno(r, "Could not send rtnetlink message: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not send rtnetlink message: %m");
link_ref(link);
r = sd_rtnl_message_new_addr_update(link->manager->rtnl, &req,
link->ifindex, address->family);
- if (r < 0) {
- log_error_errno(r, "Could not allocate RTM_NEWADDR message: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not allocate RTM_NEWADDR message: %m");
r = sd_rtnl_message_addr_set_prefixlen(req, address->prefixlen);
- if (r < 0) {
- log_error_errno(r, "Could not set prefixlen: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not set prefixlen: %m");
r = sd_rtnl_message_addr_set_flags(req, IFA_F_PERMANENT);
- if (r < 0) {
- log_error_errno(r, "Could not set flags: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not set flags: %m");
r = sd_rtnl_message_addr_set_scope(req, address->scope);
- if (r < 0) {
- log_error_errno(r, "Could not set scope: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not set scope: %m");
if (address->family == AF_INET)
r = sd_rtnl_message_append_in_addr(req, IFA_LOCAL, &address->in_addr.in);
else if (address->family == AF_INET6)
r = sd_rtnl_message_append_in6_addr(req, IFA_LOCAL, &address->in_addr.in6);
- if (r < 0) {
- log_error_errno(r, "Could not append IFA_LOCAL attribute: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not append IFA_LOCAL attribute: %m");
if (address->family == AF_INET) {
r = sd_rtnl_message_append_in_addr(req, IFA_BROADCAST, &address->broadcast);
- if (r < 0) {
- log_error_errno(r, "Could not append IFA_BROADCAST attribute: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not append IFA_BROADCAST attribute: %m");
}
if (address->label) {
r = sd_rtnl_message_append_string(req, IFA_LABEL, address->label);
- if (r < 0) {
- log_error_errno(r, "Could not append IFA_LABEL attribute: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not append IFA_LABEL attribute: %m");
}
r = sd_rtnl_message_append_cache_info(req, IFA_CACHEINFO, &address->cinfo);
- if (r < 0) {
- log_error_errno(r, "Could not append IFA_CACHEINFO attribute: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not append IFA_CACHEINFO attribute: %m");
r = sd_rtnl_call_async(link->manager->rtnl, req, callback, link, 0, NULL);
- if (r < 0) {
- log_error_errno(r, "Could not send rtnetlink message: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not send rtnetlink message: %m");
link_ref(link);
r = sd_rtnl_message_new_addr(link->manager->rtnl, &req, RTM_NEWADDR,
link->ifindex, address->family);
- if (r < 0) {
- log_error_errno(r, "Could not allocate RTM_NEWADDR message: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not allocate RTM_NEWADDR message: %m");
r = sd_rtnl_message_addr_set_prefixlen(req, address->prefixlen);
- if (r < 0) {
- log_error_errno(r, "Could not set prefixlen: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not set prefixlen: %m");
r = sd_rtnl_message_addr_set_flags(req, IFA_F_PERMANENT);
- if (r < 0) {
- log_error_errno(r, "Could not set flags: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not set flags: %m");
r = sd_rtnl_message_addr_set_scope(req, address->scope);
- if (r < 0) {
- log_error_errno(r, "Could not set scope: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not set scope: %m");
if (address->family == AF_INET)
r = sd_rtnl_message_append_in_addr(req, IFA_LOCAL, &address->in_addr.in);
else if (address->family == AF_INET6)
r = sd_rtnl_message_append_in6_addr(req, IFA_LOCAL, &address->in_addr.in6);
- if (r < 0) {
- log_error_errno(r, "Could not append IFA_LOCAL attribute: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not append IFA_LOCAL attribute: %m");
if (!in_addr_is_null(address->family, &address->in_addr_peer)) {
if (address->family == AF_INET)
r = sd_rtnl_message_append_in_addr(req, IFA_ADDRESS, &address->in_addr_peer.in);
else if (address->family == AF_INET6)
r = sd_rtnl_message_append_in6_addr(req, IFA_ADDRESS, &address->in_addr_peer.in6);
- if (r < 0) {
- log_error_errno(r, "Could not append IFA_ADDRESS attribute: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not append IFA_ADDRESS attribute: %m");
} else {
if (address->family == AF_INET) {
r = sd_rtnl_message_append_in_addr(req, IFA_BROADCAST, &address->broadcast);
- if (r < 0) {
- log_error_errno(r, "Could not append IFA_BROADCAST attribute: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not append IFA_BROADCAST attribute: %m");
}
}
if (address->label) {
r = sd_rtnl_message_append_string(req, IFA_LABEL, address->label);
- if (r < 0) {
- log_error_errno(r, "Could not append IFA_LABEL attribute: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not append IFA_LABEL attribute: %m");
}
r = sd_rtnl_message_append_cache_info(req, IFA_CACHEINFO,
&address->cinfo);
- if (r < 0) {
- log_error_errno(r, "Could not append IFA_CACHEINFO attribute: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not append IFA_CACHEINFO attribute: %m");
r = sd_rtnl_call_async(link->manager->rtnl, req, callback, link, 0, NULL);
- if (r < 0) {
- log_error_errno(r, "Could not send rtnetlink message: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not send rtnetlink message: %m");
link_ref(link);