diff options
author | Karel Zak | 2013-03-13 11:52:34 +0100 |
---|---|---|
committer | Karel Zak | 2013-03-13 11:52:34 +0100 |
commit | 880c4045e5020e5132b1f6f41ab042f774bdd4a6 (patch) | |
tree | 34eea871720c578148254672e3b98311aaedfb9f /sys-utils/flock.c | |
parent | lib/strutils: add strtotimeval_or_err() (diff) | |
download | kernel-qcow2-util-linux-880c4045e5020e5132b1f6f41ab042f774bdd4a6.tar.gz kernel-qcow2-util-linux-880c4045e5020e5132b1f6f41ab042f774bdd4a6.tar.xz kernel-qcow2-util-linux-880c4045e5020e5132b1f6f41ab042f774bdd4a6.zip |
flock: use strtotimeval() from libcommon
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/flock.c')
-rw-r--r-- | sys-utils/flock.c | 16 |
1 files changed, 4 insertions, 12 deletions
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, |