diff options
author | ume <ume@FreeBSD.org> | 2015-11-04 16:59:12 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2015-11-04 16:59:12 +0000 |
commit | bad3c35c8dd3e3bba0ca4848d8bfc41f745413ca (patch) | |
tree | ec8fb6068fc64291ea033c08b3ce7ef04cad98f0 | |
parent | b59e6c253a635986c32db65cfbfe0fe193110ba8 (diff) | |
download | FreeBSD-src-bad3c35c8dd3e3bba0ca4848d8bfc41f745413ca.zip FreeBSD-src-bad3c35c8dd3e3bba0ca4848d8bfc41f745413ca.tar.gz |
Simplify r290367 using asterisk for a field width
and precision.
-rw-r--r-- | usr.bin/netstat/if.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c index 0ae8645..11bde27 100644 --- a/usr.bin/netstat/if.c +++ b/usr.bin/netstat/if.c @@ -272,7 +272,6 @@ intpr(void (*pfunc)(char *), int af) struct ifaddrs *ifap, *ifa; struct ifmaddrs *ifmap, *ifma; u_int ifn_len_max = 5, ifn_len; - char ifn_hdr_fmt[14], ifn_bdy_fmt[41]; if (interval) return sidewaysintpr(); @@ -295,15 +294,10 @@ intpr(void (*pfunc)(char *), int af) ifn_len_max = MAX(ifn_len_max, ifn_len); } } - snprintf(ifn_hdr_fmt, sizeof(ifn_hdr_fmt), "{T:/%%-%d.%ds}", - ifn_len_max, ifn_len_max); - snprintf(ifn_bdy_fmt, sizeof(ifn_bdy_fmt), - "{etk:name/%%s}{e:flags/0x%%x}{d:/%%-%d.%ds}", ifn_len_max, - ifn_len_max); xo_open_list("interface"); if (!pfunc) { - xo_emit(ifn_hdr_fmt, "Name"); + xo_emit("{T:/%-*.*s}", ifn_len_max, ifn_len_max, "Name"); xo_emit(" {T:/%5.5s} {T:/%-13.13s} {T:/%-17.17s} {T:/%8.8s} " "{T:/%5.5s} {T:/%5.5s}", "Mtu", "Network", "Address", "Ipkts", "Ierrs", "Idrop"); @@ -354,7 +348,8 @@ intpr(void (*pfunc)(char *), int af) } else xname = name; - xo_emit(ifn_bdy_fmt, name, ifa->ifa_flags, xname); + xo_emit("{etk:name/%s}{e:flags/0x%x}{d:/%-*.*s}", + name, ifa->ifa_flags, ifn_len_max, ifn_len_max, xname); #define IFA_MTU(ifa) (((struct if_data *)(ifa)->ifa_data)->ifi_mtu) show_stat("lu", 6, "mtu", IFA_MTU(ifa), IFA_MTU(ifa), 0); |