mirror of
https://github.com/systemd/systemd.git
synced 2024-10-31 07:51:21 +03:00
tree-wide: add FORMAT_BYTES_FULL()
This commit is contained in:
parent
3c90437083
commit
46e23f9a8d
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user