tree-wide: add FORMAT_BYTES()
This commit is contained in:
@@ -80,6 +80,11 @@ static inline char *format_bytes(char *buf, size_t l, uint64_t t) {
|
||||
return format_bytes_full(buf, l, t, FORMAT_BYTES_USE_IEC | FORMAT_BYTES_BELOW_POINT | FORMAT_BYTES_TRAILING_B);
|
||||
}
|
||||
|
||||
/* Note: the lifetime of the compound literal is the immediately surrounding block,
|
||||
* 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)
|
||||
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user