From ced61d7dc44541127f0462409d81d11ee0da0a2e Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 23 Mar 2009 10:49:21 -0700 Subject: [PATCH] Handle default hoplimit Default for hoplimit is -1 which should be displayed as zero. --- ip/iproute.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/ip/iproute.c b/ip/iproute.c index 6a2ea05f..bf0f31bd 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); } } }