From 880c4045e5020e5132b1f6f41ab042f774bdd4a6 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 13 Mar 2013 11:52:34 +0100 Subject: flock: use strtotimeval() from libcommon Signed-off-by: Karel Zak --- sys-utils/flock.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'sys-utils/flock.c') diff --git a/sys-utils/flock.c b/sys-utils/flock.c index 24576b139..0ae8f3bf9 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, -- cgit v1.2.3-55-g7522