From: Karel Zak Date: Wed, 13 Mar 2013 10:52:34 +0000 (+0100) Subject: flock: use strtotimeval() from libcommon X-Git-Tag: v2.23-rc1~67 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=880c4045e5020e5132b1f6f41ab042f774bdd4a6;p=thirdparty%2Futil-linux.git flock: use strtotimeval() from libcommon Signed-off-by: Karel Zak --- diff --git a/sys-utils/flock.c b/sys-utils/flock.c index 24576b1399..0ae8f3bf92 100644 --- a/sys-utils/flock.c +++ b/sys-utils/flock.c @@ -75,17 +75,6 @@ static void timeout_handler(int sig __attribute__((__unused__))) timeout_expired = 1; } -static void strtotimeval(const char *str, struct timeval *tv) -{ - double user_input; - - user_input = strtod_or_err(str, "bad number"); - tv->tv_sec = (time_t) user_input; - tv->tv_usec = (long)((user_input - tv->tv_sec) * 1000000); - if ((tv->tv_sec + tv->tv_usec) == 0) - errx(EX_USAGE, _("timeout cannot be zero")); -} - static void setup_timer(struct itimerval *timer, struct itimerval *old_timer, struct sigaction *sa, struct sigaction *old_sa) { @@ -199,7 +188,10 @@ int main(int argc, char *argv[]) break; case 'w': have_timeout = 1; - strtotimeval(optarg, &timeout.it_value); + strtotimeval_or_err(optarg, &timeout.it_value, + _("invalid timeout value")); + if (timeout.it_value.tv_sec + timeout.it_value.tv_usec == 0) + errx(EX_USAGE, _("timeout cannot be zero")); break; case 'E': conflict_exit_code = strtos32_or_err(optarg,