From: Lennart Poettering Date: Fri, 20 Jan 2023 12:16:19 +0000 (+0100) Subject: time-util: use IN_SET() more X-Git-Tag: v253-rc1~52^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=060c9c02d8231b8b5780a147c61b4f1769b1be72;p=thirdparty%2Fsystemd.git time-util: use IN_SET() more --- diff --git a/src/basic/time-util.c b/src/basic/time-util.c index d5c10571c9b..197c4855524 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 */