summaryrefslogtreecommitdiffstats
path: root/usr.bin/ftp
diff options
context:
space:
mode:
authormike <mike@FreeBSD.org>2001-08-30 17:13:15 +0000
committermike <mike@FreeBSD.org>2001-08-30 17:13:15 +0000
commit6c9222dbedbc236f756e3c34b46ef8a1269e785f (patch)
treeeb8195d3aef5d355a250820e133c6d0d3fe5e72f /usr.bin/ftp
parent06adf20e25862e317901321aaa9ae6b6edaa3b41 (diff)
downloadFreeBSD-src-6c9222dbedbc236f756e3c34b46ef8a1269e785f.zip
FreeBSD-src-6c9222dbedbc236f756e3c34b46ef8a1269e785f.tar.gz
Revert the previous delta and apply a better fix which corrects
a check on the final snprintf and reduces duplicated code. Submitted by: brian
Diffstat (limited to 'usr.bin/ftp')
-rw-r--r--usr.bin/ftp/util.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/usr.bin/ftp/util.c b/usr.bin/ftp/util.c
index 3c1d49a..687a84c 100644
--- a/usr.bin/ftp/util.c
+++ b/usr.bin/ftp/util.c
@@ -670,22 +670,16 @@ progressmeter(flag)
if (bytes <= 0 || elapsed <= 0.0 || cursize > filesize) {
n = snprintf(buf + len, sizeof(buf) - len,
" --:-- ETA");
- if (n > 0 && n < sizeof(buf) - len)
- len += n;
} else if (wait.tv_sec >= STALLTIME) {
n = snprintf(buf + len, sizeof(buf) - len,
" - stalled -");
- if (n > 0 && n < sizeof(buf) - len)
- len += n;
} else {
remaining =
((filesize - restart_point) / (bytes / elapsed) - elapsed);
- if (remaining >= 100 * SECSPERHOUR) {
+ if (remaining >= 100 * SECSPERHOUR)
n = snprintf(buf + len, sizeof(buf) - len,
" --:-- ETA");
- if (n > 0 && n < sizeof(buf) - len)
- len += n;
- } else {
+ else {
i = remaining / SECSPERHOUR;
if (i)
n = snprintf(buf + len, sizeof(buf) - len,
@@ -696,10 +690,12 @@ progressmeter(flag)
if (n > 0 && n < sizeof(buf) - len)
len += n;
i = remaining % SECSPERHOUR;
- len += snprintf(buf + len, sizeof(buf) - len,
+ n = snprintf(buf + len, sizeof(buf) - len,
"%02d:%02d ETA", i / 60, i % 60);
}
}
+ if (n > 0 && n < sizeof(buf) - len)
+ len += n;
(void)write(STDOUT_FILENO, buf, len);
if (flag == -1) {
OpenPOWER on IntegriCloud