2006-10-01 13:24:23

by Jeff Garzik

[permalink] [raw]
Subject: ATM bug found

Unlike 98% of the warnings of this type, this gcc warning does indeed
seem to indicate a bug:

drivers/atm/zatm.c: In function ?zatm_open?:
drivers/atm/zatm.c:919: warning: ?pcr? may be used uninitialized in this
function

If alloc_shaper() argument 'unlimited' is true, then pcr is never
assigned a value. However, the caller of alloc_shaper() always tests
the pcr value, regardless of whether or not 'unlimited' is true.

Jeff



Subject: Re: ATM bug found

In message <[email protected]>,Jeff Garzik writes:
>If alloc_shaper() argument 'unlimited' is true, then pcr is never
>assigned a value. However, the caller of alloc_shaper() always tests
>the pcr value, regardless of whether or not 'unlimited' is true.

when unlimited is true, this means ubr. alloc_shaper() creates a queue
to use for all ubr (best effort) traffic. ubr doesnt count against tx_bw
so its handled a bit differently. alloc_shaper() should return a 0 for
the pcr since this gets assigned to the vcc's qos parameters. min_pcr =
0 and max_pcr = 0 means "best effort".

still generates a warning from gcc though.

[ATM]: [zatm] always *pcr in alloc_shaper()

Signed-off-by: Chas Williams <[email protected]>

diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
index c491ec4..083c5d3 100644
--- a/drivers/atm/zatm.c
+++ b/drivers/atm/zatm.c
@@ -800,6 +800,7 @@ static int alloc_shaper(struct atm_dev *
i = m = 1;
zatm_dev->ubr_ref_cnt++;
zatm_dev->ubr = shaper;
+ *pcr = 0;
}
else {
if (min) {