From 4bf4f50faabd9014720e3e499801d4cdb1e32f6d Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Wed, 3 Nov 2021 11:04:46 +0100 Subject: tree-wide: warn when sd_notify fails with READY=1 or FDSTOREREMOVE=1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most sd_notify() calls are like log_info() — the result is only informative and if they fail, it's best ignore this. But if a call with READY=1 fails, the unit may enter a failed state, so we should warn about this. Similarly for FSTOREREMOVE=1: the manager may be left with a stale fd, at least wasting resources. --- src/portable/portabled.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/portable') diff --git a/src/portable/portabled.c b/src/portable/portabled.c index 3c8e20e0f3..2f9afdc8f2 100644 --- a/src/portable/portabled.c +++ b/src/portable/portabled.c @@ -4,11 +4,11 @@ #include #include "sd-bus.h" -#include "sd-daemon.h" #include "alloc-util.h" #include "bus-log-control-api.h" #include "bus-polkit.h" +#include "daemon-util.h" #include "def.h" #include "main-func.h" #include "portabled-bus.h" @@ -154,15 +154,13 @@ static int run(int argc, char *argv[]) { return log_error_errno(r, "Failed to fully start up daemon: %m"); log_debug("systemd-portabled running as pid " PID_FMT, getpid_cached()); - sd_notify(false, - "READY=1\n" - "STATUS=Processing requests..."); + r = sd_notify(false, NOTIFY_READY); + if (r < 0) + log_warning_errno(r, "Failed to send readiness notification, ignoring: %m"); r = manager_run(m); - (void) sd_notify(false, - "STOPPING=1\n" - "STATUS=Shutting down..."); + (void) sd_notify(false, NOTIFY_STOPPING); log_debug("systemd-portabled stopped as pid " PID_FMT, getpid_cached()); return r; } -- cgit v1.2.3 From 384c2c3239c51b7bdaddc7cbd4958b5b923cce42 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Tue, 3 Aug 2021 16:59:09 +0200 Subject: Make pager_open() return void --- src/analyze/analyze.c | 20 ++++++++++---------- src/binfmt/binfmt.c | 2 +- src/boot/bootctl.c | 4 ++-- src/busctl/busctl.c | 22 +++++++++++----------- src/cgls/cgls.c | 4 ++-- src/core/main.c | 2 +- src/coredump/coredumpctl.c | 2 +- src/delta/delta.c | 2 +- src/dissect/dissect.c | 2 +- src/home/homectl.c | 4 ++-- src/journal/journalctl.c | 8 ++++---- src/locale/localectl.c | 6 +++--- src/login/inhibit.c | 2 +- src/login/loginctl.c | 14 +++++++------- src/machine/machinectl.c | 12 ++++++------ src/mount/mount-tool.c | 2 +- src/network/networkctl.c | 6 +++--- src/nspawn/nspawn.c | 2 +- src/oom/oomctl.c | 4 ++-- src/portable/portablectl.c | 4 ++-- src/resolve/resolvectl.c | 4 ++-- src/shared/format-table.c | 2 +- src/shared/pager.c | 28 ++++++++++++---------------- src/shared/pager.h | 2 +- src/sysctl/sysctl.c | 2 +- src/systemctl/systemctl-edit.c | 2 +- src/systemctl/systemctl-list-dependencies.c | 2 +- src/systemctl/systemctl-list-jobs.c | 4 ++-- src/systemctl/systemctl-list-machines.c | 2 +- src/systemctl/systemctl-list-unit-files.c | 2 +- src/systemctl/systemctl-list-units.c | 6 +++--- src/systemctl/systemctl-set-environment.c | 2 +- src/systemctl/systemctl-show.c | 4 ++-- src/systemctl/systemctl.c | 2 +- src/sysusers/sysusers.c | 2 +- src/timedate/timedatectl.c | 2 +- src/tmpfiles/tmpfiles.c | 2 +- src/userdb/userdbctl.c | 2 +- 38 files changed, 96 insertions(+), 100 deletions(-) (limited to 'src/portable') diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index c6a0f8efc3..5badbd8ca8 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -1051,7 +1051,7 @@ static int analyze_critical_chain(int argc, char *argv[], void *userdata) { } unit_times_hashmap = h; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); puts("The time when unit became active or started is printed after the \"@\" character.\n" "The time the unit took to start is printed after the \"+\" character.\n"); @@ -1121,7 +1121,7 @@ static int analyze_blame(int argc, char *argv[], void *userdata) { return table_log_add_error(r); } - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); return table_print(table, NULL); } @@ -1349,7 +1349,7 @@ static int dump(int argc, char *argv[], void *userdata) { if (r < 0) return bus_log_connect_error(r); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (!sd_bus_can_send(bus, SD_BUS_TYPE_UNIX_FD)) return dump_fallback(bus); @@ -1376,7 +1376,7 @@ static int cat_config(int argc, char *argv[], void *userdata) { char **arg, **list; int r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); list = strv_skip(argv, 1); STRV_FOREACH(arg, list) { @@ -1523,7 +1523,7 @@ static int dump_exit_status(int argc, char *argv[], void *userdata) { return table_log_add_error(r); } - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); return table_print(table, NULL); } @@ -1568,7 +1568,7 @@ static int dump_capabilities(int argc, char *argv[], void *userdata) { (void) table_set_sort(table, (size_t) 1); } - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); return table_print(table, NULL); } @@ -1652,7 +1652,7 @@ static void dump_syscall_filter(const SyscallFilterSet *set) { static int dump_syscall_filters(int argc, char *argv[], void *userdata) { bool first = true; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (strv_isempty(strv_skip(argv, 1))) { _cleanup_set_free_ Set *kernel = NULL, *known = NULL; @@ -1824,7 +1824,7 @@ static int dump_filesystems(int argc, char *argv[], void *userdata) { return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "Not compiled with libbpf support, sorry."); #endif - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (strv_isempty(strv_skip(argv, 1))) { _cleanup_set_free_ Set *kernel = NULL, *known = NULL; @@ -2270,7 +2270,7 @@ static int do_security(int argc, char *argv[], void *userdata) { if (r < 0) return bus_log_connect_error(r); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (arg_security_policy) { r = json_parse_file(/*f=*/ NULL, arg_security_policy, /*flags=*/ 0, &policy, &line, &column); @@ -2309,7 +2309,7 @@ static int help(int argc, char *argv[], void *userdata) { _cleanup_free_ char *link = NULL, *dot_link = NULL; int r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = terminal_urlify_man("systemd-analyze", "1", &link); if (r < 0) diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c index bf1861981a..c6b8dee446 100644 --- a/src/binfmt/binfmt.c +++ b/src/binfmt/binfmt.c @@ -217,7 +217,7 @@ static int run(int argc, char *argv[]) { return log_error_errno(r, "Failed to enumerate binfmt.d files: %m"); if (arg_cat_config) { - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); return cat_files(NULL, files, 0); } diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index 449eed0bed..f51fb1c0a4 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -1286,7 +1286,7 @@ static int verb_status(int argc, char *argv[], void *userdata) { r = 0; /* If we couldn't determine the path, then don't consider that a problem from here on, just show what we * can show */ - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (is_efi_boot()) { static const struct { @@ -1444,7 +1444,7 @@ static int verb_list(int argc, char *argv[], void *userdata) { if (config.n_entries == 0) log_info("No boot loader entries found."); else { - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); printf("Boot Loader Entries:\n"); diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c index 30a86234d9..85dc0bedf3 100644 --- a/src/busctl/busctl.c +++ b/src/busctl/busctl.c @@ -486,7 +486,7 @@ static int tree_one(sd_bus *bus, const char *service) { return log_oom(); } - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); l = set_get_strv(done); if (!l) @@ -526,7 +526,7 @@ static int tree(int argc, char **argv, void *userdata) { if (r < 0) return log_error_errno(r, "Failed to get name list: %m"); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); STRV_FOREACH(i, names) { int q; @@ -556,7 +556,7 @@ static int tree(int argc, char **argv, void *userdata) { printf("\n"); if (argv[2]) { - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); printf("Service %s%s%s:\n", ansi_highlight(), *i, ansi_normal()); } @@ -979,7 +979,7 @@ static int introspect(int argc, char **argv, void *userdata) { if (arg_xml_interface) { /* Just dump the received XML and finish */ - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); puts(xml); return 0; } @@ -1098,7 +1098,7 @@ static int introspect(int argc, char **argv, void *userdata) { typesafe_qsort(sorted, k, member_compare_funcp); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (arg_legend) printf("%-*s %-*s %-*s %-*s %s\n", @@ -1358,7 +1358,7 @@ static int status(int argc, char **argv, void *userdata) { if (r < 0) return r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (!isempty(argv[1])) { r = parse_pid(argv[1], &pid); @@ -2038,7 +2038,7 @@ static int call(int argc, char **argv, void *userdata) { _cleanup_(json_variant_unrefp) JsonVariant *v = NULL; if (arg_json_format_flags & (JSON_FORMAT_PRETTY|JSON_FORMAT_PRETTY_AUTO)) - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = json_transform_message(reply, &v); if (r < 0) @@ -2047,7 +2047,7 @@ static int call(int argc, char **argv, void *userdata) { json_variant_dump(v, arg_json_format_flags, NULL, NULL); } else if (arg_verbose) { - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = sd_bus_message_dump(reply, stdout, 0); if (r < 0) @@ -2147,7 +2147,7 @@ static int get_property(int argc, char **argv, void *userdata) { _cleanup_(json_variant_unrefp) JsonVariant *v = NULL; if (arg_json_format_flags & (JSON_FORMAT_PRETTY|JSON_FORMAT_PRETTY_AUTO)) - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = json_transform_variant(reply, contents, &v); if (r < 0) @@ -2156,7 +2156,7 @@ static int get_property(int argc, char **argv, void *userdata) { json_variant_dump(v, arg_json_format_flags, NULL, NULL); } else if (arg_verbose) { - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY); if (r < 0) @@ -2233,7 +2233,7 @@ static int help(void) { if (r < 0) return log_oom(); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); printf("%s [OPTIONS...] COMMAND ...\n\n" "%sIntrospect the D-Bus IPC bus.%s\n" diff --git a/src/cgls/cgls.c b/src/cgls/cgls.c index e2c746f7e7..e5333648bf 100644 --- a/src/cgls/cgls.c +++ b/src/cgls/cgls.c @@ -191,8 +191,8 @@ static int run(int argc, char *argv[]) { if (r <= 0) return r; - r = pager_open(arg_pager_flags); - if (r > 0 && arg_full < 0) + pager_open(arg_pager_flags); + if (arg_full < 0 && pager_have()) arg_full = true; if (arg_full > 0) diff --git a/src/core/main.c b/src/core/main.c index 129f340f6e..72dd199ddb 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -2902,7 +2902,7 @@ int main(int argc, char *argv[]) { goto finish; if (IN_SET(arg_action, ACTION_TEST, ACTION_HELP, ACTION_DUMP_CONFIGURATION_ITEMS, ACTION_DUMP_BUS_PROPERTIES, ACTION_BUS_INTROSPECT)) - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (arg_action != ACTION_RUN) skip_setup = true; diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c index 3f6537faee..2904de3728 100644 --- a/src/coredump/coredumpctl.c +++ b/src/coredump/coredumpctl.c @@ -824,7 +824,7 @@ static int dump_list(int argc, char **argv, void *userdata) { (void) table_set_empty_string(t, "-"); } else - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); /* "info" without pattern implies "-1" */ if ((arg_rows_max == 1 && arg_reverse) || (verb_is_info && argc == 1)) { diff --git a/src/delta/delta.c b/src/delta/delta.c index ad6b9a195a..8f154f7680 100644 --- a/src/delta/delta.c +++ b/src/delta/delta.c @@ -649,7 +649,7 @@ static int run(int argc, char *argv[]) { else if (arg_diff) arg_flags |= SHOW_OVERRIDDEN; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (optind < argc) { int i; diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c index 03c1e89cc5..7b4769d1b0 100644 --- a/src/dissect/dissect.c +++ b/src/dissect/dissect.c @@ -379,7 +379,7 @@ static int action_dissect(DissectedImage *m, LoopDevice *d) { assert(d); if (arg_json_format_flags & (JSON_FORMAT_OFF|JSON_FORMAT_PRETTY|JSON_FORMAT_PRETTY_AUTO)) - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (arg_json_format_flags & JSON_FORMAT_OFF) printf(" Name: %s\n", basename(arg_image)); diff --git a/src/home/homectl.c b/src/home/homectl.c index 4f1aebfe30..67a50a1ed5 100644 --- a/src/home/homectl.c +++ b/src/home/homectl.c @@ -613,7 +613,7 @@ static int inspect_home(int argc, char *argv[], void *userdata) { int r, ret = 0; char **items, **i; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = acquire_bus(&bus); if (r < 0) @@ -2020,7 +2020,7 @@ static int help(int argc, char *argv[], void *userdata) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = terminal_urlify_man("homectl", "1", &link); if (r < 0) diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 21e76a5899..5ea996c449 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -327,7 +327,7 @@ static int help(void) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = terminal_urlify_man("journalctl", "1", &link); if (r < 0) @@ -1445,7 +1445,7 @@ static int list_boots(sd_journal *j) { if (count == 0) return count; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); /* numbers are one less, but we need an extra char for the sign */ w = DECIMAL_STR_WIDTH(count - 1) + 1; @@ -2193,7 +2193,7 @@ int main(int argc, char *argv[]) { } else { bool oneline = arg_action == ACTION_LIST_CATALOG; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (optind < argc) r = catalog_list_items(stdout, database, oneline, argv + optind); @@ -2586,7 +2586,7 @@ int main(int argc, char *argv[]) { need_seek = true; if (!arg_follow) - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (!arg_quiet && (arg_lines != 0 || arg_follow)) { usec_t start, end; diff --git a/src/locale/localectl.c b/src/locale/localectl.c index 7e63976dfc..8c70660312 100644 --- a/src/locale/localectl.c +++ b/src/locale/localectl.c @@ -193,7 +193,7 @@ static int list_locales(int argc, char **argv, void *userdata) { if (r < 0) return log_error_errno(r, "Failed to read list of locales: %m"); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); strv_print(l); return 0; @@ -233,7 +233,7 @@ static int list_vconsole_keymaps(int argc, char **argv, void *userdata) { if (r < 0) return log_error_errno(r, "Failed to read list of keymaps: %m"); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); strv_print(l); @@ -362,7 +362,7 @@ static int list_x11_keymaps(int argc, char **argv, void *userdata) { strv_sort(list); strv_uniq(list); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); strv_print(list); return 0; diff --git a/src/login/inhibit.c b/src/login/inhibit.c index ff5a5d06f5..9f82e8d7e1 100644 --- a/src/login/inhibit.c +++ b/src/login/inhibit.c @@ -70,7 +70,7 @@ static int print_inhibitors(sd_bus *bus) { _cleanup_(table_unrefp) Table *table = NULL; int r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = sd_bus_call_method( bus, diff --git a/src/login/loginctl.c b/src/login/loginctl.c index 846a31012e..6f06ffdc9c 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -123,7 +123,7 @@ static int list_sessions(int argc, char *argv[], void *userdata) { assert(bus); assert(argv); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = bus_call_method(bus, bus_login_mgr, "ListSessions", &error, &reply, NULL); if (r < 0) @@ -197,7 +197,7 @@ static int list_users(int argc, char *argv[], void *userdata) { assert(bus); assert(argv); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = bus_call_method(bus, bus_login_mgr, "ListUsers", &error, &reply, NULL); if (r < 0) @@ -247,7 +247,7 @@ static int list_seats(int argc, char *argv[], void *userdata) { assert(bus); assert(argv); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = bus_call_method(bus, bus_login_mgr, "ListSeats", &error, &reply, NULL); if (r < 0) @@ -810,7 +810,7 @@ static int show_session(int argc, char *argv[], void *userdata) { properties = !strstr(argv[0], "status"); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (argc <= 1) { /* If no argument is specified inspect the manager itself */ @@ -847,7 +847,7 @@ static int show_user(int argc, char *argv[], void *userdata) { properties = !strstr(argv[0], "status"); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (argc <= 1) { /* If no argument is specified inspect the manager itself */ @@ -904,7 +904,7 @@ static int show_seat(int argc, char *argv[], void *userdata) { properties = !strstr(argv[0], "status"); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (argc <= 1) { /* If no argument is specified inspect the manager itself */ @@ -1219,7 +1219,7 @@ static int help(int argc, char *argv[], void *userdata) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = terminal_urlify_man("loginctl", "1", &link); if (r < 0) diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index d18374dda0..9a0fbc198c 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -273,7 +273,7 @@ static int list_machines(int argc, char *argv[], void *userdata) { assert(bus); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = bus_call_method(bus, bus_machine_mgr, "ListMachines", &error, &reply, NULL); if (r < 0) @@ -352,7 +352,7 @@ static int list_images(int argc, char *argv[], void *userdata) { assert(bus); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = bus_call_method(bus, bus_machine_mgr, "ListImages", &error, &reply, NULL); if (r < 0) @@ -705,7 +705,7 @@ static int show_machine(int argc, char *argv[], void *userdata) { properties = !strstr(argv[0], "status"); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (properties && argc <= 1) { @@ -1004,7 +1004,7 @@ static int show_image(int argc, char *argv[], void *userdata) { properties = !strstr(argv[0], "status"); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (argc <= 1) { @@ -2251,7 +2251,7 @@ static int list_transfers(int argc, char *argv[], void *userdata) { double progress; int r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = bus_call_method(bus, bus_import_mgr, "ListTransfers", &error, &reply, NULL); if (r < 0) @@ -2446,7 +2446,7 @@ static int help(int argc, char *argv[], void *userdata) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = terminal_urlify_man("machinectl", "1", &link); if (r < 0) diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c index d8034202dc..ad68e8c070 100644 --- a/src/mount/mount-tool.c +++ b/src/mount/mount-tool.c @@ -1432,7 +1432,7 @@ static int list_devices(void) { } } - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = table_print(table, NULL); if (r < 0) diff --git a/src/network/networkctl.c b/src/network/networkctl.c index 0ec01dc11e..6dd05145c9 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -810,7 +810,7 @@ static int list_links(int argc, char *argv[], void *userdata) { if (c < 0) return c; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); table = table_new("idx", "link", "type", "operational", "setup"); if (!table) @@ -2394,7 +2394,7 @@ static int link_status(int argc, char *argv[], void *userdata) { return dump_link_description(strv_skip(argv, 1)); } - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = sd_bus_open_system(&bus); if (r < 0) @@ -2493,7 +2493,7 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) { if (c < 0) return c; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); table = table_new("link", "chassis id", diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 3727d90398..a5f5a1ccc8 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -304,7 +304,7 @@ static int help(void) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = terminal_urlify_man("systemd-nspawn", "1", &link); if (r < 0) diff --git a/src/oom/oomctl.c b/src/oom/oomctl.c index 1836dc1014..2ffb9d4d19 100644 --- a/src/oom/oomctl.c +++ b/src/oom/oomctl.c @@ -16,7 +16,7 @@ static int help(int argc, char *argv[], void *userdata) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = terminal_urlify_man("oomctl", "1", &link); if (r < 0) @@ -52,7 +52,7 @@ static int dump_state(int argc, char *argv[], void *userdata) { if (r < 0) return log_error_errno(r, "Failed to connect system bus: %m"); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = sd_bus_call_method( bus, diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c index ec625161a4..dda6b9c1ef 100644 --- a/src/portable/portablectl.c +++ b/src/portable/portablectl.c @@ -333,7 +333,7 @@ static int inspect_image(int argc, char *argv[], void *userdata) { if (r < 0) return bus_log_parse_error(r); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (arg_cat) { printf("%s-- OS Release: --%s\n", ansi_highlight(), ansi_normal()); @@ -1093,7 +1093,7 @@ static int help(int argc, char *argv[], void *userdata) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = terminal_urlify_man("portablectl", "1", &link); if (r < 0) diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c index 99876dbdf6..20455bf7a9 100644 --- a/src/resolve/resolvectl.c +++ b/src/resolve/resolvectl.c @@ -1587,7 +1587,7 @@ static int status_ifindex(sd_bus *bus, int ifindex, const char *name, StatusMode if (r < 0) return log_error_errno(r, "Failed to get link data for %i: %s", ifindex, bus_error_message(&error, r)); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (mode == STATUS_DNS) return status_print_strv_ifindex(ifindex, name, link_info.dns_ex ?: link_info.dns); @@ -1851,7 +1851,7 @@ static int status_global(sd_bus *bus, StatusMode mode, bool *empty_line) { if (r < 0) return log_error_errno(r, "Failed to get global data: %s", bus_error_message(&error, r)); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (mode == STATUS_DNS) return status_print_strv_global(global_info.dns_ex ?: global_info.dns); diff --git a/src/shared/format-table.c b/src/shared/format-table.c index 81a7949a7f..08e0146a91 100644 --- a/src/shared/format-table.c +++ b/src/shared/format-table.c @@ -2783,7 +2783,7 @@ int table_print_with_pager( * the table header and logs about any error. */ if (json_format_flags & (JSON_FORMAT_OFF|JSON_FORMAT_PRETTY|JSON_FORMAT_PRETTY_AUTO)) - (void) pager_open(pager_flags); + pager_open(pager_flags); saved_header = t->header; t->header = show_header; diff --git a/src/shared/pager.c b/src/shared/pager.c index 90c347f8c0..526cb7c6c9 100644 --- a/src/shared/pager.c +++ b/src/shared/pager.c @@ -83,23 +83,23 @@ static int no_quit_on_interrupt(int exe_name_fd, const char *less_opts) { return r; } -int pager_open(PagerFlags flags) { +void pager_open(PagerFlags flags) { _cleanup_close_pair_ int fd[2] = { -1, -1 }, exe_name_pipe[2] = { -1, -1 }; _cleanup_strv_free_ char **pager_args = NULL; const char *pager, *less_opts; int r; if (flags & PAGER_DISABLE) - return 0; + return; if (pager_pid > 0) - return 1; + return; if (terminal_is_dumb()) - return 0; + return; if (!is_main_thread()) - return log_error_errno(SYNTHETIC_ERRNO(EPERM), "Pager invoked from wrong thread."); + return (void) log_error_errno(SYNTHETIC_ERRNO(EPERM), "Pager invoked from wrong thread."); pager = getenv("SYSTEMD_PAGER"); if (!pager) @@ -108,11 +108,11 @@ int pager_open(PagerFlags flags) { if (pager) { pager_args = strv_split(pager, WHITESPACE); if (!pager_args) - return log_oom(); + return (void) log_oom(); /* If the pager is explicitly turned off, honour it */ if (strv_isempty(pager_args) || strv_equal(pager_args, STRV_MAKE("cat"))) - return 0; + return; } /* Determine and cache number of columns/lines before we spawn the pager so that we get the value from the @@ -121,11 +121,11 @@ int pager_open(PagerFlags flags) { (void) lines(); if (pipe2(fd, O_CLOEXEC) < 0) - return log_error_errno(errno, "Failed to create pager pipe: %m"); + return (void) log_error_errno(errno, "Failed to create pager pipe: %m"); /* This is a pipe to feed the name of the executed pager binary into the parent */ if (pipe2(exe_name_pipe, O_CLOEXEC) < 0) - return log_error_errno(errno, "Failed to create exe_name pipe: %m"); + return (void) log_error_errno(errno, "Failed to create exe_name pipe: %m"); /* Initialize a good set of less options */ less_opts = getenv("SYSTEMD_LESS"); @@ -137,7 +137,7 @@ int pager_open(PagerFlags flags) { /* We set SIGINT as PR_DEATHSIG signal here, to match the "K" parameter we set in $LESS, which enables SIGINT behaviour. */ r = safe_fork("(pager)", FORK_RESET_SIGNALS|FORK_DEATHSIG_SIGINT|FORK_RLIMIT_NOFILE_SAFE|FORK_LOG, &pager_pid); if (r < 0) - return r; + return; if (r == 0) { const char *less_charset, *exe; @@ -245,26 +245,22 @@ int pager_open(PagerFlags flags) { stored_stdout = fcntl(STDOUT_FILENO, F_DUPFD_CLOEXEC, 3); if (dup2(fd[1], STDOUT_FILENO) < 0) { stored_stdout = safe_close(stored_stdout); - return log_error_errno(errno, "Failed to duplicate pager pipe: %m"); + return (void) log_error_errno(errno, "Failed to duplicate pager pipe: %m"); } stdout_redirected = true; stored_stderr = fcntl(STDERR_FILENO, F_DUPFD_CLOEXEC, 3); if (dup2(fd[1], STDERR_FILENO) < 0) { stored_stderr = safe_close(stored_stderr); - return log_error_errno(errno, "Failed to duplicate pager pipe: %m"); + return (void) log_error_errno(errno, "Failed to duplicate pager pipe: %m"); } stderr_redirected = true; exe_name_pipe[1] = safe_close(exe_name_pipe[1]); r = no_quit_on_interrupt(TAKE_FD(exe_name_pipe[0]), less_opts); - if (r < 0) - return r; if (r > 0) (void) ignore_signals(SIGINT); - - return 1; } void pager_close(void) { diff --git a/src/shared/pager.h b/src/shared/pager.h index b3b1b4f6b0..9a9d4c53c3 100644 --- a/src/shared/pager.h +++ b/src/shared/pager.h @@ -10,7 +10,7 @@ typedef enum PagerFlags { PAGER_JUMP_TO_END = 1 << 1, } PagerFlags; -int pager_open(PagerFlags flags); +void pager_open(PagerFlags flags); void pager_close(void); bool pager_have(void) _pure_; diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c index 8c452854b1..408ac3b8be 100644 --- a/src/sysctl/sysctl.c +++ b/src/sysctl/sysctl.c @@ -410,7 +410,7 @@ static int run(int argc, char *argv[]) { return log_error_errno(r, "Failed to enumerate sysctl.d files: %m"); if (arg_cat_config) { - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); return cat_files(NULL, files, 0); } diff --git a/src/systemctl/systemctl-edit.c b/src/systemctl/systemctl-edit.c index 87650850fe..2503bddb96 100644 --- a/src/systemctl/systemctl-edit.c +++ b/src/systemctl/systemctl-edit.c @@ -54,7 +54,7 @@ int cat(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); STRV_FOREACH(name, names) { _cleanup_free_ char *fragment_path = NULL; diff --git a/src/systemctl/systemctl-list-dependencies.c b/src/systemctl/systemctl-list-dependencies.c index 5d19f338d8..a536240a9f 100644 --- a/src/systemctl/systemctl-list-dependencies.c +++ b/src/systemctl/systemctl-list-dependencies.c @@ -157,7 +157,7 @@ int list_dependencies(int argc, char *argv[], void *userdata) { return log_error_errno(r, "Failed to expand names: %m"); } - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); STRV_FOREACH(u, units) { if (u != units) diff --git a/src/systemctl/systemctl-list-jobs.c b/src/systemctl/systemctl-list-jobs.c index a050e09c17..1a39416d39 100644 --- a/src/systemctl/systemctl-list-jobs.c +++ b/src/systemctl/systemctl-list-jobs.c @@ -73,7 +73,7 @@ static int output_jobs_list(sd_bus *bus, const struct job_info* jobs, unsigned n return 0; } - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); table = table_new("job", "unit", "type", "state"); if (!table) @@ -168,7 +168,7 @@ int list_jobs(int argc, char *argv[], void *userdata) { if (r < 0) return bus_log_parse_error(r); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); return output_jobs_list(bus, jobs, c, skipped); } diff --git a/src/systemctl/systemctl-list-machines.c b/src/systemctl/systemctl-list-machines.c index 1a2f2d7153..b4eb0bd4b6 100644 --- a/src/systemctl/systemctl-list-machines.c +++ b/src/systemctl/systemctl-list-machines.c @@ -232,7 +232,7 @@ int list_machines(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); typesafe_qsort(machine_infos, r, compare_machine_info); rc = output_machines_list(machine_infos, r); diff --git a/src/systemctl/systemctl-list-unit-files.c b/src/systemctl/systemctl-list-unit-files.c index fd10e7965b..a729171ded 100644 --- a/src/systemctl/systemctl-list-unit-files.c +++ b/src/systemctl/systemctl-list-unit-files.c @@ -255,7 +255,7 @@ int list_unit_files(int argc, char *argv[], void *userdata) { return bus_log_parse_error(r); } - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); typesafe_qsort(units, c, compare_unit_file_list); r = output_unit_file_list(units, c); diff --git a/src/systemctl/systemctl-list-units.c b/src/systemctl/systemctl-list-units.c index 1efb569971..0c405fb7e8 100644 --- a/src/systemctl/systemctl-list-units.c +++ b/src/systemctl/systemctl-list-units.c @@ -221,7 +221,7 @@ int list_units(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); if (arg_with_dependencies) { _cleanup_strv_free_ char **names = NULL; @@ -439,7 +439,7 @@ int list_sockets(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = expand_unit_names(bus, strv_skip(argv, 1), ".socket", &sockets_with_suffix, NULL); if (r < 0) @@ -703,7 +703,7 @@ int list_timers(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = expand_unit_names(bus, strv_skip(argv, 1), ".timer", &timers_with_suffix, NULL); if (r < 0) diff --git a/src/systemctl/systemctl-set-environment.c b/src/systemctl/systemctl-set-environment.c index a19e031dd3..4c8d1acba1 100644 --- a/src/systemctl/systemctl-set-environment.c +++ b/src/systemctl/systemctl-set-environment.c @@ -36,7 +36,7 @@ int show_environment(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = bus_get_property(bus, bus_systemd_mgr, "Environment", &error, &reply, "as"); if (r < 0) diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c index 6166260d10..35c1235a83 100644 --- a/src/systemctl/systemctl-show.c +++ b/src/systemctl/systemctl-show.c @@ -2036,7 +2036,7 @@ static int show_all( if (r < 0) return r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); c = (unsigned) r; @@ -2142,7 +2142,7 @@ int show(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); /* If no argument is specified inspect the manager itself */ if (show_mode == SYSTEMCTL_SHOW_PROPERTIES && argc <= 1) diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index e2a8aef114..6f76a63165 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -128,7 +128,7 @@ static int systemctl_help(void) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = terminal_urlify_man("systemctl", "1", &link); if (r < 0) diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index fafdef1706..106a602305 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -1807,7 +1807,7 @@ static int cat_config(void) { if (r < 0) return r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); return cat_files(NULL, files, 0); } diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c index d9767ba564..78987df8e3 100644 --- a/src/timedate/timedatectl.c +++ b/src/timedate/timedatectl.c @@ -315,7 +315,7 @@ static int list_timezones(int argc, char **argv, void *userdata) { if (r < 0) return bus_log_parse_error(r); - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); strv_print(zones); return 0; diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 6b2f75e248..56a332326f 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -3754,7 +3754,7 @@ static int run(int argc, char *argv[]) { } if (arg_cat_config) { - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); return cat_config(config_dirs, argv + optind); } diff --git a/src/userdb/userdbctl.c b/src/userdb/userdbctl.c index 33c8caa42f..b0ee3ce258 100644 --- a/src/userdb/userdbctl.c +++ b/src/userdb/userdbctl.c @@ -574,7 +574,7 @@ static int help(int argc, char *argv[], void *userdata) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_pager_flags); + pager_open(arg_pager_flags); r = terminal_urlify_man("userdbctl", "1", &link); if (r < 0) -- cgit v1.2.3