From 1008583c91474091eae5ebd3a55ddd86d41a6e85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 3 Apr 2026 11:49:30 +0200 Subject: [PATCH] tree-wide: print error if table_print() fails We generally want to print an error message if table_print() fails. Add a helper function for this and use it consistently. This does one of the three things depending on the call site: - a no-change reformatting of the code - change from a custom message to the generic one - addition of the error message where previously none was printed In the third case, the actual use impact is very small, since the table formatting is very unlikely to fail. But if it did, we would often return an error without any message whatsoever, which we never want to do. --- src/ac-power/ac-power.c | 4 +++- src/analyze/analyze-calendar.c | 2 +- src/analyze/analyze-image-policy.c | 2 +- src/analyze/analyze-inspect-elf.c | 4 ++-- src/analyze/analyze-timespan.c | 2 +- src/analyze/analyze-timestamp.c | 2 +- src/ask-password/ask-password.c | 4 +++- src/binfmt/binfmt.c | 4 +++- src/bless-boot/bless-boot.c | 8 ++++++-- src/cryptenroll/cryptenroll-list.c | 6 +----- src/detect-virt/detect-virt.c | 4 +++- src/dissect/dissect.c | 12 ++++++++---- src/factory-reset/factory-reset-tool.c | 8 ++++++-- src/hostname/hostnamectl.c | 14 +++++++------- src/id128/id128.c | 8 ++++++-- src/imds/imds-tool.c | 8 ++------ src/locale/localectl.c | 6 +----- src/login/loginctl.c | 12 ++++++------ src/network/networkctl-address-label.c | 6 +----- src/network/networkctl-list.c | 4 ++-- src/network/networkctl-lldp.c | 4 ++-- src/network/networkctl-status-link.c | 4 ++-- src/network/networkctl-status-system.c | 4 ++-- src/notify/notify.c | 4 +++- src/portable/portablectl.c | 4 ++-- src/report/report-basic-server.c | 3 +-- src/resolve/resolvectl.c | 16 ++++------------ src/shared/format-table.c | 9 +++++++++ src/shared/format-table.h | 1 + src/shared/libfido2-util.c | 6 ++---- src/shared/parse-argument.c | 6 +----- src/shared/pkcs11-util.c | 6 +----- src/shared/tpm2-util.c | 6 +----- src/systemctl/systemctl-list-jobs.c | 4 ++-- src/timedate/timedatectl.c | 22 +++++----------------- src/update-done/update-done.c | 4 +++- src/validatefs/validatefs.c | 4 +++- src/varlinkctl/varlinkctl.c | 14 +++++--------- src/vpick/vpick-tool.c | 4 ++-- 39 files changed, 115 insertions(+), 130 deletions(-) diff --git a/src/ac-power/ac-power.c b/src/ac-power/ac-power.c index b153194cdb..dad4384ada 100644 --- a/src/ac-power/ac-power.c +++ b/src/ac-power/ac-power.c @@ -37,7 +37,9 @@ static int help(void) { program_invocation_short_name, ansi_highlight(), ansi_normal()); - table_print(options); + r = table_print_or_warn(options); + if (r < 0) + return r; printf("\nSee the %s for details.\n", link); return 0; diff --git a/src/analyze/analyze-calendar.c b/src/analyze/analyze-calendar.c index ea99f3871e..c1427f25aa 100644 --- a/src/analyze/analyze-calendar.c +++ b/src/analyze/analyze-calendar.c @@ -119,7 +119,7 @@ static int test_calendar_one(usec_t n, const char *p) { n = next; } - return table_print(table); + return table_print_or_warn(table); } int verb_calendar(int argc, char *argv[], uintptr_t _data, void *userdata) { diff --git a/src/analyze/analyze-image-policy.c b/src/analyze/analyze-image-policy.c index 16e69414c1..220716878a 100644 --- a/src/analyze/analyze-image-policy.c +++ b/src/analyze/analyze-image-policy.c @@ -157,7 +157,7 @@ int verb_image_policy(int argc, char *argv[], uintptr_t _data, void *userdata) { putc('\n', stdout); - r = table_print(table); + r = table_print_or_warn(table); if (r < 0) return r; } diff --git a/src/analyze/analyze-inspect-elf.c b/src/analyze/analyze-inspect-elf.c index f4fcc3bd57..c664aea588 100644 --- a/src/analyze/analyze-inspect-elf.c +++ b/src/analyze/analyze-inspect-elf.c @@ -118,9 +118,9 @@ static int analyze_elf(char **filenames, sd_json_format_flags_t json_flags) { if (sd_json_format_enabled(json_flags)) sd_json_variant_dump(package_metadata, json_flags, stdout, NULL); else { - r = table_print(t); + r = table_print_or_warn(t); if (r < 0) - return table_log_print_error(r); + return r; } } diff --git a/src/analyze/analyze-timespan.c b/src/analyze/analyze-timespan.c index b6ca7bb4af..31a201c5f6 100644 --- a/src/analyze/analyze-timespan.c +++ b/src/analyze/analyze-timespan.c @@ -55,7 +55,7 @@ int verb_timespan(int argc, char *argv[], uintptr_t _data, void *userdata) { if (r < 0) return table_log_add_error(r); - r = table_print(table); + r = table_print_or_warn(table); if (r < 0) return r; diff --git a/src/analyze/analyze-timestamp.c b/src/analyze/analyze-timestamp.c index d998ca830a..5d4fa2f625 100644 --- a/src/analyze/analyze-timestamp.c +++ b/src/analyze/analyze-timestamp.c @@ -73,7 +73,7 @@ static int test_timestamp_one(const char *p) { if (r < 0) return table_log_add_error(r); - return table_print(table); + return table_print_or_warn(table); } int verb_timestamp(int argc, char *argv[], uintptr_t _data, void *userdata) { diff --git a/src/ask-password/ask-password.c b/src/ask-password/ask-password.c index 2ed2be8afe..4bd618b2a7 100644 --- a/src/ask-password/ask-password.c +++ b/src/ask-password/ask-password.c @@ -57,7 +57,9 @@ static int help(void) { program_invocation_short_name, ansi_highlight(), ansi_normal()); - table_print(options); + r = table_print_or_warn(options); + if (r < 0) + return r; printf("\nSee the %s for details.\n", link); return 0; diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c index 06fff811bf..f8c2b55595 100644 --- a/src/binfmt/binfmt.c +++ b/src/binfmt/binfmt.c @@ -126,7 +126,9 @@ static int help(void) { program_invocation_short_name, ansi_highlight(), ansi_normal()); - table_print(options); + r = table_print_or_warn(options); + if (r < 0) + return r; printf("\nSee the %s for details.\n", link); return 0; diff --git a/src/bless-boot/bless-boot.c b/src/bless-boot/bless-boot.c index 67da021f29..86525f359a 100644 --- a/src/bless-boot/bless-boot.c +++ b/src/bless-boot/bless-boot.c @@ -58,10 +58,14 @@ static int help(void) { program_invocation_short_name, ansi_highlight(), ansi_normal()); - table_print(verbs); + r = table_print_or_warn(verbs); + if (r < 0) + return r; printf("\nOptions:\n"); - table_print(options); + r = table_print_or_warn(options); + if (r < 0) + return r; printf("\nSee the %s for details.\n", link); return 0; diff --git a/src/cryptenroll/cryptenroll-list.c b/src/cryptenroll/cryptenroll-list.c index bf9f2a130e..bca9f74c3a 100644 --- a/src/cryptenroll/cryptenroll-list.c +++ b/src/cryptenroll/cryptenroll-list.c @@ -125,9 +125,5 @@ int list_enrolled(struct crypt_device *cd) { return 0; } - r = table_print(t); - if (r < 0) - return log_error_errno(r, "Failed to show slot table: %m"); - - return 0; + return table_print_or_warn(t); } diff --git a/src/detect-virt/detect-virt.c b/src/detect-virt/detect-virt.c index a8b9739a92..3c5b3dd39c 100644 --- a/src/detect-virt/detect-virt.c +++ b/src/detect-virt/detect-virt.c @@ -41,7 +41,9 @@ static int help(void) { program_invocation_short_name, ansi_highlight(), ansi_normal()); - table_print(options); + r = table_print_or_warn(options); + if (r < 0) + return r; printf("\nSee the %s for details.\n", link); return 0; diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c index 91ad3a4502..ceaedb262f 100644 --- a/src/dissect/dissect.c +++ b/src/dissect/dissect.c @@ -165,11 +165,15 @@ static int help(void) { ansi_underline(), ansi_normal()); - table_print(options); + r = table_print_or_warn(options); + if (r < 0) + return r; printf("\n%sCommands:%s\n", ansi_underline(), ansi_normal()); - table_print(commands); + r = table_print_or_warn(commands); + if (r < 0) + return r; printf("\nSee the %s for details.\n", link); return 0; @@ -1082,9 +1086,9 @@ static int action_dissect( if (!sd_json_format_enabled(arg_json_format_flags)) { table_set_header(t, arg_legend); - r = table_print(t); + r = table_print_or_warn(t); if (r < 0) - return table_log_print_error(r); + return r; } else { _cleanup_(sd_json_variant_unrefp) sd_json_variant *jt = NULL; diff --git a/src/factory-reset/factory-reset-tool.c b/src/factory-reset/factory-reset-tool.c index c09369e229..ec3f7e43c4 100644 --- a/src/factory-reset/factory-reset-tool.c +++ b/src/factory-reset/factory-reset-tool.c @@ -51,10 +51,14 @@ static int help(void) { program_invocation_short_name, ansi_highlight(), ansi_normal()); - table_print(verbs); + r = table_print_or_warn(verbs); + if (r < 0) + return r; printf("\nOptions:\n"); - table_print(options); + r = table_print_or_warn(options); + if (r < 0) + return r; printf("\nSee the %s for details.\n", link); return 0; diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c index 52b31a5867..67e82c1e7c 100644 --- a/src/hostname/hostnamectl.c +++ b/src/hostname/hostnamectl.c @@ -375,11 +375,7 @@ static int print_status_info(StatusInfo *i) { } } - r = table_print(table); - if (r < 0) - return table_log_print_error(r); - - return 0; + return table_print_or_warn(table); } static int get_one_name(sd_bus *bus, const char* attr, char **ret) { @@ -748,10 +744,14 @@ static int help(void) { program_invocation_short_name, ansi_highlight(), ansi_normal()); - table_print(verbs); + r = table_print_or_warn(verbs); + if (r < 0) + return r; printf("\nOptions:\n"); - table_print(options); + r = table_print_or_warn(options); + if (r < 0) + return r; printf("\nSee the %s for details.\n", link); return 0; diff --git a/src/id128/id128.c b/src/id128/id128.c index eda117aec0..1616bfea65 100644 --- a/src/id128/id128.c +++ b/src/id128/id128.c @@ -216,10 +216,14 @@ static int help(void) { program_invocation_short_name, ansi_highlight(), ansi_normal()); - table_print(verbs); + r = table_print_or_warn(verbs); + if (r < 0) + return r; printf("\nOptions:\n"); - table_print(options); + r = table_print_or_warn(options); + if (r < 0) + return r; printf("\nSee the %s for details.\n", link); return 0; diff --git a/src/imds/imds-tool.c b/src/imds/imds-tool.c index 61fc82014e..ff5a9b317a 100644 --- a/src/imds/imds-tool.c +++ b/src/imds/imds-tool.c @@ -381,14 +381,10 @@ static int action_summary(sd_varlink *link) { if (table_isempty(table)) return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "No well-known IMDS data available."); - r = table_print(table); - if (r < 0) - return table_log_print_error(r); - - return 0; + return table_print_or_warn(table); } -static const char *detect_json_object(const char *text) { +static const char* detect_json_object(const char *text) { assert(text); /* Checks if the provided text looks like a JSON object. It checks if the first non-whitespace diff --git a/src/locale/localectl.c b/src/locale/localectl.c index b67a67e73b..e80cd96c86 100644 --- a/src/locale/localectl.c +++ b/src/locale/localectl.c @@ -144,11 +144,7 @@ static int print_status_info(StatusInfo *i) { return table_log_add_error(r); } - r = table_print(table); - if (r < 0) - return table_log_print_error(r); - - return 0; + return table_print_or_warn(table); } static int verb_show_status(int argc, char *argv[], uintptr_t _data, void *userdata) { diff --git a/src/login/loginctl.c b/src/login/loginctl.c index fa1c024481..cdffd79d8c 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -716,9 +716,9 @@ static int print_session_status_info(sd_bus *bus, const char *path) { /* We don't use the table to show the header, in order to make the width of the column stable. */ printf("%s%s - %s (" UID_FMT ")%s\n", ansi_highlight(), i.id, i.name, i.uid, ansi_normal()); - r = table_print(table); + r = table_print_or_warn(table); if (r < 0) - return table_log_print_error(r); + return r; if (i.scope) { show_unit_cgroup(bus, i.scope, i.leader, /* prefix= */ strrepa(" ", STRLEN("Display: "))); @@ -821,9 +821,9 @@ static int print_user_status_info(sd_bus *bus, const char *path) { printf("%s%s (" UID_FMT ")%s\n", ansi_highlight(), i.name, i.uid, ansi_normal()); - r = table_print(table); + r = table_print_or_warn(table); if (r < 0) - return table_log_print_error(r); + return r; if (i.slice) { show_unit_cgroup(bus, i.slice, /* leader= */ 0, /* prefix= */ strrepa(" ", STRLEN("Sessions: "))); @@ -896,9 +896,9 @@ static int print_seat_status_info(sd_bus *bus, const char *path) { printf("%s%s%s\n", ansi_highlight(), i.id, ansi_normal()); - r = table_print(table); + r = table_print_or_warn(table); if (r < 0) - return table_log_print_error(r); + return r; if (arg_transport == BUS_TRANSPORT_LOCAL) { unsigned c = MAX(LESS_BY(columns(), 21U), 10U); diff --git a/src/network/networkctl-address-label.c b/src/network/networkctl-address-label.c index 04b6d4d236..c1e2cc0920 100644 --- a/src/network/networkctl-address-label.c +++ b/src/network/networkctl-address-label.c @@ -82,11 +82,7 @@ static int dump_address_labels(sd_netlink *rtnl) { return table_log_add_error(r); } - r = table_print(table); - if (r < 0) - return table_log_print_error(r); - - return 0; + return table_print_or_warn(table); } int verb_list_address_labels(int argc, char *argv[], uintptr_t _data, void *userdata) { diff --git a/src/network/networkctl-list.c b/src/network/networkctl-list.c index c30be4a1de..6f3379e788 100644 --- a/src/network/networkctl-list.c +++ b/src/network/networkctl-list.c @@ -79,9 +79,9 @@ int verb_list_links(int argc, char *argv[], uintptr_t _data, void *userdata) { return table_log_add_error(r); } - r = table_print(table); + r = table_print_or_warn(table); if (r < 0) - return table_log_print_error(r); + return r; if (arg_legend) printf("\n%i links listed.\n", c); diff --git a/src/network/networkctl-lldp.c b/src/network/networkctl-lldp.c index c91d8fea00..009f70e4d7 100644 --- a/src/network/networkctl-lldp.c +++ b/src/network/networkctl-lldp.c @@ -303,9 +303,9 @@ int verb_link_lldp_status(int argc, char *argv[], uintptr_t _data, void *userdat } } - r = table_print(table); + r = table_print_or_warn(table); if (r < 0) - return table_log_print_error(r); + return r; if (arg_legend) { lldp_capabilities_legend(all); diff --git a/src/network/networkctl-status-link.c b/src/network/networkctl-status-link.c index 9cbf3efb33..15c9c46336 100644 --- a/src/network/networkctl-status-link.c +++ b/src/network/networkctl-status-link.c @@ -900,9 +900,9 @@ static int link_status_one( on_color_operational, glyph(GLYPH_BLACK_CIRCLE), off_color_operational, info->ifindex, info->name); - r = table_print(table); + r = table_print_or_warn(table); if (r < 0) - return table_log_print_error(r); + return r; return show_logs(info->ifindex, info->name); } diff --git a/src/network/networkctl-status-system.c b/src/network/networkctl-status-system.c index ce403d6062..a03004b882 100644 --- a/src/network/networkctl-status-system.c +++ b/src/network/networkctl-status-system.c @@ -126,9 +126,9 @@ int system_status(sd_netlink *rtnl, sd_hwdb *hwdb) { on_color_operational, glyph(GLYPH_BLACK_CIRCLE), off_color_operational, strna(netifs_joined)); - r = table_print(table); + r = table_print_or_warn(table); if (r < 0) - return table_log_print_error(r); + return r; return show_logs(0, NULL); } diff --git a/src/notify/notify.c b/src/notify/notify.c index e425a125ac..2ac0129bae 100644 --- a/src/notify/notify.c +++ b/src/notify/notify.c @@ -77,7 +77,9 @@ static int help(void) { ansi_highlight(), ansi_normal()); - table_print(options); + r = table_print_or_warn(options); + if (r < 0) + return r; printf("\nSee the %s for details.\n", link); return 0; diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c index f5ce3db9c4..7c2cbf3e52 100644 --- a/src/portable/portablectl.c +++ b/src/portable/portablectl.c @@ -1075,9 +1075,9 @@ static int verb_list_images(int argc, char *argv[], uintptr_t _data, void *userd table_set_header(table, arg_legend); - r = table_print(table); + r = table_print_or_warn(table); if (r < 0) - return table_log_print_error(r); + return r; } if (arg_legend) { diff --git a/src/report/report-basic-server.c b/src/report/report-basic-server.c index dc482a37ff..ea82dbd42f 100644 --- a/src/report/report-basic-server.c +++ b/src/report/report-basic-server.c @@ -47,9 +47,8 @@ static int help(void) { ansi_normal(), ansi_underline(), ansi_normal()); - table_print(options); - return 0; + return table_print_or_warn(options); } static int parse_argv(int argc, char *argv[]) { diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c index fe2b676c7c..8cc9e73f93 100644 --- a/src/resolve/resolvectl.c +++ b/src/resolve/resolvectl.c @@ -1321,11 +1321,7 @@ static int verb_show_statistics(int argc, char *argv[], uintptr_t _data, void *u if (r < 0) return table_log_add_error(r); - r = table_print(table); - if (r < 0) - return table_log_print_error(r); - - return 0; + return table_print_or_warn(table); } static int verb_reset_statistics(int argc, char *argv[], uintptr_t _data, void *userdata) { @@ -1890,9 +1886,9 @@ static int print_configuration(DNSConfiguration *configuration, StatusMode mode, return table_log_add_error(r); } - r = table_print(table); + r = table_print_or_warn(table); if (r < 0) - return table_log_print_error(r); + return r; if (empty_line) *empty_line = true; @@ -3097,11 +3093,7 @@ static int dump_server_state(sd_json_variant *server) { if (r < 0) return table_log_add_error(r); - r = table_print(table); - if (r < 0) - return table_log_print_error(r); - - return 0; + return table_print_or_warn(table); } static int verb_show_server_state(int argc, char *argv[], uintptr_t _data, void *userdata) { diff --git a/src/shared/format-table.c b/src/shared/format-table.c index 718d5c09b8..8c8bcb1bdc 100644 --- a/src/shared/format-table.c +++ b/src/shared/format-table.c @@ -2643,6 +2643,15 @@ int table_print_full(Table *t, FILE *f, bool flush) { return fflush_and_check(f); } +int table_print_or_warn(Table *t) { + int r; + + r = table_print(t); + if (r < 0) + return table_log_print_error(r); + return 0; +} + int table_format(Table *t, char **ret) { _cleanup_(memstream_done) MemStream m = {}; FILE *f; diff --git a/src/shared/format-table.h b/src/shared/format-table.h index ee4007394e..0f52f80293 100644 --- a/src/shared/format-table.h +++ b/src/shared/format-table.h @@ -151,6 +151,7 @@ int table_print_full(Table *t, FILE *f, bool flush); static inline int table_print(Table *t) { return table_print_full(t, /* f= */ NULL, /* flush= */ false); } +int table_print_or_warn(Table *t); int table_format(Table *t, char **ret); diff --git a/src/shared/libfido2-util.c b/src/shared/libfido2-util.c index 7e50d0dd2d..6224ad4b1d 100644 --- a/src/shared/libfido2-util.c +++ b/src/shared/libfido2-util.c @@ -1241,11 +1241,9 @@ int fido2_list_devices(void) { } } - r = table_print(t); - if (r < 0) { - log_error_errno(r, "Failed to show device table: %m"); + r = table_print_or_warn(t); + if (r < 0) goto finish; - } if (!table_isempty(t)) printf("\n" diff --git a/src/shared/parse-argument.c b/src/shared/parse-argument.c index 6ac42c4d88..e85c78a476 100644 --- a/src/shared/parse-argument.c +++ b/src/shared/parse-argument.c @@ -128,11 +128,7 @@ int parse_signal_argument(const char *s, int *ret) { return table_log_add_error(r); } - r = table_print(table); - if (r < 0) - return table_log_print_error(r); - - return 0; + return table_print_or_warn(table); } r = signal_from_string(s); diff --git a/src/shared/pkcs11-util.c b/src/shared/pkcs11-util.c index 2d8ce29b58..3144d0b3da 100644 --- a/src/shared/pkcs11-util.c +++ b/src/shared/pkcs11-util.c @@ -1816,11 +1816,7 @@ int pkcs11_list_tokens(void) { return 0; } - r = table_print(t); - if (r < 0) - return log_error_errno(r, "Failed to show device table: %m"); - - return 0; + return table_print_or_warn(t); #else return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "PKCS#11 tokens not supported on this build."); diff --git a/src/shared/tpm2-util.c b/src/shared/tpm2-util.c index a1f05d6397..78ff47afe8 100644 --- a/src/shared/tpm2-util.c +++ b/src/shared/tpm2-util.c @@ -6584,11 +6584,7 @@ int tpm2_list_devices(bool legend, bool quiet) { return 0; } - r = table_print(t); - if (r < 0) - return log_error_errno(r, "Failed to show device table: %m"); - - return 0; + return table_print_or_warn(t); #else return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "TPM2 not supported on this build."); diff --git a/src/systemctl/systemctl-list-jobs.c b/src/systemctl/systemctl-list-jobs.c index bf3f5ed866..e5ad25234f 100644 --- a/src/systemctl/systemctl-list-jobs.c +++ b/src/systemctl/systemctl-list-jobs.c @@ -115,9 +115,9 @@ static int output_jobs_list(sd_bus *bus, const struct job_info* jobs, unsigned n output_waiting_jobs(bus, table, j->id, "GetJobBefore", "\twaiting for job"); } - r = table_print(table); + r = table_print_or_warn(table); if (r < 0) - return log_error_errno(r, "Failed to print the table: %m"); + return r; if (arg_legend != 0) { on = ansi_highlight(); diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c index 93a5dd6da3..d02cb80bb1 100644 --- a/src/timedate/timedatectl.c +++ b/src/timedate/timedatectl.c @@ -163,9 +163,9 @@ static int print_status_info(const StatusInfo *i) { if (r < 0) return table_log_add_error(r); - r = table_print(table); + r = table_print_or_warn(table); if (r < 0) - return table_log_print_error(r); + return r; if (i->rtc_local) { fflush(stdout); @@ -443,20 +443,12 @@ static int print_ntp_status_info(NTPStatusInfo *i) { if (r < 0) return table_log_add_error(r); - r = table_print(table); - if (r < 0) - return table_log_print_error(r); - - return 0; + return table_print_or_warn(table); } if (i->dest < i->origin || i->trans < i->recv || i->dest - i->origin < i->trans - i->recv) { log_error("Invalid NTP response"); - r = table_print(table); - if (r < 0) - return table_log_print_error(r); - - return 0; + return table_print_or_warn(table); } delay = (i->dest - i->origin) - (i->trans - i->recv); @@ -536,11 +528,7 @@ static int print_ntp_status_info(NTPStatusInfo *i) { return table_log_add_error(r); } - r = table_print(table); - if (r < 0) - return table_log_print_error(r); - - return 0; + return table_print_or_warn(table); } static int map_server_address(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) { diff --git a/src/update-done/update-done.c b/src/update-done/update-done.c index f076f263a6..bc678b8f41 100644 --- a/src/update-done/update-done.c +++ b/src/update-done/update-done.c @@ -82,7 +82,9 @@ static int help(void) { ansi_normal(), ansi_underline(), ansi_normal()); - table_print(options); + r = table_print_or_warn(options); + if (r < 0) + return r; printf("\nSee the %s for details.\n", link); return 0; diff --git a/src/validatefs/validatefs.c b/src/validatefs/validatefs.c index 0608a14895..1106eaf1fe 100644 --- a/src/validatefs/validatefs.c +++ b/src/validatefs/validatefs.c @@ -50,7 +50,9 @@ static int help(void) { program_invocation_short_name, ansi_highlight(), ansi_normal()); - table_print(options); + r = table_print_or_warn(options); + if (r < 0) + return r; printf("\nSee the %s for details.\n", link); return 0; diff --git a/src/varlinkctl/varlinkctl.c b/src/varlinkctl/varlinkctl.c index 2d610db4e5..4124d0d570 100644 --- a/src/varlinkctl/varlinkctl.c +++ b/src/varlinkctl/varlinkctl.c @@ -416,6 +416,8 @@ static int verb_info(int argc, char *argv[], uintptr_t _data, void *userdata) { if (streq_ptr(argv[0], "list-interfaces")) { STRV_FOREACH(i, data.interfaces) puts(*i); + + return 0; } else { _cleanup_(table_unrefp) Table *t = NULL; @@ -439,20 +441,14 @@ static int verb_info(int argc, char *argv[], uintptr_t _data, void *userdata) { if (r < 0) return table_log_add_error(r); - r = table_print(t); - if (r < 0) - return table_log_print_error(r); + return table_print_or_warn(t); } } else { - sd_json_variant *v; - - v = streq_ptr(argv[0], "list-interfaces") ? + sd_json_variant *v = streq_ptr(argv[0], "list-interfaces") ? sd_json_variant_by_key(reply, "interfaces") : reply; - sd_json_variant_dump(v, arg_json_format_flags, stdout, NULL); + return sd_json_variant_dump(v, arg_json_format_flags, stdout, NULL); } - - return 0; } static size_t break_columns(void) { diff --git a/src/vpick/vpick-tool.c b/src/vpick/vpick-tool.c index 1f3277da45..57df857c6a 100644 --- a/src/vpick/vpick-tool.c +++ b/src/vpick/vpick-tool.c @@ -337,9 +337,9 @@ static int run(int argc, char *argv[]) { return table_log_add_error(r); } - r = table_print(t); + r = table_print_or_warn(t); if (r < 0) - return table_log_print_error(r); + return r; break; }