networking/interface.c: huke remaining big statics; use malloc for INET[6]_rresolve
return value. Went thru callers and adjusted them - code got smaller too. function old new delta ip_port_str - 126 +126 INET6_rresolve 165 182 +17 static.cache 20 24 +4 route_main 2092 2091 -1 INET_sprint 61 59 -2 INET_nn 4 - -4 INET6_sprint 59 53 -6 udp_do_one 518 508 -10 tcp_do_one 433 423 -10 raw_do_one 494 484 -10 traceroute_main 4117 4105 -12 INET_rresolve 334 321 -13 bb_displayroutes 494 456 -38 snprint_ip_port 244 - -244 static.buff 264 16 -248 ------------------------------------------------------------------------------ (add/remove: 1/2 grow/shrink: 2/10 up/down: 147/-598) Total: -451 bytes size busybox_old busybox_unstripped text data bss dec hex filename 751073 3048 14688 768809 bbb29 busybox_old 750873 3048 14440 768361 bb969 busybox_unstripped
This commit is contained in:
@@ -802,22 +802,20 @@ packet_ok(unsigned char *buf, int cc, struct sockaddr_in *from, int seq)
|
||||
* numeric value, otherwise try for symbolic name.
|
||||
*/
|
||||
static inline void
|
||||
inetname(struct sockaddr_in *from)
|
||||
print_inetname(struct sockaddr_in *from)
|
||||
{
|
||||
const char *n = NULL;
|
||||
const char *ina;
|
||||
char name[257];
|
||||
|
||||
if (!nflag && from->sin_addr.s_addr != INADDR_ANY) {
|
||||
if (INET_rresolve(name, sizeof(name), from, 0x4000,
|
||||
0xffffffff) >= 0)
|
||||
n = name;
|
||||
}
|
||||
ina = inet_ntoa(from->sin_addr);
|
||||
if (nflag)
|
||||
printf(" %s", ina);
|
||||
else
|
||||
else {
|
||||
char *n = NULL;
|
||||
if (from->sin_addr.s_addr != INADDR_ANY)
|
||||
n = xmalloc_sockaddr2host_noport((struct sockaddr*)from, sizeof(*from));
|
||||
printf(" %s (%s)", (n ? n : ina), ina);
|
||||
free(n);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -830,7 +828,7 @@ print(unsigned char *buf, int cc, struct sockaddr_in *from)
|
||||
hlen = ip->ip_hl << 2;
|
||||
cc -= hlen;
|
||||
|
||||
inetname(from);
|
||||
print_inetname(from);
|
||||
#if ENABLE_FEATURE_TRACEROUTE_VERBOSE
|
||||
if (verbose)
|
||||
printf(" %d bytes to %s", cc, inet_ntoa(ip->ip_dst));
|
||||
|
Reference in New Issue
Block a user