Netdev List
 help / color / mirror / Atom feed
From: "Satoru SATOH" <satoru.satoh@gmail.com>
To: netdev@vger.kernel.org
Subject: [PATCH] [IPROUTE]: Avoid overflow for larger rto_min in print_route
Date: Thu, 13 Dec 2007 00:50:27 +0900	[thread overview]
Message-ID: <d72b7ace0712120750k2deed0f6p50c1c556d3f7de80@mail.gmail.com> (raw)

This includes a workaround for overflow while conversion of larger
rto_min (e.g. 3s) unit.


Signed-off-by: Satoru SATOH <satoru.satoh@gmail.com>

 ip/iproute.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/ip/iproute.c b/ip/iproute.c
index f4200ae..fa722c6 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -510,16 +510,16 @@ 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 / 1000;

-                               val *= 1000;
                                if (i == RTAX_RTT)
                                        val /= 8;
                                else if (i == RTAX_RTTVAR)
                                        val /= 4;
-                               if (val >= hz)
-                                       fprintf(fp, " %ums", val/hz);
+                               if (val >= hz1)
+                                       fprintf(fp, " %ums", val/hz1);
                                else
-                                       fprintf(fp, " %.2fms", (float)val/hz);
+                                       fprintf(fp, " %.2fms", (float)val/hz1);
                        }
                }
        }

                 reply	other threads:[~2007-12-12 16:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=d72b7ace0712120750k2deed0f6p50c1c556d3f7de80@mail.gmail.com \
    --to=satoru.satoh@gmail.com \
    --cc=netdev@vger.kernel.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