ping: fix write-after-allocated-mem bug

ping: use monotonic_us instead of gettimeofday: smaller code and
      needs only 4 bytes in the packet
ping: display roundtrip times with 1/1000th of ms, not 1/10 ms precision.
wget: small optimization

function                                             old     new   delta
pingstats                                            243     259     +16
sendping6                                             98      93      -5
sendping4                                            183     178      -5
.rodata                                           129715  129707      -8
progressmeter                                        867     855     -12
unpack_tail                                          320     272     -48
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/5 up/down: 16/-78)            Total: -62 bytes
This commit is contained in:
Denis Vlasenko
2007-06-18 08:55:57 +00:00
parent ebd27aabaa
commit 7679145cfa
2 changed files with 32 additions and 37 deletions

View File

@@ -8,7 +8,7 @@
/* We want libc to give us xxx64 functions also */
/* http://www.unix.org/version2/whatsnew/lfs20mar.html */
#define _LARGEFILE64_SOURCE 1
//#define _LARGEFILE64_SOURCE 1
#include <getopt.h> /* for struct option */
#include "libbb.h"
@@ -710,7 +710,7 @@ progressmeter(int flag)
fprintf(stderr, "\r%-20.20s%4d%% ", curfile, ratio);
barlength = getttywidth() - 51;
barlength = getttywidth() - 49;
if (barlength > 0) {
/* god bless gcc for variable arrays :) */
i = barlength * ratio / 100;
@@ -728,7 +728,7 @@ progressmeter(int flag)
abbrevsize >>= 10;
}
/* see http://en.wikipedia.org/wiki/Tera */
fprintf(stderr, "%6d %c%c ", (int)abbrevsize, " KMGTPEZY"[i], i?'B':' ');
fprintf(stderr, "%6d%c ", (int)abbrevsize, " kMGTPEZY"[i]);
// Nuts! Ain't it easier to update progress meter ONLY when we transferred++?
// FIXME: get rid of alarmtimer + updateprogressmeter mess