]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: print error if table_print() fails
authorZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Fri, 3 Apr 2026 09:49:30 +0000 (11:49 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Fri, 3 Apr 2026 11:05:03 +0000 (13:05 +0200)
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.

39 files changed:
src/ac-power/ac-power.c
src/analyze/analyze-calendar.c
src/analyze/analyze-image-policy.c
src/analyze/analyze-inspect-elf.c
src/analyze/analyze-timespan.c
src/analyze/analyze-timestamp.c
src/ask-password/ask-password.c
src/binfmt/binfmt.c
src/bless-boot/bless-boot.c
src/cryptenroll/cryptenroll-list.c
src/detect-virt/detect-virt.c
src/dissect/dissect.c
src/factory-reset/factory-reset-tool.c
src/hostname/hostnamectl.c
src/id128/id128.c
src/imds/imds-tool.c
src/locale/localectl.c
src/login/loginctl.c
src/network/networkctl-address-label.c
src/network/networkctl-list.c
src/network/networkctl-lldp.c
src/network/networkctl-status-link.c
src/network/networkctl-status-system.c
src/notify/notify.c
src/portable/portablectl.c
src/report/report-basic-server.c
src/resolve/resolvectl.c
src/shared/format-table.c
src/shared/format-table.h
src/shared/libfido2-util.c
src/shared/parse-argument.c
src/shared/pkcs11-util.c
src/shared/tpm2-util.c
src/systemctl/systemctl-list-jobs.c
src/timedate/timedatectl.c
src/update-done/update-done.c
src/validatefs/validatefs.c
src/varlinkctl/varlinkctl.c
src/vpick/vpick-tool.c

index b153194cdbf7eefe859b78ad0dc1a651cb466120..dad4384ada74c93f2cf121268b4a8de35ee35614 100644 (file)
@@ -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;
index ea99f3871e85f1efe280e417cae8c432b6a1aea0..c1427f25aabf221921397ae345489fd932b934b9 100644 (file)
@@ -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) {
index 16e69414c125061663dc3cf294115527bbae0771..220716878a5243973b4dd620c82f9178bfc901b4 100644 (file)
@@ -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;
         }
index f4fcc3bd5708943590a1a91944e471e0960d14d3..c664aea588673ddaba173cb7621cbf1619ecd30a 100644 (file)
@@ -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;
                 }
         }
 
index b6ca7bb4af4dfbc116457ef126b845c4a98776a7..31a201c5f6c5dfa7169e12275d10fce1141d671d 100644 (file)
@@ -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;
 
index d998ca830a20a581f73b887bd0e9dc3e120c8ebe..5d4fa2f6250f596557691baba507b5cd5d60f440 100644 (file)
@@ -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) {
index 2ed2be8afee313cff13e9ecbff57b3eaebe1934d..4bd618b2a7f09c104a12cec206e6069cca606bc8 100644 (file)
@@ -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;
index 06fff811bfb2f2eb86f6a93b4deae98d6df141a8..f8c2b55595e07f1edc120693e636fcbfb71aab3b 100644 (file)
@@ -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;
index 67da021f2966038d419de2db519eaff2f56c0cd3..86525f359a102afa2f581b0aefccb1b6925c6c53 100644 (file)
@@ -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;
index bf9f2a130e94aa2d66a2019e55871afa8eba229e..bca9f74c3ab020da42cac025b01ba32904ac2122 100644 (file)
@@ -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);
 }
index a8b9739a925d3b6ad5407594776f8a8a130beb59..3c5b3dd39cb3483ca3cb0e8452c352bf40d8d5cd 100644 (file)
@@ -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;
index 91ad3a4502676a93a31eb7da2cfcbd118317ecf0..ceaedb262fd71bebbb9367cf0cb27ec8fc060a39 100644 (file)
@@ -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;
 
