Commit f66efadd authored by Andreas Schwab's avatar Andreas Schwab Committed by Stephen Hemminger

iproute2: remove useless use of buffer

Print directly to the file instead of going through a buffer.
Signed-off-by: default avatarAndreas Schwab <schwab@linux-m68k.org>
parent 7162c921
...@@ -613,23 +613,21 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n, ...@@ -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])); fprintf(fp, "%s", (char*)RTA_DATA(rta_tb[IFA_LABEL]));
if (rta_tb[IFA_CACHEINFO]) { if (rta_tb[IFA_CACHEINFO]) {
struct ifa_cacheinfo *ci = RTA_DATA(rta_tb[IFA_CACHEINFO]); struct ifa_cacheinfo *ci = RTA_DATA(rta_tb[IFA_CACHEINFO]);
char buf[128];
fprintf(fp, "%s", _SL_); fprintf(fp, "%s", _SL_);
fprintf(fp, " valid_lft ");
if (ci->ifa_valid == INFINITY_LIFE_TIME) if (ci->ifa_valid == INFINITY_LIFE_TIME)
sprintf(buf, "valid_lft forever"); fprintf(fp, "forever");
else 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) if (ci->ifa_prefered == INFINITY_LIFE_TIME)
sprintf(buf+strlen(buf), " preferred_lft forever"); fprintf(fp, "forever");
else { else {
if (deprecated) if (deprecated)
sprintf(buf+strlen(buf), " preferred_lft %dsec", fprintf(fp, "%dsec", ci->ifa_prefered);
ci->ifa_prefered);
else else
sprintf(buf+strlen(buf), " preferred_lft %usec", fprintf(fp, "%usec", ci->ifa_prefered);
ci->ifa_prefered);
} }
fprintf(fp, " %s", buf);
} }
fprintf(fp, "\n"); fprintf(fp, "\n");
fflush(fp); fflush(fp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment