summaryrefslogtreecommitdiff
path: root/src/shutdown/s6-linux-init-shutdown.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2019-05-06 00:17:12 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2019-05-06 00:17:12 +0000
commitbf3668cdf7327b2e02e734561e6daf9212da8924 (patch)
tree77e4e21d2dbbd9e484251c89819f16831071953d /src/shutdown/s6-linux-init-shutdown.c
parent97967b6276c0f0ae5ae1ac0e706ce43e2727d03a (diff)
downloads6-linux-init-bf3668cdf7327b2e02e734561e6daf9212da8924.tar.xz
fix hpr -w, refactor shutdown
Diffstat (limited to 'src/shutdown/s6-linux-init-shutdown.c')
-rw-r--r--src/shutdown/s6-linux-init-shutdown.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/shutdown/s6-linux-init-shutdown.c b/src/shutdown/s6-linux-init-shutdown.c
index f534944..3e791f1 100644
--- a/src/shutdown/s6-linux-init-shutdown.c
+++ b/src/shutdown/s6-linux-init-shutdown.c
@@ -78,22 +78,19 @@ static inline void parse_hourmin (tain_t *when, char const *s)
when->nano = 0 ;
}
+static void parse_mins (tain_t *when, char const *s)
+{
+ unsigned int mins ;
+ if (!uint0_scan(s, &mins)) dieusage() ;
+ tain_addsec_g(when, mins * 60) ;
+}
+
static inline void parse_time (tain_t *when, char const *s)
{
if (!strcmp(s, "now")) tain_copynow(when) ;
- else if (s[0] == '+')
- {
- unsigned int mins ;
- if (!uint0_scan(s+1, &mins)) dieusage() ;
- tain_addsec_g(when, mins * 60) ;
- }
+ else if (s[0] == '+') parse_mins(when, s+1) ;
else if (strchr(s, ':')) parse_hourmin(when, s) ;
- else
- {
- unsigned int mins ;
- if (!uint0_scan(s, &mins)) dieusage() ;
- tain_addsec_g(when, mins * 60) ;
- }
+ else parse_mins(when, s) ;
}