[PKT_SCHED]: PSCHED_TADD() and PSCHED_TADD2() can result,tv_usec >= 1000000
authorShuya MAEDA <maeda-sxb@necst.nec.co.jp>
Wed, 28 Jun 2006 08:40:35 +0000 (01:40 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Thu, 29 Jun 2006 23:58:01 +0000 (16:58 -0700)
Signed-off-by: Shuya MAEDA <maeda-sxb@necst.nec.co.jp>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/pkt_sched.h

index 75b5b9333fc75cc3b4289c80870b8a77ed6f0892..1925c65e617b9eddae6e199f660a72232e750235 100644 (file)
@@ -169,17 +169,23 @@ psched_tod_diff(int delta_sec, int bound)
 
 #define PSCHED_TADD2(tv, delta, tv_res) \
 ({ \
-          int __delta = (tv).tv_usec + (delta); \
-          (tv_res).tv_sec = (tv).tv_sec; \
-          if (__delta > USEC_PER_SEC) { (tv_res).tv_sec++; __delta -= USEC_PER_SEC; } \
+          int __delta = (delta); \
+          (tv_res) = (tv); \
+          while(__delta >= USEC_PER_SEC){ \
+                (tv_res).tv_sec++; \
+                __delta -= USEC_PER_SEC; \
+          } \
           (tv_res).tv_usec = __delta; \
 })
 
 #define PSCHED_TADD(tv, delta) \
 ({ \
-          (tv).tv_usec += (delta); \
-          if ((tv).tv_usec > USEC_PER_SEC) { (tv).tv_sec++; \
-                (tv).tv_usec -= USEC_PER_SEC; } \
+          int __delta = (delta); \
+          while(__delta >= USEC_PER_SEC){ \
+                (tv).tv_sec++; \
+                __delta -= USEC_PER_SEC; \
+          } \
+          (tv).tv_usec = __delta; \
 })
 
 /* Set/check that time is in the "past perfect";