diff options
40 files changed, 232 insertions, 278 deletions
diff --git a/src/activate/activate.c b/src/activate/activate.c index 70f86bb1e9..874b883617 100644 --- a/src/activate/activate.c +++ b/src/activate/activate.c @@ -66,8 +66,7 @@ static int open_sockets(int *epoll_fd, bool accept) { n = sd_listen_fds(true); if (n < 0) { - log_error("Failed to read listening file descriptors from environment: %s", - strerror(-n)); + log_error_errno(n, "Failed to read listening file descriptors from environment: %m"); return n; } if (n > 0) { diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c index 2f1b3b2f9c..218dc0d8cd 100644 --- a/src/backlight/backlight.c +++ b/src/backlight/backlight.c @@ -285,8 +285,7 @@ int main(int argc, char *argv[]) { r = mkdir_p("/var/lib/systemd/backlight", 0755); if (r < 0) { - log_error("Failed to create backlight directory /var/lib/systemd/backlight: %s", - strerror(-r)); + log_error_errno(r, "Failed to create backlight directory /var/lib/systemd/backlight: %m"); return EXIT_FAILURE; } @@ -395,8 +394,7 @@ int main(int argc, char *argv[]) { r = udev_device_set_sysattr_value(device, "brightness", value); if (r < 0) { - log_error("Failed to write system 'brightness' attribute: %s", - strerror(-r)); + log_error_errno(r, "Failed to write system 'brightness' attribute: %m"); return EXIT_FAILURE; } diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c index f025c76fb6..35c15ab12e 100644 --- a/src/bootchart/bootchart.c +++ b/src/bootchart/bootchart.c @@ -194,8 +194,8 @@ static int parse_argv(int argc, char *argv[]) { case 'f': r = safe_atod(optarg, &arg_hz); if (r < 0) - log_warning("failed to parse --freq/-f argument '%s': %s", - optarg, strerror(-r)); + log_warning_errno(r, "failed to parse --freq/-f argument '%s': %m", + optarg); break; case 'F': arg_filter = false; @@ -209,8 +209,8 @@ static int parse_argv(int argc, char *argv[]) { case 'n': r = safe_atoi(optarg, &arg_samples_len); if (r < 0) - log_warning("failed to parse --samples/-n argument '%s': %s", - optarg, strerror(-r)); + log_warning_errno(r, "failed to parse --samples/-n argument '%s': %m", + optarg); break; case 'o': path_kill_slashes(optarg); @@ -226,14 +226,14 @@ static int parse_argv(int argc, char *argv[]) { case 'x': r = safe_atod(optarg, &arg_scale_x); if (r < 0) - log_warning("failed to parse --scale-x/-x argument '%s': %s", - optarg, strerror(-r)); + log_warning_errno(r, "failed to parse --scale-x/-x argument '%s': %m", + optarg); break; case 'y': r = safe_atod(optarg, &arg_scale_y); if (r < 0) - log_warning("failed to parse --scale-y/-y argument '%s': %s", - optarg, strerror(-r)); + log_warning_errno(r, "failed to parse --scale-y/-y argument '%s': %m", + optarg); break; case 'e': arg_entropy = true; diff --git a/src/cgls/cgls.c b/src/cgls/cgls.c index 71921c4a80..27420f4f96 100644 --- a/src/cgls/cgls.c +++ b/src/cgls/cgls.c @@ -246,8 +246,8 @@ int main(int argc, char *argv[]) { } else r = cg_get_root_path(&root); if (r < 0) { - log_error("Failed to get %s path: %s", - arg_machine ? "machine" : "root", strerror(-r)); + log_error_errno(r, "Failed to get %s path: %m", + arg_machine ? "machine" : "root"); goto finish; } diff --git a/src/console/consoled-manager.c b/src/console/consoled-manager.c index 1b856f2228..0eac7ae78a 100644 --- a/src/console/consoled-manager.c +++ b/src/console/consoled-manager.c @@ -142,15 +142,15 @@ static int manager_sysview_session_add(Manager *m, sysview_event *event) { r = sysview_session_take_control(session); if (r < 0) { - log_error("Cannot request session control on '%s': %s", - sysview_session_get_name(session), strerror(-r)); + log_error_errno(r, "Cannot request session control on '%s': %m", + sysview_session_get_name(session)); return r; } r = session_new(&s, m, session); if (r < 0) { - log_error("Cannot create session on '%s': %s", - sysview_session_get_name(session), strerror(-r)); + log_error_errno(r, "Cannot create session on '%s': %m", + sysview_session_get_name(session)); sysview_session_release_control(session); return r; } @@ -226,8 +226,8 @@ static int manager_sysview_session_control(Manager *m, sysview_event *event) { return 0; if (error < 0) { - log_error("Cannot take session control on '%s': %s", - sysview_session_get_name(session), strerror(-error)); + log_error_errno(error, "Cannot take session control on '%s': %m", + sysview_session_get_name(session)); session_free(s); sysview_session_set_userdata(session, NULL); return -error; diff --git a/src/console/consoled-session.c b/src/console/consoled-session.c index c81bb306b7..927965e02c 100644 --- a/src/console/consoled-session.c +++ b/src/console/consoled-session.c @@ -106,8 +106,8 @@ static void session_grdev_fn(grdev_session *grdev, void *userdata, grdev_event * r = display_new(&d, s, display); if (r < 0) { - log_error("Cannot create display '%s' on '%s': %s", - grdev_display_get_name(display), sysview_session_get_name(s->sysview), strerror(-r)); + log_error_errno(r, "Cannot create display '%s' on '%s': %m", + grdev_display_get_name(display), sysview_session_get_name(s->sysview)); break; } diff --git a/src/console/consoled-terminal.c b/src/console/consoled-terminal.c index 166a43b5b1..755f23ece2 100644 --- a/src/console/consoled-terminal.c +++ b/src/console/consoled-terminal.c @@ -189,8 +189,7 @@ static void terminal_feed_keyboard(Terminal *t, idev_data *data) { kdata->codepoints, kdata->mods); if (r < 0) - log_error("Cannot feed keyboard data to screen: %s", - strerror(-r)); + log_error_errno(r, "Cannot feed keyboard data to screen: %m"); } } diff --git a/src/core/loopback-setup.c b/src/core/loopback-setup.c index 6ac1fffd75..ca8ac4ea61 100644 --- a/src/core/loopback-setup.c +++ b/src/core/loopback-setup.c @@ -93,13 +93,11 @@ int loopback_setup(void) { r = start_loopback(rtnl); if (r == -EPERM) { if (check_loopback() < 0) { - log_warning("Failed to configure loopback device: %s", - strerror(EPERM)); + log_warning_errno(EPERM, "Failed to configure loopback device: %m"); return -EPERM; } } else if (r < 0) { - log_warning("Failed to configure loopback device: %s", - strerror(-r)); + log_warning_errno(r, "Failed to configure loopback device: %m"); return r; } diff --git a/src/core/main.c b/src/core/main.c index c204758d43..6224a7ae6b 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1695,7 +1695,7 @@ int main(int argc, char *argv[]) { if (r < 0) log_error("Failed to load default target: %s", bus_error_message(&error, r)); else if (target->load_state == UNIT_ERROR || target->load_state == UNIT_NOT_FOUND) - log_error("Failed to load default target: %s", strerror(-target->load_error)); + log_error_errno(target->load_error, "Failed to load default target: %m"); else if (target->load_state == UNIT_MASKED) log_error("Default target masked."); @@ -1708,7 +1708,7 @@ int main(int argc, char *argv[]) { error_message = "Failed to load rescue target"; goto finish; } else if (target->load_state == UNIT_ERROR || target->load_state == UNIT_NOT_FOUND) { - log_emergency("Failed to load rescue target: %s", strerror(-target->load_error)); + log_emergency_errno(target->load_error, "Failed to load rescue target: %m"); error_message = "Failed to load rescue target"; goto finish; } else if (target->load_state == UNIT_MASKED) { diff --git a/src/core/manager.c b/src/core/manager.c index ef58bdd161..c56c1621b0 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -238,7 +238,7 @@ static int manager_dispatch_ask_password_fd(sd_event_source *source, if (m->have_ask_password < 0) /* Log error but continue. Negative have_ask_password * is treated as unknown status. */ - log_error("Failed to list /run/systemd/ask-password: %s", strerror(m->have_ask_password)); + log_error_errno(m->have_ask_password, "Failed to list /run/systemd/ask-password: %m"); return 0; } @@ -730,7 +730,7 @@ static int manager_setup_kdbus(Manager *m) { m->running_as == SYSTEMD_SYSTEM, &p); if (m->kdbus_fd < 0) { - log_debug("Failed to set up kdbus: %s", strerror(-m->kdbus_fd)); + log_debug_errno(m->kdbus_fd, "Failed to set up kdbus: %m"); return m->kdbus_fd; } @@ -2699,8 +2699,7 @@ static int create_generator_dir(Manager *m, char **generator, const char *name) r = mkdir_p_label(p, 0755); if (r < 0) { - log_error("Failed to create generator directory %s: %s", - p, strerror(-r)); + log_error_errno(r, "Failed to create generator directory %s: %m", p); free(p); return r; } @@ -2716,8 +2715,7 @@ static int create_generator_dir(Manager *m, char **generator, const char *name) r = mkdir_p_label(p, 0755); if (r < 0) { - log_error("Failed to create generator directory %s: %s", - p, strerror(-r)); + log_error_errno(r, "Failed to create generator directory %s: %m", p); free(p); return r; } diff --git a/src/core/path.c b/src/core/path.c index ca586d9616..202cba5d31 100644 --- a/src/core/path.c +++ b/src/core/path.c @@ -562,8 +562,7 @@ static void path_enter_waiting(Path *p, bool initial, bool recheck) { return; fail: - log_warning("%s failed to enter waiting state: %s", - UNIT(p)->id, strerror(-r)); + log_warning_errno(r, "%s failed to enter waiting state: %m", UNIT(p)->id); path_enter_dead(p, PATH_FAILURE_RESOURCES); } diff --git a/src/initctl/initctl.c b/src/initctl/initctl.c index 242ad3eca0..a0745af716 100644 --- a/src/initctl/initctl.c +++ b/src/initctl/initctl.c @@ -290,8 +290,7 @@ static int server_init(Server *s, unsigned n_sockets) { r = sd_is_fifo(fd, NULL); if (r < 0) { - log_error("Failed to determine file descriptor type: %s", - strerror(-r)); + log_error_errno(r, "Failed to determine file descriptor type: %m"); goto fail; } diff --git a/src/journal-remote/journal-remote-parse.c b/src/journal-remote/journal-remote-parse.c index 7dd8878ca6..47ff368e6c 100644 --- a/src/journal-remote/journal-remote-parse.c +++ b/src/journal-remote/journal-remote-parse.c @@ -451,8 +451,8 @@ int process_source(RemoteSource *source, bool compress, bool seal) { r = writer_write(source->writer, &source->iovw, &source->ts, compress, seal); if (r < 0) - log_error("Failed to write entry of %zu bytes: %s", - iovw_size(&source->iovw), strerror(-r)); + log_error_errno(r, "Failed to write entry of %zu bytes: %m", + iovw_size(&source->iovw)); else r = 1; diff --git a/src/journal-remote/journal-remote-write.c b/src/journal-remote/journal-remote-write.c index bfb6a7dcb8..df30049397 100644 --- a/src/journal-remote/journal-remote-write.c +++ b/src/journal-remote/journal-remote-write.c @@ -59,11 +59,9 @@ static int do_rotate(JournalFile **f, bool compress, bool seal) { int r = journal_file_rotate(f, compress, seal); if (r < 0) { if (*f) - log_error("Failed to rotate %s: %s", (*f)->path, - strerror(-r)); + log_error_errno(r, "Failed to rotate %s: %m", (*f)->path); else - log_error("Failed to create rotated journal: %s", - strerror(-r)); + log_error_errno(r, "Failed to create rotated journal: %m"); } return r; diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c index 89a680dcb7..d1df83fba0 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -210,8 +210,8 @@ static int open_output(Writer *w, const char* host) { w->mmap, NULL, &w->journal); if (r < 0) - log_error("Failed to open output journal %s: %s", - output, strerror(-r)); + log_error_errno(r, "Failed to open output journal %s: %m", + output); else log_info("Opened output file %s", w->journal->path); return r; @@ -321,8 +321,8 @@ static int get_source_for_fd(RemoteServer *s, r = get_writer(s, name, &writer); if (r < 0) { - log_warning("Failed to get writer for source %s: %s", - name, strerror(-r)); + log_warning_errno(r, "Failed to get writer for source %s: %m", + name); return r; } @@ -376,8 +376,8 @@ static int add_source(RemoteServer *s, int fd, char* name, bool own_name) { r = get_source_for_fd(s, fd, name, &source); if (r < 0) { - log_error("Failed to create source for fd:%d (%s): %s", - fd, name, strerror(-r)); + log_error_errno(r, "Failed to create source for fd:%d (%s): %m", + fd, name); free(name); return r; } @@ -393,8 +393,8 @@ static int add_source(RemoteServer *s, int fd, char* name, bool own_name) { sd_event_source_set_enabled(source->event, SD_EVENT_ON); } if (r < 0) { - log_error("Failed to register event source for fd:%d: %s", - fd, strerror(-r)); + log_error_errno(r, "Failed to register event source for fd:%d: %m", + fd); goto error; } @@ -460,8 +460,8 @@ static int request_meta(void **connection_cls, int fd, char *hostname) { r = get_writer(server, hostname, &writer); if (r < 0) { - log_warning("Failed to get writer for source %s: %s", - hostname, strerror(-r)); + log_warning_errno(r, "Failed to get writer for source %s: %m", + hostname); return r; } @@ -856,8 +856,7 @@ static int remoteserver_init(RemoteServer *s, n = sd_listen_fds(true); if (n < 0) { - log_error("Failed to read listening file descriptors from environment: %s", - strerror(-n)); + log_error_errno(n, "Failed to read listening file descriptors from environment: %m"); return n; } else log_info("Received %d descriptors", n); @@ -896,8 +895,8 @@ static int remoteserver_init(RemoteServer *s, } if(r < 0) { - log_error("Failed to register socket (fd:%d): %s", - fd, strerror(-r)); + log_error_errno(r, "Failed to register socket (fd:%d): %m", + fd); return r; } } @@ -1462,15 +1461,15 @@ static int load_certificates(char **key, char **cert, char **trust) { r = read_full_file(arg_key ?: PRIV_KEY_FILE, key, NULL); if (r < 0) { - log_error("Failed to read key from file '%s': %s", - arg_key ?: PRIV_KEY_FILE, strerror(-r)); + log_error_errno(r, "Failed to read key from file '%s': %m", + arg_key ?: PRIV_KEY_FILE); return r; } r = read_full_file(arg_cert ?: CERT_FILE, cert, NULL); if (r < 0) { - log_error("Failed to read certificate from file '%s': %s", - arg_cert ?: CERT_FILE, strerror(-r)); + log_error_errno(r, "Failed to read certificate from file '%s': %m", + arg_cert ?: CERT_FILE); return r; } @@ -1479,8 +1478,8 @@ static int load_certificates(char **key, char **cert, char **trust) { else { r = read_full_file(arg_trust ?: TRUST_FILE, trust, NULL); if (r < 0) { - log_error("Failed to read CA certificate file '%s': %s", - arg_trust ?: TRUST_FILE, strerror(-r)); + log_error_errno(r, "Failed to read CA certificate file '%s': %m", + arg_trust ?: TRUST_FILE); return r; } } diff --git a/src/journal-remote/journal-upload-journal.c b/src/journal-remote/journal-upload-journal.c index ace31af0bf..6e5e45f7c9 100644 --- a/src/journal-remote/journal-upload-journal.c +++ b/src/journal-remote/journal-upload-journal.c @@ -134,8 +134,7 @@ static ssize_t write_entry(char *buf, size_t size, Uploader *u) { &u->field_data, &u->field_length); if (r < 0) { - log_error("Failed to move to next field in entry: %s", - strerror(-r)); + log_error_errno(r, "Failed to move to next field in entry: %m"); return r; } else if (r == 0) { u->entry_state = ENTRY_OUTRO; @@ -250,8 +249,7 @@ static size_t journal_input_callback(void *buf, size_t size, size_t nmemb, void if (u->entry_state == ENTRY_DONE) { r = sd_journal_next(j); if (r < 0) { - log_error("Failed to move to next entry in journal: %s", - strerror(-r)); + log_error_errno(r, "Failed to move to next entry in journal: %m"); return CURL_READFUNC_ABORT; } else if (r == 0) { if (u->input_event) @@ -392,8 +390,8 @@ int open_journal_for_upload(Uploader *u, if (cursor) { r = sd_journal_seek_cursor(j, cursor); if (r < 0) { - log_error("Failed to seek to cursor %s: %s", - cursor, strerror(-r)); + log_error_errno(r, "Failed to seek to cursor %s: %m", + cursor); return r; } } diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c index 0b9a817b23..e677e13348 100644 --- a/src/journal-remote/journal-upload.c +++ b/src/journal-remote/journal-upload.c @@ -87,8 +87,8 @@ static size_t output_callback(char *buf, if (nmemb && !u->answer) { u->answer = strndup(buf, size*nmemb); if (!u->answer) - log_warning("Failed to store server answer (%zu bytes): %s", - size*nmemb, strerror(ENOMEM)); + log_warning_errno(ENOMEM, "Failed to store server answer (%zu bytes): %m", + size*nmemb); } return size * nmemb; @@ -104,15 +104,15 @@ static int check_cursor_updating(Uploader *u) { r = mkdir_parents(u->state_file, 0755); if (r < 0) { - log_error("Cannot create parent directory of state file %s: %s", - u->state_file, strerror(-r)); + log_error_errno(r, "Cannot create parent directory of state file %s: %m", + u->state_file); return r; } r = fopen_temporary(u->state_file, &f, &temp_path); if (r < 0) { - log_error("Cannot save state to %s: %s", - u->state_file, strerror(-r)); + log_error_errno(r, "Cannot save state to %s: %m", + u->state_file); return r; } unlink(temp_path); @@ -165,8 +165,8 @@ static int load_cursor_state(Uploader *u) { if (r == -ENOENT) log_debug("State file %s is not present.", u->state_file); else if (r < 0) { - log_error("Failed to read state file %s: %s", - u->state_file, strerror(-r)); + log_error_errno(r, "Failed to read state file %s: %m", + u->state_file); return r; } else log_debug("Last cursor was %s", u->last_cursor); @@ -786,9 +786,8 @@ static int open_journal(sd_journal **j) { else r = sd_journal_open(j, !arg_merge*SD_JOURNAL_LOCAL_ONLY + arg_journal_type); if (r < 0) - log_error("Failed to open %s: %s", - arg_directory ? arg_directory : arg_file ? "files" : "journal", - strerror(-r)); + log_error_errno(r, "Failed to open %s: %m", + arg_directory ? arg_directory : arg_file ? "files" : "journal"); return r; } diff --git a/src/journal/catalog.c b/src/journal/catalog.c index f16e28a7a8..67bf4ba017 100644 --- a/src/journal/catalog.c +++ b/src/journal/catalog.c @@ -348,8 +348,8 @@ static long write_catalog(const char *database, Hashmap *h, struct strbuf *sb, r = fopen_temporary(database, &w, &p); if (r < 0) { - log_error("Failed to open database for writing: %s: %s", - database, strerror(-r)); + log_error_errno(r, "Failed to open database for writing: %s: %m", + database); return r; } @@ -687,8 +687,8 @@ int catalog_list_items(FILE *f, const char *database, bool oneline, char **items k = sd_id128_from_string(*item, &id); if (k < 0) { - log_error("Failed to parse id128 '%s': %s", - *item, strerror(-k)); + log_error_errno(k, "Failed to parse id128 '%s': %m", + *item); if (r == 0) r = k; continue; diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c index b82c6f4530..edc12fead6 100644 --- a/src/journal/coredumpctl.c +++ b/src/journal/coredumpctl.c @@ -830,8 +830,8 @@ int main(int argc, char *argv[]) { SET_FOREACH(match, matches, it) { r = sd_journal_add_match(j, match, strlen(match)); if (r != 0) { - log_error("Failed to add match '%s': %s", - match, strerror(-r)); + log_error_errno(r, "Failed to add match '%s': %m", + match); goto end; } } diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 1fdd7fc5c8..96b0ddd80f 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -1662,8 +1662,7 @@ static int access_check(sd_journal *j) { assert(err > 0); if (err != EACCES) - log_warning("Error was encountered while opening journal files: %s", - strerror(err)); + log_warning_errno(err, "Error was encountered while opening journal files: %m"); } return r; @@ -1814,9 +1813,8 @@ int main(int argc, char *argv[]) { else r = sd_journal_open(&j, !arg_merge*SD_JOURNAL_LOCAL_ONLY + arg_journal_type); if (r < 0) { - log_error("Failed to open %s: %s", - arg_directory ? arg_directory : arg_file ? "files" : "journal", - strerror(-r)); + log_error_errno(r, "Failed to open %s: %m", + arg_directory ? arg_directory : arg_file ? "files" : "journal"); return EXIT_FAILURE; } diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index f30a3c1392..4f5d002d21 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -308,11 +308,11 @@ static int do_rotate(Server *s, JournalFile **f, const char* name, r = journal_file_rotate(f, s->compress, seal); if (r < 0) if (*f) - log_error("Failed to rotate %s: %s", - (*f)->path, strerror(-r)); + log_error_errno(r, "Failed to rotate %s: %m", + (*f)->path); else - log_error("Failed to create new %s journal: %s", - name, strerror(-r)); + log_error_errno(r, "Failed to create new %s journal: %m", + name); else server_fix_perms(s, *f, uid); return r; diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 61e64f7f7c..d171600eef 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -1466,8 +1466,8 @@ static int add_directory(sd_journal *j, const char *prefix, const char *dirname) dirent_is_file_with_suffix(de, ".journal~")) { r = add_file(j, m->path, de->d_name); if (r < 0) { - log_debug("Failed to add file %s/%s: %s", - m->path, de->d_name, strerror(-r)); + log_debug_errno(r, "Failed to add file %s/%s: %m", + m->path, de->d_name); r = set_put_error(j, r); if (r < 0) return r; @@ -1556,8 +1556,8 @@ static int add_root_directory(sd_journal *j, const char *p) { dirent_is_file_with_suffix(de, ".journal~")) { r = add_file(j, m->path, de->d_name); if (r < 0) { - log_debug("Failed to add file %s/%s: %s", - m->path, de->d_name, strerror(-r)); + log_debug_errno(r, "Failed to add file %s/%s: %m", + m->path, de->d_name); r = set_put_error(j, r); if (r < 0) return r; @@ -2218,8 +2218,8 @@ static void process_inotify_event(sd_journal *j, struct inotify_event *e) { if (e->mask & (IN_CREATE|IN_MOVED_TO|IN_MODIFY|IN_ATTRIB)) { r = add_file(j, d->path, e->name); if (r < 0) { - log_debug("Failed to add file %s/%s: %s", - d->path, e->name, strerror(-r)); + log_debug_errno(r, "Failed to add file %s/%s: %m", + d->path, e->name); set_put_error(j, r); } diff --git a/src/libsystemd-terminal/grdev-drm.c b/src/libsystemd-terminal/grdev-drm.c index 48f8e9ce96..2d678e8acf 100644 --- a/src/libsystemd-terminal/grdev-drm.c +++ b/src/libsystemd-terminal/grdev-drm.c @@ -2186,8 +2186,8 @@ static void grdrm_card_hotplug(grdrm_card *card) { card->ready = false; r = grdrm_card_resync(card); if (r < 0) { - log_debug("grdrm: %s/%s: cannot re-sync card: %s", - card->base.session->name, card->base.name, strerror(-r)); + log_debug_errno(r, "grdrm: %s/%s: cannot re-sync card: %m", + card->base.session->name, card->base.name); return; } @@ -2415,8 +2415,8 @@ static int grdrm_card_open(grdrm_card *card, int dev_fd) { r = ioctl(card->fd, DRM_IOCTL_GET_CAP, &cap); card->cap_dumb = r >= 0 && cap.value; if (r < 0) - log_debug("grdrm: %s/%s: cannot retrieve DUMB_BUFFER capability: %s", - card->base.session->name, card->base.name, strerror(-r)); + log_debug_errno(r, "grdrm: %s/%s: cannot retrieve DUMB_BUFFER capability: %m", + card->base.session->name, card->base.name); else if (!card->cap_dumb) log_debug("grdrm: %s/%s: DUMB_BUFFER capability not supported", card->base.session->name, card->base.name); @@ -2427,8 +2427,8 @@ static int grdrm_card_open(grdrm_card *card, int dev_fd) { r = ioctl(card->fd, DRM_IOCTL_GET_CAP, &cap); card->cap_monotonic = r >= 0 && cap.value; if (r < 0) - log_debug("grdrm: %s/%s: cannot retrieve TIMESTAMP_MONOTONIC capability: %s", - card->base.session->name, card->base.name, strerror(-r)); + log_debug_errno(r, "grdrm: %s/%s: cannot retrieve TIMESTAMP_MONOTONIC capability: %m", + card->base.session->name, card->base.name); else if (!card->cap_monotonic) log_debug("grdrm: %s/%s: TIMESTAMP_MONOTONIC is disabled globally, fix this NOW!", card->base.session->name, card->base.name); @@ -2507,8 +2507,8 @@ static void unmanaged_card_enable(grdev_card *basecard) { r = grdrm_card_open(&cu->card, fd); if (r < 0) { - log_debug("grdrm: %s/%s: cannot open: %s", - basecard->session->name, basecard->name, strerror(-r)); + log_debug_errno(r, "grdrm: %s/%s: cannot open: %m", + basecard->session->name, basecard->name); return; } } @@ -2580,8 +2580,8 @@ static int unmanaged_card_new(grdev_card **out, grdev_session *session, struct u r = grdrm_card_open(&cu->card, fd); if (r < 0) - log_debug("grdrm: %s/%s: cannot open: %s", - basecard->session->name, basecard->name, strerror(-r)); + log_debug_errno(r, "grdrm: %s/%s: cannot open: %m", + basecard->session->name, basecard->name); } if (out) @@ -2724,8 +2724,8 @@ static int managed_card_pause_device_fn(sd_bus *bus, } if (r < 0) - log_debug("grdrm: %s/%s: cannot send PauseDeviceComplete: %s", - session->name, cm->card.base.name, strerror(-r)); + log_debug_errno(r, "grdrm: %s/%s: cannot send PauseDeviceComplete: %m", + session->name, cm->card.base.name); } return 0; @@ -2778,8 +2778,8 @@ static int managed_card_resume_device_fn(sd_bus *bus, r = grdrm_card_open(&cm->card, fd); if (r < 0) { - log_debug("grdrm: %s/%s: cannot open: %s", - session->name, cm->card.base.name, strerror(-r)); + log_debug_errno(r, "grdrm: %s/%s: cannot open: %m", + session->name, cm->card.base.name); return 0; } } @@ -2870,8 +2870,8 @@ static int managed_card_take_device_fn(sd_bus *bus, r = grdrm_card_open(&cm->card, fd); if (r < 0) { - log_debug("grdrm: %s/%s: cannot open: %s", - session->name, cm->card.base.name, strerror(-r)); + log_debug_errno(r, "grdrm: %s/%s: cannot open: %m", + session->name, cm->card.base.name); return 0; } @@ -2912,8 +2912,8 @@ static void managed_card_take_device(managed_card *cm) { return; error: - log_debug("grdrm: %s/%s: cannot send TakeDevice request: %s", - session->name, cm->card.base.name, strerror(-r)); + log_debug_errno(r, "grdrm: %s/%s: cannot send TakeDevice request: %m", + session->name, cm->card.base.name); } static void managed_card_release_device(managed_card *cm) { @@ -2955,8 +2955,8 @@ static void managed_card_release_device(managed_card *cm) { } if (r < 0 && r != -ENOTCONN) - log_debug("grdrm: %s/%s: cannot send ReleaseDevice: %s", - session->name, cm->card.base.name, strerror(-r)); + log_debug_errno(r, "grdrm: %s/%s: cannot send ReleaseDevice: %m", + session->name, cm->card.base.name); } static int managed_card_new(grdev_card **out, grdev_session *session, struct udev_device *ud) { diff --git a/src/libsystemd-terminal/grdev.c b/src/libsystemd-terminal/grdev.c index 0c21eac551..db87ede762 100644 --- a/src/libsystemd-terminal/grdev.c +++ b/src/libsystemd-terminal/grdev.c @@ -577,8 +577,8 @@ static bool display_cache(grdev_display *display) { out: if (r < 0) - log_debug("grdev: %s/%s: cannot cache pipes: %s", - display->session->name, display->name, strerror(-r)); + log_debug_errno(r, "grdev: %s/%s: cannot cache pipes: %m", + display->session->name, display->name); return true; } @@ -772,8 +772,8 @@ void grdev_pipe_schedule(grdev_pipe *pipe, uint64_t frames) { return; error: - log_debug("grdev: %s/%s/%s: cannot schedule vsync timer: %s", - pipe->card->session->name, pipe->card->name, pipe->name, strerror(-r)); + log_debug_errno(r, "grdev: %s/%s/%s: cannot schedule vsync timer: %m", + pipe->card->session->name, pipe->card->name, pipe->name); } /* @@ -1176,8 +1176,8 @@ void grdev_session_add_drm(grdev_session *session, struct udev_device *ud) { r = grdev_drm_card_new(&card, session, ud); if (r < 0) { - log_debug("grdev: %s: cannot add DRM device for %s: %s", - session->name, udev_device_get_syspath(ud), strerror(-r)); + log_debug_errno(r, "grdev: %s: cannot add DRM device for %s: %m", + session->name, udev_device_get_syspath(ud)); return; } @@ -1269,8 +1269,8 @@ static void session_configure(grdev_session *session) { } else if (!display) { r = grdev_display_new(&display, session, pipe->name); if (r < 0) { - log_debug("grdev: %s/%s: cannot create display for pipe %s: %s", - session->name, card->name, pipe->name, strerror(-r)); + log_debug_errno(r, "grdev: %s/%s: cannot create display for pipe %s: %m", + session->name, card->name, pipe->name); continue; } } diff --git a/src/libsystemd-terminal/idev-evdev.c b/src/libsystemd-terminal/idev-evdev.c index 63fa89e47d..b3e86bfb19 100644 --- a/src/libsystemd-terminal/idev-evdev.c +++ b/src/libsystemd-terminal/idev-evdev.c @@ -222,8 +222,8 @@ static int idev_evdev_io(idev_evdev *evdev) { } if (error < 0) - log_debug("idev-evdev: %s/%s: error on data event: %s", - e->session->name, e->name, strerror(-error)); + log_debug_errno(error, "idev-evdev: %s/%s: error on data event: %m", + e->session->name, e->name); return error; error: @@ -448,8 +448,8 @@ static void unmanaged_evdev_resume(idev_element *e) { r = idev_evdev_resume(&eu->evdev, fd); if (r < 0) - log_debug("idev-evdev: %s/%s: cannot resume: %s", - e->session->name, e->name, strerror(-r)); + log_debug_errno(r, "idev-evdev: %s/%s: cannot resume: %m", + e->session->name, e->name); } static void unmanaged_evdev_pause(idev_element *e) { @@ -571,8 +571,8 @@ static int managed_evdev_take_device_fn(sd_bus *bus, r = idev_evdev_resume(&em->evdev, fd); if (r < 0) - log_debug("idev-evdev: %s/%s: cannot resume: %s", - s->name, e->name, strerror(-r)); + log_debug_errno(r, "idev-evdev: %s/%s: cannot resume: %m", + s->name, e->name); return 0; } @@ -621,8 +621,8 @@ static void managed_evdev_enable(idev_element *e) { return; error: - log_debug("idev-evdev: %s/%s: cannot send TakeDevice request: %s", - s->name, e->name, strerror(-r)); + log_debug_errno(r, "idev-evdev: %s/%s: cannot send TakeDevice request: %m", + s->name, e->name); } static void managed_evdev_disable(idev_element *e) { @@ -679,8 +679,8 @@ static void managed_evdev_disable(idev_element *e) { } if (r < 0 && r != -ENOTCONN) - log_debug("idev-evdev: %s/%s: cannot send ReleaseDevice: %s", - s->name, e->name, strerror(-r)); + log_debug_errno(r, "idev-evdev: %s/%s: cannot send ReleaseDevice: %m", + s->name, e->name); } static void managed_evdev_resume(idev_element *e, int fd) { @@ -705,8 +705,8 @@ static void managed_evdev_resume(idev_element *e, int fd) { r = idev_evdev_resume(&em->evdev, fd); if (r < 0) - log_debug("idev-evdev: %s/%s: cannot resume: %s", - s->name, e->name, strerror(-r)); + log_debug_errno(r, "idev-evdev: %s/%s: cannot resume: %m", + s->name, e->name); return; } @@ -776,8 +776,8 @@ static void managed_evdev_pause(idev_element *e, const char *mode) { } if (r < 0) - log_debug("idev-evdev: %s/%s: cannot send PauseDeviceComplete: %s", - s->name, e->name, strerror(-r)); + log_debug_errno(r, "idev-evdev: %s/%s: cannot send PauseDeviceComplete: %m", + s->name, e->name); } } diff --git a/src/libsystemd-terminal/idev-keyboard.c b/src/libsystemd-terminal/idev-keyboard.c index a26a49a80d..e971ab360d 100644 --- a/src/libsystemd-terminal/idev-keyboard.c +++ b/src/libsystemd-terminal/idev-keyboard.c @@ -284,8 +284,8 @@ static int kbdctx_refresh_compose_table(kbdctx *kc, const char *lang) { * it as a hard-failure but just continue. Preferably, we want * xkb to tell us exactly whether compilation failed or whether * there is no compose file available for this locale. */ - log_debug("idev-keyboard: cannot load compose-table for '%s': %s", - lang, strerror(-r)); + log_debug_errno(r, "idev-keyboard: cannot load compose-table for '%s': %m", + lang); r = 0; kt = NULL; } @@ -333,8 +333,7 @@ static int kbdctx_refresh_keymap(kbdctx *kc) { 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("idev-keyboard: cannot create keymap from locale1: %s", - strerror(-r)); + log_debug_errno(r, "idev-keyboard: cannot create keymap from locale1: %m"); return r; } @@ -648,8 +647,8 @@ static int keyboard_raise_data(idev_keyboard *k, idev_data *data) { r = idev_session_raise_device_data(d->session, d, data); if (r < 0) - log_debug("idev-keyboard: %s/%s: error while raising data event: %s", - d->session->name, d->name, strerror(-r)); + log_debug_errno(r, "idev-keyboard: %s/%s: error while raising data event: %m", + d->session->name, d->name); return r; } @@ -952,8 +951,8 @@ static void keyboard_repeat(idev_keyboard *k) { r = keyboard_fill(k, repdata, false, evkbd->keycode, KBDKEY_REPEAT, num, keysyms); if (r < 0) { - log_debug("idev-keyboard: %s/%s: cannot set key-repeat: %s", - d->session->name, d->name, strerror(-r)); + log_debug_errno(r, "idev-keyboard: %s/%s: cannot set key-repeat: %m", + d->session->name, d->name); k->repeating = false; keyboard_arm(k, 0); } else { @@ -977,8 +976,8 @@ static void keyboard_repeat(idev_keyboard *k) { r = keyboard_fill(k, repdata, false, repkbd->keycode, KBDKEY_REPEAT, num, keysyms); if (r < 0) { - log_debug("idev-keyboard: %s/%s: cannot update key-repeat: %s", - d->session->name, d->name, strerror(-r)); + log_debug_errno(r, "idev-keyboard: %s/%s: cannot update key-repeat: %m", + d->session->name, d->name); k->repeating = false; keyboard_arm(k, 0); } @@ -1067,8 +1066,8 @@ static int keyboard_feed_evdev(idev_keyboard *k, idev_data *data) { return keyboard_raise_data(k, &k->evdata); error: - log_debug("idev-keyboard: %s/%s: cannot handle event: %s", - d->session->name, d->name, strerror(-r)); + log_debug_errno(r, "idev-keyboard: %s/%s: cannot handle event: %m", + d->session->name, d->name); k->repeating = false; keyboard_arm(k, 0); return 0; @@ -1128,8 +1127,8 @@ static int keyboard_update_kbdmap(idev_keyboard *k) { return 0; error: - log_debug("idev-keyboard: %s/%s: cannot adopt new keymap: %s", - d->session->name, d->name, strerror(-r)); + log_debug_errno(r, "idev-keyboard: %s/%s: cannot adopt new keymap: %m", + d->session->name, d->name); return r; } @@ -1162,8 +1161,8 @@ static int keyboard_update_kbdtbl(idev_keyboard *k) { return 0; error: - log_debug("idev-keyboard: %s/%s: cannot adopt new compose table: %s", - d->session->name, d->name, strerror(-r)); + log_debug_errno(r, "idev-keyboard: %s/%s: cannot adopt new compose table: %m", + d->session->name, d->name); return r; } diff --git a/src/libsystemd-terminal/idev.c b/src/libsystemd-terminal/idev.c index e979b608b6..989683f39a 100644 --- a/src/libsystemd-terminal/idev.c +++ b/src/libsystemd-terminal/idev.c @@ -351,8 +351,8 @@ static int session_add_device(idev_session *s, idev_device *d) { error: if (r < 0) - log_debug("idev: %s: error while adding device '%s': %s", - s->name, d->name, strerror(-r)); + log_debug_errno(r, "idev: %s: error while adding device '%s': %m", + s->name, d->name); return r; } @@ -372,8 +372,8 @@ static int session_remove_device(idev_session *s, idev_device *d) { idev_device_disable(d); if (error < 0) - log_debug("idev: %s: error while removing device '%s': %s", - s->name, d->name, strerror(-error)); + log_debug_errno(error, "idev: %s: error while removing device '%s': %m", + s->name, d->name); idev_device_free(d); return error; } @@ -420,8 +420,8 @@ static int session_remove_element(idev_session *s, idev_element *e) { element_disable(e); if (error < 0) - log_debug("idev: %s: error while removing element '%s': %s", - s->name, e->name, strerror(-r)); + log_debug_errno(r, "idev: %s: error while removing element '%s': %m", + s->name, e->name); idev_element_free(e); return error; } diff --git a/src/libsystemd-terminal/sysview.c b/src/libsystemd-terminal/sysview.c index 9eb659777a..62d9b66060 100644 --- a/src/libsystemd-terminal/sysview.c +++ b/src/libsystemd-terminal/sysview.c @@ -295,8 +295,8 @@ static int session_take_control_fn(sd_bus *bus, r = context_raise_session_control(session->seat->context, session, error); if (r < 0) - log_debug("sysview: callback failed while signalling session control '%d' on session '%s': %s", - error, session->name, strerror(-r)); + log_debug_errno(r, "sysview: callback failed while signalling session control '%d' on session '%s': %m", + error, session->name); return 0; } @@ -365,8 +365,8 @@ void sysview_session_release_control(sysview_session *session) { r = sd_bus_send(session->seat->context->sysbus, m, NULL); if (r < 0 && r != -ENOTCONN) - log_debug("sysview: %s: cannot send ReleaseControl: %s", - session->name, strerror(-r)); + log_debug_errno(r, "sysview: %s: cannot send ReleaseControl: %m", + session->name); } /* @@ -604,8 +604,8 @@ static void context_add_device(sysview_context *c, sysview_device *device) { r = context_raise_session_attach(c, session, device); if (r < 0) - log_debug("sysview: callback failed while attaching device '%s' to session '%s': %s", - device->name, session->name, strerror(-r)); + log_debug_errno(r, "sysview: callback failed while attaching device '%s' to session '%s': %m", + device->name, session->name); } } @@ -625,8 +625,8 @@ static void context_remove_device(sysview_context *c, sysview_device *device) { r = context_raise_session_detach(c, session, device); if (r < 0) - log_debug("sysview: callback failed while detaching device '%s' from session '%s': %s", - device->name, session->name, strerror(-r)); + log_debug_errno(r, "sysview: callback failed while detaching device '%s' from session '%s': %m", + device->name, session->name); } sysview_device_free(device); @@ -648,8 +648,8 @@ static void context_change_device(sysview_context *c, sysview_device *device, st r = context_raise_session_refresh(c, session, device, ud); if (r < 0) - log_debug("sysview: callback failed while changing device '%s' on session '%s': %s", - device->name, session->name, strerror(-r)); + log_debug_errno(r, "sysview: callback failed while changing device '%s' on session '%s': %m", + device->name, session->name); } } @@ -683,8 +683,8 @@ static void context_add_session(sysview_context *c, sysview_seat *seat, const ch session->public = true; r = context_raise_session_add(c, session); if (r < 0) { - log_debug("sysview: callback failed while adding session '%s': %s", - session->name, strerror(-r)); + log_debug_errno(r, "sysview: callback failed while adding session '%s': %m", + session->name); session->public = false; goto error; } @@ -692,8 +692,8 @@ static void context_add_session(sysview_context *c, sysview_seat *seat, const ch HASHMAP_FOREACH(device, seat->device_map, i) { r = context_raise_session_attach(c, session, device); if (r < 0) - log_debug("sysview: callback failed while attaching device '%s' to new session '%s': %s", - device->name, session->name, strerror(-r)); + log_debug_errno(r, "sysview: callback failed while attaching device '%s' to new session '%s': %m", + device->name, session->name); } } @@ -701,8 +701,8 @@ static void context_add_session(sysview_context *c, sysview_seat *seat, const ch error: if (r < 0) - log_debug("sysview: error while adding session '%s': %s", - id, strerror(-r)); + log_debug_errno(r, "sysview: error while adding session '%s': %m", + id); } static void context_remove_session(sysview_context *c, sysview_session *session) { @@ -719,15 +719,15 @@ static void context_remove_session(sysview_context *c, sysview_session *session) HASHMAP_FOREACH(device, session->seat->device_map, i) { r = context_raise_session_detach(c, session, device); if (r < 0) - log_debug("sysview: callback failed while detaching device '%s' from old session '%s': %s", - device->name, session->name, strerror(-r)); + log_debug_errno(r, "sysview: callback failed while detaching device '%s' from old session '%s': %m", + device->name, session->name); } session->public = false; r = context_raise_session_remove(c, session); if (r < 0) - log_debug("sysview: callback failed while removing session '%s': %s", - session->name, strerror(-r)); + log_debug_errno(r, "sysview: callback failed while removing session '%s': %m", + session->name); } if (!session->custom) @@ -756,8 +756,8 @@ static void context_add_seat(sysview_context *c, const char *id) { seat->public = true; r = context_raise_seat_add(c, seat); if (r < 0) { - log_debug("sysview: callback failed while adding seat '%s': %s", - seat->name, strerror(-r)); + log_debug_errno(r, "sysview: callback failed while adding seat '%s': %m", + seat->name); seat->public = false; } @@ -765,8 +765,8 @@ static void context_add_seat(sysview_context *c, const char *id) { error: if (r < 0) - log_debug("sysview: error while adding seat '%s': %s", - id, strerror(-r)); + log_debug_errno(r, "sysview: error while adding seat '%s': %m", + id); } static void context_remove_seat(sysview_context *c, sysview_seat *seat) { @@ -789,8 +789,8 @@ static void context_remove_seat(sysview_context *c, sysview_seat *seat) { seat->public = false; r = context_raise_seat_remove(c, seat); if (r < 0) - log_debug("sysview: callback failed while removing seat '%s': %s", - seat->name, strerror(-r)); + log_debug_errno(r, "sysview: callback failed while removing seat '%s': %m", + seat->name); } sysview_seat_free(seat); @@ -976,8 +976,8 @@ static int context_ud_hotplug(sysview_context *c, struct udev_device *d) { r = device_new_ud(&device, seat, type, d); if (r < 0) { - log_debug("sysview: cannot create device for udev-device '%s': %s", - syspath, strerror(-r)); + log_debug_errno(r, "sysview: cannot create device for udev-device '%s': %m", + syspath); return r; } @@ -1083,8 +1083,8 @@ static int context_ud_scan(sysview_context *c) { d = udev_device_new_from_syspath(c->ud, name); if (!d) { r = errno > 0 ? -errno : -EFAULT; - log_debug("sysview: cannot create udev-device for %s: %s", - name, strerror(-r)); + log_debug_errno(r, "sysview: cannot create udev-device for %s: %m", + name); continue; } @@ -1103,8 +1103,7 @@ static int context_ld_seat_new(sysview_context *c, sd_bus_message *signal) { r = sd_bus_message_read(signal, "so", &id, &path); if (r < 0) { - log_debug("sysview: cannot parse SeatNew from logind: %s", - strerror(-r)); + log_debug_errno(r, "sysview: cannot parse SeatNew from logind: %m"); return r; } @@ -1119,8 +1118,7 @@ static int context_ld_seat_removed(sysview_context *c, sd_bus_message *signal) { r = sd_bus_message_read(signal, "so", &id, &path); if (r < 0) { - log_debug("sysview: cannot parse SeatRemoved from logind: %s", - strerror(-r)); + log_debug_errno(r, "sysview: cannot parse SeatRemoved from logind: %m"); return r; } @@ -1141,8 +1139,7 @@ static int context_ld_session_new(sysview_context *c, sd_bus_message *signal) { r = sd_bus_message_read(signal, "so", &id, &path); if (r < 0) { - log_debug("sysview: cannot parse SessionNew from logind: %s", - strerror(-r)); + log_debug_errno(r, "sysview: cannot parse SessionNew from logind: %m"); return r; } @@ -1177,16 +1174,16 @@ static int context_ld_session_new(sysview_context *c, sd_bus_message *signal) { r = context_raise_session_filter(c, id, seatid, username, uid); if (r < 0) - log_debug("sysview: callback failed while filtering session '%s': %s", - id, strerror(-r)); + log_debug_errno(r, "sysview: callback failed while filtering session '%s': %m", + id); else if (r > 0) context_add_session(c, seat, id); return 0; error: - log_debug("sysview: failed retrieving information for new session '%s': %s", - id, strerror(-r)); + log_debug_errno(r, "sysview: failed retrieving information for new session '%s': %m", + id); return r; } @@ -1197,8 +1194,7 @@ static int context_ld_session_removed(sysview_context *c, sd_bus_message *signal r = sd_bus_message_read(signal, "so", &id, &path); if (r < 0) { - log_debug("sysview: cannot parse SessionRemoved from logind: %s", - strerror(-r)); + log_debug_errno(r, "sysview: cannot parse SessionRemoved from logind: %m"); return r; } @@ -1299,8 +1295,7 @@ static int context_ld_list_seats_fn(sd_bus *bus, return 0; error: - log_debug("sysview: erroneous ListSeats response from logind: %s", - strerror(-r)); + log_debug_errno(r, "sysview: erroneous ListSeats response from logind: %m"); return r; } @@ -1344,8 +1339,8 @@ static int context_ld_list_sessions_fn(sd_bus *bus, if (seat) { r = context_raise_session_filter(c, id, seatid, username, uid); if (r < 0) - log_debug("sysview: callback failed while filtering session '%s': %s", - id, strerror(-r)); + log_debug_errno(r, "sysview: callback failed while filtering session '%s': %m", + id); else if (r > 0) context_add_session(c, seat, id); } @@ -1365,8 +1360,7 @@ static int context_ld_list_sessions_fn(sd_bus *bus, return 0; error: - log_debug("sysview: erroneous ListSessions response from logind: %s", - strerror(-r)); + log_debug_errno(r, "sysview: erroneous ListSessions response from logind: %m"); return r; } diff --git a/src/locale/localed.c b/src/locale/localed.c index f587b224a0..119a1da844 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -1095,8 +1095,8 @@ static int method_set_x11_keyboard(sd_bus *bus, sd_bus_message *m, void *userdat r = verify_xkb_rmlvo(model, layout, variant, options); if (r < 0) - log_warning("Cannot compile XKB keymap for new x11 keyboard layout ('%s' / '%s' / '%s' / '%s'): %s", - strempty(model), strempty(layout), strempty(variant), strempty(options), strerror(-r)); + log_warning_errno(r, "Cannot compile XKB keymap for new x11 keyboard layout ('%s' / '%s' / '%s' / '%s'): %m", + strempty(model), strempty(layout), strempty(variant), strempty(options)); if (free_and_strdup(&c->x11_layout, layout) < 0 || free_and_strdup(&c->x11_model, model) < 0 || diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c index b31dc807f4..99aa429ed8 100644 --- a/src/modules-load/modules-load.c +++ b/src/modules-load/modules-load.c @@ -116,8 +116,7 @@ static int load_module(struct kmod_ctx *ctx, const char *m) { else if (err == KMOD_PROBE_APPLY_BLACKLIST) log_info("Module '%s' is blacklisted", kmod_module_get_name(mod)); else { - log_error("Failed to insert '%s': %s", kmod_module_get_name(mod), - strerror(-err)); + log_error_errno(err, "Failed to insert '%s': %m", kmod_module_get_name(mod)); r = err; } } diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index e95184b8ff..9502fa8caa 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -118,8 +118,7 @@ int address_drop(Address *address, Link *link, r = sd_rtnl_message_new_addr(link->manager->rtnl, &req, RTM_DELADDR, link->ifindex, address->family); if (r < 0) { - log_error("Could not allocate RTM_DELADDR message: %s", - strerror(-r)); + log_error_errno(r, "Could not allocate RTM_DELADDR message: %m"); return r; } @@ -134,8 +133,7 @@ int address_drop(Address *address, Link *link, 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("Could not append IFA_LOCAL attribute: %s", - strerror(-r)); + log_error_errno(r, "Could not append IFA_LOCAL attribute: %m"); return r; } @@ -164,8 +162,7 @@ int address_update(Address *address, Link *link, r = sd_rtnl_message_new_addr_update(link->manager->rtnl, &req, link->ifindex, address->family); if (r < 0) { - log_error("Could not allocate RTM_NEWADDR message: %s", - strerror(-r)); + log_error_errno(r, "Could not allocate RTM_NEWADDR message: %m"); return r; } @@ -192,16 +189,14 @@ int address_update(Address *address, Link *link, 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("Could not append IFA_LOCAL attribute: %s", - strerror(-r)); + log_error_errno(r, "Could not append IFA_LOCAL attribute: %m"); return r; } if (address->family == AF_INET) { r = sd_rtnl_message_append_in_addr(req, IFA_BROADCAST, &address->broadcast); if (r < 0) { - log_error("Could not append IFA_BROADCAST attribute: %s", - strerror(-r)); + log_error_errno(r, "Could not append IFA_BROADCAST attribute: %m"); return r; } } @@ -209,16 +204,14 @@ int address_update(Address *address, Link *link, if (address->label) { r = sd_rtnl_message_append_string(req, IFA_LABEL, address->label); if (r < 0) { - log_error("Could not append IFA_LABEL attribute: %s", - strerror(-r)); + log_error_errno(r, "Could not append IFA_LABEL attribute: %m"); return r; } } r = sd_rtnl_message_append_cache_info(req, IFA_CACHEINFO, &address->cinfo); if (r < 0) { - log_error("Could not append IFA_CACHEINFO attribute: %s", - strerror(-r)); + log_error_errno(r, "Could not append IFA_CACHEINFO attribute: %m"); return r; } @@ -313,8 +306,7 @@ int address_configure(Address *address, Link *link, r = sd_rtnl_message_new_addr(link->manager->rtnl, &req, RTM_NEWADDR, link->ifindex, address->family); if (r < 0) { - log_error("Could not allocate RTM_NEWADDR message: %s", - strerror(-r)); + log_error_errno(r, "Could not allocate RTM_NEWADDR message: %m"); return r; } @@ -341,8 +333,7 @@ int address_configure(Address *address, Link *link, 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("Could not append IFA_LOCAL attribute: %s", - strerror(-r)); + log_error_errno(r, "Could not append IFA_LOCAL attribute: %m"); return r; } @@ -352,16 +343,14 @@ int address_configure(Address *address, Link *link, 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("Could not append IFA_ADDRESS attribute: %s", - strerror(-r)); + log_error_errno(r, "Could not append IFA_ADDRESS attribute: %m"); return r; } } else { if (address->family == AF_INET) { r = sd_rtnl_message_append_in_addr(req, IFA_BROADCAST, &address->broadcast); if (r < 0) { - log_error("Could not append IFA_BROADCAST attribute: %s", - strerror(-r)); + log_error_errno(r, "Could not append IFA_BROADCAST attribute: %m"); return r; } } @@ -370,8 +359,7 @@ int address_configure(Address *address, Link *link, if (address->label) { r = sd_rtnl_message_append_string(req, IFA_LABEL, address->label); if (r < 0) { - log_error("Could not append IFA_LABEL attribute: %s", - strerror(-r)); + log_error_errno(r, "Could not append IFA_LABEL attribute: %m"); return r; } } @@ -379,8 +367,7 @@ int address_configure(Address *address, Link *link, r = sd_rtnl_message_append_cache_info(req, IFA_CACHEINFO, &address->cinfo); if (r < 0) { - log_error("Could not append IFA_CACHEINFO attribute: %s", - strerror(-r)); + log_error_errno(r, "Could not append IFA_CACHEINFO attribute: %m"); return r; } diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c index 98a12c277a..3a1d565e7b 100644 --- a/src/network/networkd-manager.c +++ b/src/network/networkd-manager.c @@ -262,8 +262,7 @@ static int manager_rtnl_process_link(sd_rtnl *rtnl, sd_rtnl_message *message, vo /* link is new, so add it */ r = link_add(m, message, &link); if (r < 0) { - log_debug("could not add new link: %s", - strerror(-r)); + log_debug_errno(r, "could not add new link: %m"); return 0; } } diff --git a/src/network/networkd-netdev-tuntap.c b/src/network/networkd-netdev-tuntap.c index 7767d75507..57cc77c555 100644 --- a/src/network/networkd-netdev-tuntap.c +++ b/src/network/networkd-netdev-tuntap.c @@ -95,8 +95,8 @@ static int netdev_tuntap_add(NetDev *netdev, struct ifreq *ifr) { r = get_user_creds(&user, &uid, NULL, NULL, NULL); if (r < 0) { - log_error("Cannot resolve user name %s: %s", - t->user_name, strerror(-r)); + log_error_errno(r, "Cannot resolve user name %s: %m", + t->user_name); return 0; } @@ -114,8 +114,8 @@ static int netdev_tuntap_add(NetDev *netdev, struct ifreq *ifr) { r = get_group_creds(&group, &gid); if (r < 0) { - log_error("Cannot resolve group name %s: %s", - t->group_name, strerror(-r)); + log_error_errno(r, "Cannot resolve group name %s: %m", + t->group_name); return 0; } diff --git a/src/network/networkd.c b/src/network/networkd.c index fe5860411d..430d615f90 100644 --- a/src/network/networkd.c +++ b/src/network/networkd.c @@ -54,18 +54,15 @@ int main(int argc, char *argv[]) { * watches in. */ r = mkdir_safe_label("/run/systemd/netif", 0755, uid, gid); if (r < 0) - log_error("Could not create runtime directory: %s", - strerror(-r)); + log_error_errno(r, "Could not create runtime directory: %m"); r = mkdir_safe_label("/run/systemd/netif/links", 0755, uid, gid); if (r < 0) - log_error("Could not create runtime directory 'links': %s", - strerror(-r)); + log_error_errno(r, "Could not create runtime directory 'links': %m"); r = mkdir_safe_label("/run/systemd/netif/leases", 0755, uid, gid); if (r < 0) - log_error("Could not create runtime directory 'leases': %s", - strerror(-r)); + log_error_errno(r, "Could not create runtime directory 'leases': %m"); r = drop_privileges(uid, gid, (1ULL << CAP_NET_ADMIN) | diff --git a/src/run/run.c b/src/run/run.c index ea9454a0e5..8c7bd5c92d 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -575,10 +575,9 @@ int main(int argc, char* argv[]) { r = find_binary(argv[optind], arg_transport == BUS_TRANSPORT_LOCAL, &command); if (r < 0) { - log_error("Failed to find executable %s%s: %s", - argv[optind], - arg_transport == BUS_TRANSPORT_LOCAL ? "" : " on local system", - strerror(-r)); + log_error_errno(r, "Failed to find executable %s%s: %m", + argv[optind], + arg_transport == BUS_TRANSPORT_LOCAL ? "" : " on local system"); goto finish; } argv[optind] = command; diff --git a/src/shared/conf-files.c b/src/shared/conf-files.c index e6ee97a978..51f4e0105c 100644 --- a/src/shared/conf-files.c +++ b/src/shared/conf-files.c @@ -118,8 +118,8 @@ static int conf_files_list_strv_internal(char ***strv, const char *suffix, const if (r == -ENOMEM) { return r; } else if (r < 0) - log_debug("Failed to search for files in %s: %s", - *p, strerror(-r)); + log_debug_errno(r, "Failed to search for files in %s: %m", + *p); } files = hashmap_get_strv(fh); diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index f9a3459caa..94808fa6ce 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -428,8 +428,8 @@ int config_parse(const char *unit, if (r < 0) { if (warn) - log_warning("Failed to parse file '%s': %s", - filename, strerror(-r)); + log_warning_errno(r, "Failed to parse file '%s': %m", + filename); return r; } } diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index eb15eeac88..16ea1bb782 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -426,8 +426,7 @@ static int output_verbose( else { r = safe_atou64(value, &realtime); if (r < 0) - log_debug("Failed to parse realtime timestamp: %s", - strerror(-r)); + log_debug_errno(r, "Failed to parse realtime timestamp: %m"); } } diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index e6157f0e94..0fd307d0b0 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -233,8 +233,8 @@ static bool enough_memory_for_hibernation(void) { r = safe_atollu(active, &act); if (r < 0) { - log_error("Failed to parse Active(anon) from /proc/meminfo: %s: %s", - active, strerror(-r)); + log_error_errno(r, "Failed to parse Active(anon) from /proc/meminfo: %s: %m", + active); return false; } diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c index 0d7c1e3fbe..6261502588 100644 --- a/src/sleep/sleep.c +++ b/src/sleep/sleep.c @@ -48,15 +48,14 @@ static int write_mode(char **modes) { if (k == 0) return 0; - log_debug("Failed to write '%s' to /sys/power/disk: %s", - *mode, strerror(-k)); + log_debug_errno(k, "Failed to write '%s' to /sys/power/disk: %m", + *mode); if (r == 0) r = k; } if (r < 0) - log_error("Failed to write mode to /sys/power/disk: %s", - strerror(-r)); + log_error_errno(r, "Failed to write mode to /sys/power/disk: %m"); return r; } @@ -71,8 +70,8 @@ static int write_state(FILE **f, char **states) { k = write_string_stream(*f, *state); if (k == 0) return 0; - log_debug("Failed to write '%s' to /sys/power/state: %s", - *state, strerror(-k)); + log_debug_errno(k, "Failed to write '%s' to /sys/power/state: %m", + *state); if (r == 0) r = k; |