index c09369e22936aa975defd2e7e18dda572718fdad..ec3f7e43c492b1c19dfbdb7cb5a0af0cf6774f8a 100644 (file)
@@ -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;
index 52b31a58679ed66bdae65365640b2eeb7041c8d8..67e82c1e7c0283aaff40cda5c2c46a875ee0f0f6 100644 (file)
@@ -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;
index eda117aec0c4e799f7bf6a6e5f92a8065cc04ba5..1616bfea65bbe5af363d16475db44ee0b72b6d3e 100644 (file)
@@ -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;
index 61fc82014e8076a833ff201d1f543c945db1901a..ff5a9b317af8a3682bbd8a1b3fcbde0c9eada3d8 100644 (file)
@@ -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 chardetect_json_object(const char *text) {
         assert(text);
 
         /* Checks if the provided text looks like a JSON object. It checks if the first non-whitespace
index b67a67e73b7d1fcf1a44955841210ec62e80d7f0..e80cd96c86ee8e02cb369a1d99032b0b4bb676b0 100644 (file)
@@ -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) {
index fa1c02448124bb33dc99dafa9624b4e4d67aff5c..cdffd79d8ca1270c009435d0371f0afb5e235fc5 100644 (file)
@@ -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);
index 04b6d4d2366142645f1697c6311a36e721eb58a7..c1e2cc09202783ef1e8bebddc670d537895e386d 100644 (file)
@@ -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) {
index c30be4a1dee91245583af4b029c4b852237c9cdc..6f3379e788d801a8b852396772a48bb7679dd290 100644 (file)
@@ -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);
index c91d8fea007158a32d6b78d3f1c69c4af4e6ca9b..009f70e4d7fc0a57ca764e19efe3166925afbf0b 100644 (file)
@@ -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);
index 9cbf3efb33210b27a3be0ac1967ee2b39b7c60a8..15c9c46336b3a1cb69a3a39706f2a40124413455 100644 (file)
@@ -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);
 }
index ce403d60624e34514d5db65c47787bff85954108..a03004b882aad40725a60380ee7ea3c7138c4e49 100644 (file)
@@ -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);
 }
index e425a125ac3ae12529649eed3bd410b7f519cd98..2ac0129bae1051e4217b1f714e457ebc4cd24934 100644 (file)
@@ -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;
index f5ce3db9c41e370781242a3e1b46e347343939a8..7c2cbf3e52b3ab87da9c1bb163fe75fb8c72134e 100644 (file)
@@ -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) {
index dc482a37ff0ba70e737afb616964cb5403a4bc80..ea82dbd42fe267c675bf7c8c50ce659fcbf1cf4f 100644 (file)
@@ -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[]) {
index fe2b676c7c0dc81a8fc4c33a4ff52d1d88f6200b..8cc9e73f93cd527aea6422516b1a9436e43cefaa 100644 (file)
@@ -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) {
index 718d5c09b860a1f3c8a45c1a3c2c9280500bd5f9..8c8bcb1bdcbfe067d4fad56bb030aa2f57667733 100644 (file)
@@ -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;
index ee4007394ef0f5723ae9b30fe31b0f0a24a9a7aa..0f52f80293d2e64750217cde0b2ea229a6f84f85 100644 (file)
@@ -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);
 
index 7e50d0dd2df570427dddbca733d9a75faaa37826..6224ad4b1d2c6a868616460e21275f0e6ad1b544 100644 (file)
@@ -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"
index 6ac42c4d88407cde7bd3290bbf01e50211f4bf97..e85c78a47694dd56a2d8376fc1bcd9293b864125 100644 (file)
@@ -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);
index 2d8ce29b5803e7a25847e2268c5c7723bd89ff30..3144d0b3da90c9c521580a4321488a1fd7f654c7 100644 (file)
@@ -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.");
index a1f05d6397c5eb340e8742a0415ef3e64fc55090..78ff47afe87447f22f7fc4fcc58dbc3447891cd3 100644 (file)
@@ -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.");
index bf3f5ed8662aad4d44f36ac97f53a21b206402de..e5ad25234f628535fce7d49bdd2f12a541eb8e46 100644 (file)
@@ -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();
index 93a5dd6da359b2eab71981ac72593f5e593d43ad..d02cb80bb1dab81ae5efb43420e0280e4169c038 100644 (file)
@@ -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) {
index f076f263a6880d4ce895ab55e227825691f3e75a..bc678b8f419885fd61a044469a50f6c209a4a417 100644 (file)
@@ -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;
index 0608a1489520baea445a110216b5fbf1a4bba797..1106eaf1fe991bc77713619a4ec52386b95bb39f 100644 (file)
@@ -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;
index 2d610db4e5500ed3a5a0ad01efb1c6811f5b51f3..4124d0d570726976b4792609028fbb83cb9e7ae5 100644 (file)
@@ -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) {
index 1f3277da45e6d308a2bf92c979c3b574f7b6a419..57df857c6a42dcdb6d86928cc3e4de795db73d75 100644 (file)
@@ -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;
                 }