Commit e560d2c3 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller

[PKT_SCHED]: Eliminate guard from TDIFF_SAFE.

The last argument in the PSCHED_TDIFF_SAFE is no longer used;
only usage eliminated by previous patch. It gets rid of a bad macro
usage.

Also, can use the standard min_t macro which also eliminates the
macro problem of double evaluation of bound.
Signed-off-by: default avatarStephen Hemminger <shemminger@osdl.org>
Signed-off-by: default avatarDavid S. Miller <davem@redhat.com>
parent 4b53b3b7
......@@ -308,13 +308,13 @@ extern PSCHED_WATCHER psched_time_mark;
extern int psched_tod_diff(int delta_sec, int bound);
#define PSCHED_TDIFF_SAFE(tv1, tv2, bound, guard) \
#define PSCHED_TDIFF_SAFE(tv1, tv2, bound) \
({ \
int __delta_sec = (tv1).tv_sec - (tv2).tv_sec; \
int __delta = (tv1).tv_usec - (tv2).tv_usec; \
switch (__delta_sec) { \
default: \
__delta = psched_tod_diff(__delta_sec, bound); guard; break; \
__delta = psched_tod_diff(__delta_sec, bound); break; \
case 2: \
__delta += 1000000; \
case 1: \
......@@ -355,12 +355,8 @@ extern int psched_tod_diff(int delta_sec, int bound);
#else
#define PSCHED_TDIFF(tv1, tv2) (long)((tv1) - (tv2))
#define PSCHED_TDIFF_SAFE(tv1, tv2, bound, guard) \
({ \
long long __delta = (tv1) - (tv2); \
if ( __delta > (long long)(bound)) { __delta = (bound); guard; } \
__delta; \
})
#define PSCHED_TDIFF_SAFE(tv1, tv2, bound) \
min_t(long long, (tv1) - (tv2), bound)
#define PSCHED_TLESS(tv1, tv2) ((tv1) < (tv2))
......
......@@ -321,7 +321,7 @@ int tcf_act_police(struct sk_buff **pskb, struct tc_action *a)
PSCHED_GET_TIME(now);
toks = PSCHED_TDIFF_SAFE(now, p->t_c, p->burst, (void)0);
toks = PSCHED_TDIFF_SAFE(now, p->t_c, p->burst);
if (p->P_tab) {
ptoks = toks + p->ptoks;
......@@ -523,7 +523,7 @@ int tcf_police(struct sk_buff *skb, struct tcf_police *p)
PSCHED_GET_TIME(now);
toks = PSCHED_TDIFF_SAFE(now, p->t_c, p->burst, (void)0);
toks = PSCHED_TDIFF_SAFE(now, p->t_c, p->burst);
if (p->P_tab) {
ptoks = toks + p->ptoks;
......
......@@ -155,7 +155,7 @@ gred_enqueue(struct sk_buff *skb, struct Qdisc* sch)
if (!PSCHED_IS_PASTPERFECT(q->qidlestart)) {
long us_idle;
PSCHED_GET_TIME(now);
us_idle = PSCHED_TDIFF_SAFE(now, q->qidlestart, q->Scell_max, (void)0);
us_idle = PSCHED_TDIFF_SAFE(now, q->qidlestart, q->Scell_max);
PSCHED_SET_PASTPERFECT(q->qidlestart);
q->qave >>= q->Stab[(us_idle>>q->Scell_log)&0xFF];
......@@ -551,7 +551,7 @@ static int gred_dump(struct Qdisc *sch, struct sk_buff *skb)
long idle;
psched_time_t now;
PSCHED_GET_TIME(now);
idle = PSCHED_TDIFF_SAFE(now, q->qidlestart, q->Scell_max, (void)0);
idle = PSCHED_TDIFF_SAFE(now, q->qidlestart, q->Scell_max);
qave = q->qave >> q->Stab[(idle>>q->Scell_log)&0xFF];
dst->qave = qave >> q->Wlog;
......
......@@ -367,7 +367,7 @@ static void htb_debug_dump (struct htb_sched *q)
struct list_head *l;
list_for_each (l,q->hash+i) {
struct htb_class *cl = list_entry(l,struct htb_class,hlist);
long diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer, (void)0);
long diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer);
printk(KERN_DEBUG "htb*c%x m=%d t=%ld c=%ld pq=%lu df=%ld ql=%d "
"pa=%x f:",
cl->classid,cl->cmode,cl->tokens,cl->ctokens,
......@@ -807,7 +807,7 @@ static void htb_charge_class(struct htb_sched *q,struct htb_class *cl,
while (cl) {
HTB_CHCL(cl);
diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer, (void)0);
diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer);
#ifdef HTB_DEBUG
if (diff > cl->mbuffer || diff < 0 || PSCHED_TLESS(q->now, cl->t_c)) {
if (net_ratelimit())
......@@ -878,7 +878,7 @@ static long htb_do_events(struct htb_sched *q,int level)
return cl->pq_key - q->jiffies;
}
htb_safe_rb_erase(p,q->wait_pq+level);
diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer, (void)0);
diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer);
#ifdef HTB_DEBUG
if (diff > cl->mbuffer || diff < 0 || PSCHED_TLESS(q->now, cl->t_c)) {
if (net_ratelimit())
......
......@@ -189,7 +189,7 @@ red_enqueue(struct sk_buff *skb, struct Qdisc* sch)
int shift;
PSCHED_GET_TIME(now);
us_idle = PSCHED_TDIFF_SAFE(now, q->qidlestart, q->Scell_max, (void)0);
us_idle = PSCHED_TDIFF_SAFE(now, q->qidlestart, q->Scell_max);
PSCHED_SET_PASTPERFECT(q->qidlestart);
/*
......
......@@ -207,7 +207,7 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch)
PSCHED_GET_TIME(now);
toks = PSCHED_TDIFF_SAFE(now, q->t_c, q->buffer, (void)0);
toks = PSCHED_TDIFF_SAFE(now, q->t_c, q->buffer);
if (q->P_tab) {
ptoks = toks + q->ptokens;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment