From: Stephen Hemminger Date: Mon, 23 Mar 2009 17:49:21 +0000 (-0700) Subject: Handle default hoplimit X-Git-Tag: v2.6.29~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ced61d7dc44541127f0462409d81d11ee0da0a2e;p=thirdparty%2Fiproute2.git Handle default hoplimit Default for hoplimit is -1 which should be displayed as zero. --- diff --git a/ip/iproute.c b/ip/iproute.c index 6a2ea05f1..bf0f31bdb 100644 --- a/ip/iproute.c +++ b/ip/iproute.c @@ -493,6 +493,8 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) mxlock = *(unsigned*)RTA_DATA(mxrta[RTAX_LOCK]); for (i=2; i<= RTAX_MAX; i++) { + unsigned val; + if (mxrta[i] == NULL) continue; if (!hz) @@ -505,21 +507,31 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) if (mxlock & (1<= hz) - fprintf(fp, " %llums", val/hz); + fprintf(fp, " %llums", + (unsigned long long) val / hz); else - fprintf(fp, " %.2fms", (float)val/hz); + fprintf(fp, " %.2fms", + (double)val / hz); } } }