From 060c9c02d8231b8b5780a147c61b4f1769b1be72 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 20 Jan 2023 13:16:19 +0100 Subject: [PATCH] time-util: use IN_SET() more --- src/basic/time-util.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) 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 */ -- 2.47.3