netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bill Fink <billfink@mindspring.com>
To: "YOSHIFUJI Hideaki / ____________" <yoshfuji@linux-ipv6.org>
Cc: satoru.satoh@gmail.com, shemminger@linux-foundation.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH] [IPROUTE]: A workaround to make larger rto_min printed correctly
Date: Fri, 21 Dec 2007 06:18:48 -0500	[thread overview]
Message-ID: <20071221061848.aefa4e6c.billfink@mindspring.com> (raw)
In-Reply-To: <20071221.175352.77874691.yoshfuji@linux-ipv6.org>

On Fri, 21 Dec 2007, YOSHIFUJI Hideaki wrote:

> In article <d72b7ace0712201824k3754962cse377256cb5452b8a@mail.gmail.com> (at Fri, 21 Dec 2007 11:24:54 +0900), "Satoru SATOH" <satoru.satoh@gmail.com> says:
> 
> > 2007/12/21, Jarek Poplawski <jarkao2@gmail.com>:
> > > 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 <satoru.satoh@gmail.com>
> > 
> >  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 <yoshfuji@linux-ipv6.org>
> 
> --- 
> 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);
>  			}
>  		}

  reply	other threads:[~2007-12-21 11:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-20  3:31 [PATCH] [IPROUTE]: A workaround to make larger rto_min printed correctly Satoru SATOH
2007-12-20  8:35 ` YOSHIFUJI Hideaki / 吉藤英明
2007-12-20  9:12 ` Jarek Poplawski
2007-12-20 16:21   ` Satoru SATOH
2007-12-20 20:24     ` Jarek Poplawski
2007-12-20 20:31       ` Jarek Poplawski
2007-12-21  2:24         ` Satoru SATOH
2007-12-21  8:34           ` Jarek Poplawski
2007-12-21  8:53           ` YOSHIFUJI Hideaki / 吉藤英明
2007-12-21 11:18             ` Bill Fink [this message]
2007-12-21 13:49             ` Satoru SATOH
2007-12-21 13:58               ` YOSHIFUJI Hideaki / 吉藤英明
2007-12-21 17:14                 ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071221061848.aefa4e6c.billfink@mindspring.com \
    --to=billfink@mindspring.com \
    --cc=netdev@vger.kernel.org \
    --cc=satoru.satoh@gmail.com \
    --cc=shemminger@linux-foundation.org \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).