From: Zbigniew Jędrzejewski-Szmek Date: Tue, 6 Jul 2021 08:22:03 +0000 (+0200) Subject: Replace format_bytes_cgroup_protection with FORMAT_BYTES_CGROUP_PROTECTION X-Git-Tag: v250-rc1~952^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9ca7e3d00d03cc5cfe42529a4770eebe02d3cca9;p=thirdparty%2Fsystemd.git Replace format_bytes_cgroup_protection with FORMAT_BYTES_CGROUP_PROTECTION --- diff --git a/src/basic/format-util.h b/src/basic/format-util.h index e802a0bb1c5..92bb131a91b 100644 --- a/src/basic/format-util.h +++ b/src/basic/format-util.h @@ -86,10 +86,4 @@ static inline char *format_bytes(char *buf, size_t l, uint64_t t) { #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) { - (void) snprintf(buf, l, "%s", "infinity"); - return buf; - } - return format_bytes(buf, l, t); -} +#define FORMAT_BYTES_CGROUP_PROTECTION(t) (t == CGROUP_LIMIT_MAX ? "infinity" : FORMAT_BYTES(t)) diff --git a/src/oom/oomd-util.c b/src/oom/oomd-util.c index 4bf7db8c3e4..ff0fc13c6fa 100644 --- a/src/oom/oomd-util.c +++ b/src/oom/oomd-util.c @@ -521,8 +521,6 @@ void oomd_dump_swap_cgroup_context(const OomdCGroupContext *ctx, FILE *f, const } void oomd_dump_memory_pressure_cgroup_context(const OomdCGroupContext *ctx, FILE *f, const char *prefix) { - char mem_min[FORMAT_BYTES_MAX], mem_low[FORMAT_BYTES_MAX]; - assert(ctx); assert(f); @@ -546,8 +544,8 @@ void oomd_dump_memory_pressure_cgroup_context(const OomdCGroupContext *ctx, FILE "%s\tMemory Low: %s\n" "%s\tPgscan: %" PRIu64 "\n" "%s\tLast Pgscan: %" PRIu64 "\n", - strempty(prefix), format_bytes_cgroup_protection(mem_min, sizeof(mem_min), ctx->memory_min), - strempty(prefix), format_bytes_cgroup_protection(mem_low, sizeof(mem_low), ctx->memory_low), + strempty(prefix), FORMAT_BYTES_CGROUP_PROTECTION(ctx->memory_min), + strempty(prefix), FORMAT_BYTES_CGROUP_PROTECTION(ctx->memory_low), strempty(prefix), ctx->pgscan, strempty(prefix), ctx->last_pgscan); } diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c index 00b6948cdf7..fa9a9ab7507 100644 --- a/src/systemctl/systemctl-show.c +++ b/src/systemctl/systemctl-show.c @@ -671,16 +671,15 @@ static void print_status_info( i->memory_swap_max != CGROUP_LIMIT_MAX || i->memory_available != CGROUP_LIMIT_MAX || i->memory_limit != CGROUP_LIMIT_MAX) { - char buf[FORMAT_BYTES_MAX]; const char *prefix = ""; printf(" ("); if (i->memory_min > 0) { - printf("%smin: %s", prefix, format_bytes_cgroup_protection(buf, sizeof(buf), i->memory_min)); + printf("%smin: %s", prefix, FORMAT_BYTES_CGROUP_PROTECTION(i->memory_min)); prefix = " "; } if (i->memory_low > 0) { - printf("%slow: %s", prefix, format_bytes_cgroup_protection(buf, sizeof(buf), i->memory_low)); + printf("%slow: %s", prefix, FORMAT_BYTES_CGROUP_PROTECTION(i->memory_low)); prefix = " "; } if (i->memory_high != CGROUP_LIMIT_MAX) {