From bf3668cdf7327b2e02e734561e6daf9212da8924 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 6 May 2019 00:17:12 +0000 Subject: fix hpr -w, refactor shutdown --- src/shutdown/s6-linux-init-hpr.c | 2 +- src/shutdown/s6-linux-init-shutdown.c | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/shutdown/s6-linux-init-hpr.c b/src/shutdown/s6-linux-init-hpr.c index 7e4859a..886f10b 100644 --- a/src/shutdown/s6-linux-init-hpr.c +++ b/src/shutdown/s6-linux-init-hpr.c @@ -52,7 +52,7 @@ int main (int argc, char const *const *argv) case 'r' : what = 3 ; break ; case 'f' : force = 1 ; break ; case 'd' : dowtmp = 0 ; break ; - case 'w' : dowtmp = 1 ; break ; + case 'w' : dowtmp = 2 ; break ; case 'W' : dowall = 0 ; break ; default : strerr_dieusage(100, USAGE) ; } 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) ; } -- cgit v1.2.3