ping: code shrink
function old new delta unpack_tail 262 243 -19 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
59f46676a9
commit
26a7e2ecbf
@ -372,7 +372,7 @@ struct globals {
|
|||||||
struct sockaddr_in6 sin6;
|
struct sockaddr_in6 sin6;
|
||||||
#endif
|
#endif
|
||||||
} pingaddr;
|
} pingaddr;
|
||||||
char rcvd_tbl[MAX_DUP_CHK / 8];
|
unsigned char rcvd_tbl[MAX_DUP_CHK / 8];
|
||||||
} FIX_ALIASING;
|
} FIX_ALIASING;
|
||||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||||
#define if_index (G.if_index )
|
#define if_index (G.if_index )
|
||||||
@ -402,13 +402,11 @@ void BUG_ping_globals_too_big(void);
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
#define A(bit) rcvd_tbl[(bit)>>3] /* identify byte in array */
|
#define BYTE(bit) rcvd_tbl[(bit)>>3]
|
||||||
#define B(bit) (1 << ((bit) & 0x07)) /* identify bit in byte */
|
#define MASK(bit) (1 << ((bit) & 7))
|
||||||
#define SET(bit) (A(bit) |= B(bit))
|
#define SET(bit) (BYTE(bit) |= MASK(bit))
|
||||||
#define CLR(bit) (A(bit) &= (~B(bit)))
|
#define CLR(bit) (BYTE(bit) &= (~MASK(bit)))
|
||||||
#define TST(bit) (A(bit) & B(bit))
|
#define TST(bit) (BYTE(bit) & MASK(bit))
|
||||||
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
static void print_stats_and_exit(int junk) NORETURN;
|
static void print_stats_and_exit(int junk) NORETURN;
|
||||||
static void print_stats_and_exit(int junk UNUSED_PARAM)
|
static void print_stats_and_exit(int junk UNUSED_PARAM)
|
||||||
@ -578,11 +576,10 @@ static void unpack_tail(int sz, uint32_t *tp,
|
|||||||
const char *from_str,
|
const char *from_str,
|
||||||
uint16_t recv_seq, int ttl)
|
uint16_t recv_seq, int ttl)
|
||||||
{
|
{
|
||||||
|
unsigned char *b, m;
|
||||||
const char *dupmsg = " (DUP!)";
|
const char *dupmsg = " (DUP!)";
|
||||||
unsigned triptime = triptime; /* for gcc */
|
unsigned triptime = triptime; /* for gcc */
|
||||||
|
|
||||||
++G.nreceived;
|
|
||||||
|
|
||||||
if (tp) {
|
if (tp) {
|
||||||
/* (int32_t) cast is for hypothetical 64-bit unsigned */
|
/* (int32_t) cast is for hypothetical 64-bit unsigned */
|
||||||
/* (doesn't hurt 32-bit real-world anyway) */
|
/* (doesn't hurt 32-bit real-world anyway) */
|
||||||
@ -594,11 +591,15 @@ static void unpack_tail(int sz, uint32_t *tp,
|
|||||||
tmax = triptime;
|
tmax = triptime;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TST(recv_seq % MAX_DUP_CHK)) {
|
b = &BYTE(recv_seq % MAX_DUP_CHK);
|
||||||
|
m = MASK(recv_seq % MAX_DUP_CHK);
|
||||||
|
/*if TST(recv_seq % MAX_DUP_CHK):*/
|
||||||
|
if (*b & m) {
|
||||||
++G.nrepeats;
|
++G.nrepeats;
|
||||||
--G.nreceived;
|
|
||||||
} else {
|
} else {
|
||||||
SET(recv_seq % MAX_DUP_CHK);
|
/*SET(recv_seq % MAX_DUP_CHK):*/
|
||||||
|
*b |= m;
|
||||||
|
++G.nreceived;
|
||||||
dupmsg += 7;
|
dupmsg += 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user