iproute2: remove useless use of buffer
Subsystems (2)
PATCH 1/1 iproute2: remove useless use of buffer
Print directly to the file instead of going through a buffer.
Signed-off-by Andreas Schwab <[email protected]>
--- ip/ipaddress.c | 16 +++++++--------- 1 files changed, 7 insertions(+), 9 deletions(-)
ip/ipaddress.c +7 -9
@@ -613,23 +613,21 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n,fprintf (fp,"%s" , (char *)RTA_DATA (rta_tb[IFA_LABEL ]));if (rta_tb[IFA_CACHEINFO ]) {struct ifa_cacheinfo *ci =RTA_DATA (rta_tb[IFA_CACHEINFO ]); -char buf[128 ];fprintf (fp,"%s" , _SL_); +fprintf (fp," valid_lft " );if (ci->ifa_valid ==INFINITY_LIFE_TIME ) -sprintf (buf,"valid_lft forever" ); +fprintf (fp,"forever" );else -sprintf (buf,"valid_lft %usec" , ci->ifa_valid); +fprintf (fp,"%usec" , ci->ifa_valid); +fprintf (fp," preferred_lft " );if (ci->ifa_prefered ==INFINITY_LIFE_TIME ) -sprintf (buf+strlen (buf)," preferred_lft forever" ); +fprintf (fp,"forever" );else {if (deprecated) -sprintf (buf+strlen (buf)," preferred_lft %dsec" , - ci->ifa_prefered); +fprintf (fp,"%dsec" , ci->ifa_prefered);else -sprintf (buf+strlen (buf)," preferred_lft %usec" , - ci->ifa_prefered); +fprintf (fp,"%usec" , ci->ifa_prefered); } -fprintf (fp," %s" , buf); }fprintf (fp,"\n" );fflush (fp);
Signature · 7 lines
1.7.3.2 -- Andreas Schwab, [email protected] GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."