diff options
author | 2020-07-06 17:11:29 +0000 | |
---|---|---|
committer | 2020-07-06 17:11:29 +0000 | |
commit | 277ea09dcb78f5f937b8b3b77806e9e9a865d28d (patch) | |
tree | f5f2e30055ed1ee8a7b1da383ec81a1aeac5d728 | |
parent | Use mnemonic KERN_PROC_ALL not literal zero (diff) | |
download | wireguard-openbsd-277ea09dcb78f5f937b8b3b77806e9e9a865d28d.tar.xz wireguard-openbsd-277ea09dcb78f5f937b8b3b77806e9e9a865d28d.zip |
in 2014 I added this annotation: /* XXX floating point printf in signal handler */
our snprintf is reentrant safe except for floating point.
Break the double apart into integer.integer notation, to avoid that.
ok kettenis millert
-rw-r--r-- | usr.bin/ftp/util.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.bin/ftp/util.c b/usr.bin/ftp/util.c index d506d93ec2c..d04e650df5c 100644 --- a/usr.bin/ftp/util.c +++ b/usr.bin/ftp/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.92 2019/11/18 04:37:35 deraadt Exp $ */ +/* $OpenBSD: util.c,v 1.93 2020/07/06 17:11:29 deraadt Exp $ */ /* $NetBSD: util.c,v 1.12 1997/08/18 10:20:27 lukem Exp $ */ /*- @@ -921,7 +921,7 @@ void ptransfer(int siginfo) { struct timespec now, td; - double elapsed; + double elapsed, pace; off_t bs; int meg, remaining, hh; char buf[100]; @@ -937,11 +937,13 @@ ptransfer(int siginfo) if (bs > (1024 * 1024)) meg = 1; - /* XXX floating point printf in signal handler */ + pace = bs / (1024.0 * (meg ? 1024.0 : 1.0)); (void)snprintf(buf, sizeof(buf), - "%lld byte%s %s in %.2f seconds (%.2f %sB/s)\n", - (long long)bytes, bytes == 1 ? "" : "s", direction, elapsed, - bs / (1024.0 * (meg ? 1024.0 : 1.0)), meg ? "M" : "K"); + "%lld byte%s %s in %lld.%02d seconds (%lld.%02d %sB/s)\n", + (long long)bytes, bytes == 1 ? "" : "s", direction, + (long long)elapsed, (int)(elapsed * 100.0) % 100, + (long long)pace, (int)(pace * 100.0) % 100, + meg ? "M" : "K"); if (siginfo && bytes > 0 && elapsed > 0.0 && filesize >= 0 && bytes + restart_point <= filesize) { |