From: Zbigniew Jędrzejewski-Szmek Date: Tue, 6 Jul 2021 08:17:16 +0000 (+0200) Subject: tree-wide: add FORMAT_BYTES_FULL() X-Git-Tag: v250-rc1~952^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=46e23f9a8d1f49acc01dd4516f0232db039efb37;p=thirdparty%2Fsystemd.git tree-wide: add FORMAT_BYTES_FULL() --- diff --git a/src/basic/format-util.h b/src/basic/format-util.h index 148a8471027..e802a0bb1c5 100644 --- a/src/basic/format-util.h +++ b/src/basic/format-util.h @@ -84,6 +84,7 @@ static inline char *format_bytes(char *buf, size_t l, uint64_t t) { * see C11 §6.5.2.5, and * https://stackoverflow.com/questions/34880638/compound-literal-lifetime-and-if-blocks */ #define FORMAT_BYTES(t) format_bytes((char[FORMAT_BYTES_MAX]){}, FORMAT_BYTES_MAX, t) +#define FORMAT_BYTES_FULL(t, flag) format_bytes_full((char[FORMAT_BYTES_MAX]){}, FORMAT_BYTES_MAX, t, flag) static inline char *format_bytes_cgroup_protection(char *buf, size_t l, uint64_t t) { if (t == CGROUP_LIMIT_MAX) { diff --git a/src/network/networkctl.c b/src/network/networkctl.c index 9bbfe177b17..0ebb11cefac 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -2121,16 +2121,14 @@ static int link_status_one( } if (info->has_bitrates) { - char tx[FORMAT_BYTES_MAX], rx[FORMAT_BYTES_MAX]; - r = table_add_many(table, TABLE_EMPTY, TABLE_STRING, "Bit Rate (Tx/Rx):"); if (r < 0) return table_log_add_error(r); r = table_add_cell_stringf(table, NULL, "%sbps/%sbps", - format_bytes_full(tx, sizeof tx, info->tx_bitrate, 0), - format_bytes_full(rx, sizeof rx, info->rx_bitrate, 0)); + FORMAT_BYTES_FULL(info->tx_bitrate, 0), + FORMAT_BYTES_FULL(info->rx_bitrate, 0)); if (r < 0) return table_log_add_error(r); }