Skip to content

Commit

Permalink
[PKT_SCHED]: Fix regression in PSCHED_TADD{,2}.
Browse files Browse the repository at this point in the history
In PSCHED_TADD and PSCHED_TADD2, if delta is less than tv.tv_usec (so,
less than USEC_PER_SEC too) then tv_res will be smaller than tv. The
affectation "(tv_res).tv_usec = __delta;" is wrong.  The fix is to
revert to the original code before
4ee303d and change the 'if' in
'while'.

[Shuya MAEDA: "while (__delta >= USEC_PER_SEC){ ... }" instead of
"while (__delta > USEC_PER_SEC){ ... }"]

Signed-off-by: Guillaume Chazarain <guichaz@yahoo.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Guillaume Chazarain authored and David S. Miller committed Jul 24, 2006
1 parent 4b79f0a commit 2266d88
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions include/net/pkt_sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,23 +169,17 @@ psched_tod_diff(int delta_sec, int bound)

#define PSCHED_TADD2(tv, delta, tv_res) \
({ \
int __delta = (delta); \
(tv_res) = (tv); \
while(__delta >= USEC_PER_SEC){ \
(tv_res).tv_sec++; \
__delta -= USEC_PER_SEC; \
} \
int __delta = (tv).tv_usec + (delta); \
(tv_res).tv_sec = (tv).tv_sec; \
while (__delta >= USEC_PER_SEC) { (tv_res).tv_sec++; __delta -= USEC_PER_SEC; } \
(tv_res).tv_usec = __delta; \
})

#define PSCHED_TADD(tv, delta) \
({ \
int __delta = (delta); \
while(__delta >= USEC_PER_SEC){ \
(tv).tv_sec++; \
__delta -= USEC_PER_SEC; \
} \
(tv).tv_usec = __delta; \
(tv).tv_usec += (delta); \
while ((tv).tv_usec >= USEC_PER_SEC) { (tv).tv_sec++; \
(tv).tv_usec -= USEC_PER_SEC; } \
})

/* Set/check that time is in the "past perfect";
Expand Down

0 comments on commit 2266d88

Please sign in to comment.