All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jarek Poplawski <jarkao2@gmail.com>
To: Patrick McHardy <kaber@trash.net>
Cc: Stephen Hemminger <shemminger@vyatta.com>,
	Antonio Almeida <vexwek@gmail.com>,
	David Miller <davem@davemloft.net>,
	netdev@vger.kernel.org, Martin Devera <devik@cdi.cz>,
	Eric Dumazet <dada1@cosmosbay.com>,
	Vladimir Ivashchenko <hazard@francoudi.com>,
	Badalian Vyacheslav <slavon@bigtelecom.ru>
Subject: [PATCH iproute2 3/2] tc_core: Return double from tc_core_tick2time()
Date: Wed, 10 Jun 2009 00:53:46 +0200	[thread overview]
Message-ID: <20090609225317.GA3262@ami.dom.local> (raw)
In-Reply-To: <4A2E6BA4.30002@trash.net>

Hmm... I'm not sure this floor() is needed here, but maybe I'll get it
tomorrow... 

Thanks,
Jarek P.
-------------------------->
Patrick McHardy wrote:
> It seems inconsistent to have the time2tick() function take a
> double, but return an unsigned from tick2time(). If we're going
> to change this, please keep them symetrical (you could even use
> floor() in tick2time() to make it more explicit).

This patch removes this inconsistency.

Suggested-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
---

diff -Nurp a/tc/tc_core.c b/tc/tc_core.c
--- a/tc/tc_core.c	2009-06-09 22:59:42.000000000 +0200
+++ b/tc/tc_core.c	2009-06-10 00:26:10.000000000 +0200
@@ -41,9 +41,9 @@ unsigned tc_core_time2tick(double time)
 	return ceil(time * tick_in_usec);
 }
 
-unsigned tc_core_tick2time(unsigned tick)
+double tc_core_tick2time(unsigned tick)
 {
-	return tick/tick_in_usec;
+	return floor(tick / tick_in_usec);
 }
 
 unsigned tc_core_time2ktime(unsigned time)
diff -Nurp a/tc/tc_core.h b/tc/tc_core.h
--- a/tc/tc_core.h	2009-06-09 22:57:17.000000000 +0200
+++ b/tc/tc_core.h	2009-06-10 00:26:58.000000000 +0200
@@ -15,7 +15,7 @@ enum link_layer {
 
 int  tc_core_time2big(double time);
 unsigned tc_core_time2tick(double time);
-unsigned tc_core_tick2time(unsigned tick);
+double tc_core_tick2time(unsigned tick);
 unsigned tc_core_time2ktime(unsigned time);
 unsigned tc_core_ktime2time(unsigned ktime);
 unsigned tc_calc_xmittime(unsigned rate, unsigned size);

  parent reply	other threads:[~2009-06-09 22:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-09  8:05 [PATCH iproute2 1/2] tc_core: Use double in tc_core_time2tick() Jarek Poplawski
2009-06-09  8:08 ` David Miller
2009-06-09  8:18   ` Jarek Poplawski
2009-06-09 14:03 ` Patrick McHardy
2009-06-09 21:54   ` Jarek Poplawski
2009-06-09 22:20     ` Jarek Poplawski
2009-06-09 22:53   ` Jarek Poplawski [this message]
2009-06-09 23:04     ` [PATCH iproute2 3/2] tc_core: Return double from tc_core_tick2time() Patrick McHardy
2009-06-10  7:46       ` [PATCH iproute2 3/2 v2] " Jarek Poplawski
2009-06-10 12:25         ` Patrick McHardy

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=20090609225317.GA3262@ami.dom.local \
    --to=jarkao2@gmail.com \
    --cc=dada1@cosmosbay.com \
    --cc=davem@davemloft.net \
    --cc=devik@cdi.cz \
    --cc=hazard@francoudi.com \
    --cc=kaber@trash.net \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    --cc=slavon@bigtelecom.ru \
    --cc=vexwek@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.