summaryrefslogtreecommitdiff
path: root/src/basic/format-util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-10-15 17:33:04 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2020-10-20 15:51:48 +0900
commit67bd5620f6cf481c0a59cedbcf63ddcab355cc55 (patch)
treee7aafd7a176377f9c4a1100a7e304ac32f05399f /src/basic/format-util.h
parent0ce8a9d6e54f7ee04946b12fa22b0fb9fc2098f9 (diff)
downloadsystemd-67bd5620f6cf481c0a59cedbcf63ddcab355cc55.tar.gz
util: make size macros unsigned
By making them unsigned comparing them with other sizes is less likely to trigger compiler warnings regarding signed/unsigned comparisons. After all sizes (i.e. size_t) are generally assumed to be unsigned, so these should be too. Prompted-by: https://github.com/systemd/systemd/pull/17345#issuecomment-709402332
Diffstat (limited to 'src/basic/format-util.h')
-rw-r--r--src/basic/format-util.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/basic/format-util.h b/src/basic/format-util.h
index c47fa76ea8..db37c16140 100644
--- a/src/basic/format-util.h
+++ b/src/basic/format-util.h
@@ -72,11 +72,14 @@ typedef enum {
FORMAT_BYTES_TRAILING_B = 1 << 2,
} FormatBytesFlag;
-#define FORMAT_BYTES_MAX 16
+#define FORMAT_BYTES_MAX 16U
+
char *format_bytes_full(char *buf, size_t l, uint64_t t, FormatBytesFlag flag);
+
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);
}
+
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");