From a2932a0d1a5a061e51f91b4834ca631e367fe997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 17 Sep 2017 09:10:03 +0200 Subject: [PATCH] Simplify the if cases for timezone checking Just to reduce the indentation a bit. --- src/basic/calendarspec.c | 19 ++++++++----------- src/basic/time-util.c | 8 ++------ 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/basic/calendarspec.c b/src/basic/calendarspec.c index 0606f0923f..be7328af40 100644 --- a/src/basic/calendarspec.c +++ b/src/basic/calendarspec.c @@ -928,19 +928,16 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) { c->dst = j; } else { const char *last_space; + last_space = strrchr(p, ' '); - - if (last_space != NULL) { - const char *timezone = last_space + 1; - - if (timezone_is_valid(timezone)) { - c->timezone = strdup(timezone); - if (!c->timezone) { - r = -ENOMEM; - goto fail; - } - p = strndupa(p, last_space - p); + if (last_space != NULL && timezone_is_valid(last_space + 1)) { + c->timezone = strdup(last_space + 1); + if (!c->timezone) { + r = -ENOMEM; + goto fail; } + + p = strndupa(p, last_space - p); } } } diff --git a/src/basic/time-util.c b/src/basic/time-util.c index d6acdcea2c..2577088c2f 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -891,12 +891,8 @@ int parse_timestamp(const char *t, usec_t *usec) { pid_t pid; last_space = strrchr(t, ' '); - - if (last_space != NULL) { - if (timezone_is_valid(last_space + 1)) { - timezone = last_space + 1; - } - } + if (last_space != NULL && timezone_is_valid(last_space + 1)) + timezone = last_space + 1; if (timezone == NULL || endswith_no_case(t, " UTC")) return parse_timestamp_impl(t, usec, false);