diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2013-06-28 01:33:47 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-06-28 01:33:47 +0200 |
commit | 26a7e2ecbf76db06cf0754a0664eaa68e3cae53a (patch) | |
tree | a129e196bd1dfc8f40461064c08bb7b4e0533020 | |
parent | 59f46676a9c03303809f40d1a27c4d2e9e640697 (diff) | |
download | busybox-w32-26a7e2ecbf76db06cf0754a0664eaa68e3cae53a.tar.gz busybox-w32-26a7e2ecbf76db06cf0754a0664eaa68e3cae53a.tar.bz2 busybox-w32-26a7e2ecbf76db06cf0754a0664eaa68e3cae53a.zip |
ping: code shrink
function old new delta
unpack_tail 262 243 -19
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/ping.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/networking/ping.c b/networking/ping.c index 8c08c8074..f27e2143d 100644 --- a/networking/ping.c +++ b/networking/ping.c | |||
@@ -372,7 +372,7 @@ struct globals { | |||
372 | struct sockaddr_in6 sin6; | 372 | struct sockaddr_in6 sin6; |
373 | #endif | 373 | #endif |
374 | } pingaddr; | 374 | } pingaddr; |
375 | char rcvd_tbl[MAX_DUP_CHK / 8]; | 375 | unsigned char rcvd_tbl[MAX_DUP_CHK / 8]; |
376 | } FIX_ALIASING; | 376 | } FIX_ALIASING; |
377 | #define G (*(struct globals*)&bb_common_bufsiz1) | 377 | #define G (*(struct globals*)&bb_common_bufsiz1) |
378 | #define if_index (G.if_index ) | 378 | #define if_index (G.if_index ) |
@@ -402,13 +402,11 @@ void BUG_ping_globals_too_big(void); | |||
402 | } while (0) | 402 | } while (0) |
403 | 403 | ||
404 | 404 | ||
405 | #define A(bit) rcvd_tbl[(bit)>>3] /* identify byte in array */ | 405 | #define BYTE(bit) rcvd_tbl[(bit)>>3] |
406 | #define B(bit) (1 << ((bit) & 0x07)) /* identify bit in byte */ | 406 | #define MASK(bit) (1 << ((bit) & 7)) |
407 | #define SET(bit) (A(bit) |= B(bit)) | 407 | #define SET(bit) (BYTE(bit) |= MASK(bit)) |
408 | #define CLR(bit) (A(bit) &= (~B(bit))) | 408 | #define CLR(bit) (BYTE(bit) &= (~MASK(bit))) |
409 | #define TST(bit) (A(bit) & B(bit)) | 409 | #define TST(bit) (BYTE(bit) & MASK(bit)) |
410 | |||
411 | /**************************************************************************/ | ||
412 | 410 | ||
413 | static void print_stats_and_exit(int junk) NORETURN; | 411 | static void print_stats_and_exit(int junk) NORETURN; |
414 | static void print_stats_and_exit(int junk UNUSED_PARAM) | 412 | static void print_stats_and_exit(int junk UNUSED_PARAM) |
@@ -578,11 +576,10 @@ static void unpack_tail(int sz, uint32_t *tp, | |||
578 | const char *from_str, | 576 | const char *from_str, |
579 | uint16_t recv_seq, int ttl) | 577 | uint16_t recv_seq, int ttl) |
580 | { | 578 | { |
579 | unsigned char *b, m; | ||
581 | const char *dupmsg = " (DUP!)"; | 580 | const char *dupmsg = " (DUP!)"; |
582 | unsigned triptime = triptime; /* for gcc */ | 581 | unsigned triptime = triptime; /* for gcc */ |
583 | 582 | ||
584 | ++G.nreceived; | ||
585 | |||
586 | if (tp) { | 583 | if (tp) { |
587 | /* (int32_t) cast is for hypothetical 64-bit unsigned */ | 584 | /* (int32_t) cast is for hypothetical 64-bit unsigned */ |
588 | /* (doesn't hurt 32-bit real-world anyway) */ | 585 | /* (doesn't hurt 32-bit real-world anyway) */ |
@@ -594,11 +591,15 @@ static void unpack_tail(int sz, uint32_t *tp, | |||
594 | tmax = triptime; | 591 | tmax = triptime; |
595 | } | 592 | } |
596 | 593 | ||
597 | if (TST(recv_seq % MAX_DUP_CHK)) { | 594 | b = &BYTE(recv_seq % MAX_DUP_CHK); |
595 | m = MASK(recv_seq % MAX_DUP_CHK); | ||
596 | /*if TST(recv_seq % MAX_DUP_CHK):*/ | ||
597 | if (*b & m) { | ||
598 | ++G.nrepeats; | 598 | ++G.nrepeats; |
599 | --G.nreceived; | ||
600 | } else { | 599 | } else { |
601 | SET(recv_seq % MAX_DUP_CHK); | 600 | /*SET(recv_seq % MAX_DUP_CHK):*/ |
601 | *b |= m; | ||
602 | ++G.nreceived; | ||
602 | dupmsg += 7; | 603 | dupmsg += 7; |
603 | } | 604 | } |
604 | 605 | ||