diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-01-20 13:16:19 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-01-20 17:40:45 +0100 |
commit | 060c9c02d8231b8b5780a147c61b4f1769b1be72 (patch) | |
tree | b66375f9f2fad81e9478747afde337d11a343ecd /src/basic/time-util.c | |
parent | boot: Properly strip EFI binaries (diff) | |
download | systemd-060c9c02d8231b8b5780a147c61b4f1769b1be72.tar.xz systemd-060c9c02d8231b8b5780a147c61b4f1769b1be72.zip |
time-util: use IN_SET() more
Diffstat (limited to '')
-rw-r--r-- | src/basic/time-util.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/src/basic/time-util.c b/src/basic/time-util.c index d5c10571c9..197c485552 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -308,30 +308,17 @@ char *format_timestamp_style( }; struct tm tm; + bool utc, us; time_t sec; size_t n; - bool utc = false, us = false; int r; assert(buf); + assert(style >= 0); + assert(style < _TIMESTAMP_STYLE_MAX); - switch (style) { - case TIMESTAMP_PRETTY: - case TIMESTAMP_UNIX: - break; - case TIMESTAMP_US: - us = true; - break; - case TIMESTAMP_UTC: - utc = true; - break; - case TIMESTAMP_US_UTC: - us = true; - utc = true; - break; - default: - return NULL; - } + utc = IN_SET(style, TIMESTAMP_UTC, TIMESTAMP_US_UTC); + us = IN_SET(style, TIMESTAMP_US, TIMESTAMP_US_UTC); if (l < (size_t) (3 + /* week day */ 1 + 10 + /* space and date */ |