From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bill Fink Subject: Re: [PATCH] [IPROUTE]: A workaround to make larger rto_min printed correctly Date: Fri, 21 Dec 2007 06:18:48 -0500 Message-ID: <20071221061848.aefa4e6c.billfink@mindspring.com> References: <476ACF8A.7060201@gmail.com> <476AD127.2020909@gmail.com> <20071221.175352.77874691.yoshfuji@linux-ipv6.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: satoru.satoh@gmail.com, shemminger@linux-foundation.org, netdev@vger.kernel.org To: YOSHIFUJI Hideaki / =?ISO-8859-1?Q?=5F=5F=5F=5F=5F=5F=5F=5F=5F?= =?ISO-8859-1?Q?=5F=5F=5F?= Return-path: Received: from elasmtp-galgo.atl.sa.earthlink.net ([209.86.89.61]:50741 "EHLO elasmtp-galgo.atl.sa.earthlink.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751204AbXLULS7 (ORCPT ); Fri, 21 Dec 2007 06:18:59 -0500 In-Reply-To: <20071221.175352.77874691.yoshfuji@linux-ipv6.org> Sender: netdev-owner@vger.kernel.org List-ID: On Fri, 21 Dec 2007, YOSHIFUJI Hideaki wrote: > In article (at Fri, 21 Dec 2007 11:24:54 +0900), "Satoru SATOH" says: > > > 2007/12/21, Jarek Poplawski : > > > Jarek Poplawski wrote, On 12/20/2007 09:24 PM: > > > ... > > > > > > > but since it's your patch, I hope you do some additional checking > > > > if it's always like this... > > > > > > > > > ...or maybe only changing this all a little bit will make it look safer! > > > > > > Jarek P. > > > > > > OK, how about this? > > > > Signed-off-by: Satoru SATOH > > > > ip/iproute.c | 12 ++++++++---- > > 1 files changed, 8 insertions(+), 4 deletions(-) > > > > diff --git a/ip/iproute.c b/ip/iproute.c > > index f4200ae..c771b34 100644 > > --- a/ip/iproute.c > > +++ b/ip/iproute.c > > @@ -510,16 +510,20 @@ int print_route(const struct sockaddr_nl *who, > > struct nlmsghdr *n, void *arg) > > fprintf(fp, " %u", *(unsigned*)RTA_DATA(mxrta[i])); > > else { > > unsigned val = *(unsigned*)RTA_DATA(mxrta[i]); > > + unsigned hz1 = hz; > > + if (hz1 > 1000) > > Why don't you simply use unsigned long long (or maybe uint64_t) here? I was wondering that too. And maybe change the "(float)" cast to "(double)" in the fprintf. -Bill > Signed-off-by: YOSHIFUJI Hideaki > > --- > diff --git a/ip/iproute.c b/ip/iproute.c > index f4200ae..db9a3b6 100644 > --- a/ip/iproute.c > +++ b/ip/iproute.c > @@ -509,16 +509,21 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) > i != RTAX_RTO_MIN) > fprintf(fp, " %u", *(unsigned*)RTA_DATA(mxrta[i])); > else { > - unsigned val = *(unsigned*)RTA_DATA(mxrta[i]); > + unsigned long long val = *(unsigned*)RTA_DATA(mxrta[i]); > + unsigned div = 1; > > - val *= 1000; > if (i == RTAX_RTT) > - val /= 8; > + div = 8; > else if (i == RTAX_RTTVAR) > - val /= 4; > - if (val >= hz) > - fprintf(fp, " %ums", val/hz); > + div = 4; > else > + div = 1; > + > + val = val * 1000ULL / div; > + > + if (val >= hz) { > + fprintf(fp, " %llums", val/hz); > + } else > fprintf(fp, " %.2fms", (float)val/hz); > } > }