tree-wide: add FORMAT_BYTES()
This commit is contained in:
+7
-12
@@ -503,8 +503,6 @@ void oomd_update_cgroup_contexts_between_hashmaps(Hashmap *old_h, Hashmap *curr_
|
||||
}
|
||||
|
||||
void oomd_dump_swap_cgroup_context(const OomdCGroupContext *ctx, FILE *f, const char *prefix) {
|
||||
char swap[FORMAT_BYTES_MAX];
|
||||
|
||||
assert(ctx);
|
||||
assert(f);
|
||||
|
||||
@@ -513,7 +511,7 @@ void oomd_dump_swap_cgroup_context(const OomdCGroupContext *ctx, FILE *f, const
|
||||
"%sPath: %s\n"
|
||||
"%s\tSwap Usage: %s\n",
|
||||
strempty(prefix), ctx->path,
|
||||
strempty(prefix), format_bytes(swap, sizeof(swap), ctx->swap_usage));
|
||||
strempty(prefix), FORMAT_BYTES(ctx->swap_usage));
|
||||
else
|
||||
fprintf(f,
|
||||
"%sPath: %s\n"
|
||||
@@ -523,7 +521,7 @@ 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_use[FORMAT_BYTES_MAX], mem_min[FORMAT_BYTES_MAX], mem_low[FORMAT_BYTES_MAX];
|
||||
char mem_min[FORMAT_BYTES_MAX], mem_low[FORMAT_BYTES_MAX];
|
||||
|
||||
assert(ctx);
|
||||
assert(f);
|
||||
@@ -540,7 +538,7 @@ void oomd_dump_memory_pressure_cgroup_context(const OomdCGroupContext *ctx, FILE
|
||||
LOAD_INT(ctx->memory_pressure.avg60), LOAD_FRAC(ctx->memory_pressure.avg60),
|
||||
LOAD_INT(ctx->memory_pressure.avg300), LOAD_FRAC(ctx->memory_pressure.avg300),
|
||||
FORMAT_TIMESPAN(ctx->memory_pressure.total, USEC_PER_SEC),
|
||||
strempty(prefix), format_bytes(mem_use, sizeof(mem_use), ctx->current_memory_usage));
|
||||
strempty(prefix), FORMAT_BYTES(ctx->current_memory_usage));
|
||||
|
||||
if (!empty_or_root(ctx->path))
|
||||
fprintf(f,
|
||||
@@ -555,9 +553,6 @@ void oomd_dump_memory_pressure_cgroup_context(const OomdCGroupContext *ctx, FILE
|
||||
}
|
||||
|
||||
void oomd_dump_system_context(const OomdSystemContext *ctx, FILE *f, const char *prefix) {
|
||||
char mem_used[FORMAT_BYTES_MAX], mem_total[FORMAT_BYTES_MAX];
|
||||
char swap_used[FORMAT_BYTES_MAX], swap_total[FORMAT_BYTES_MAX];
|
||||
|
||||
assert(ctx);
|
||||
assert(f);
|
||||
|
||||
@@ -565,9 +560,9 @@ void oomd_dump_system_context(const OomdSystemContext *ctx, FILE *f, const char
|
||||
"%sMemory: Used: %s Total: %s\n"
|
||||
"%sSwap: Used: %s Total: %s\n",
|
||||
strempty(prefix),
|
||||
format_bytes(mem_used, sizeof(mem_used), ctx->mem_used),
|
||||
format_bytes(mem_total, sizeof(mem_total), ctx->mem_total),
|
||||
FORMAT_BYTES(ctx->mem_used),
|
||||
FORMAT_BYTES(ctx->mem_total),
|
||||
strempty(prefix),
|
||||
format_bytes(swap_used, sizeof(swap_used), ctx->swap_used),
|
||||
format_bytes(swap_total, sizeof(swap_total), ctx->swap_total));
|
||||
FORMAT_BYTES(ctx->swap_used),
|
||||
FORMAT_BYTES(ctx->swap_total));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user