usb: gadget: precedence bug in show_requests()
Subsystems (3)
PATCH 1/1 usb: gadget: precedence bug in show_requests()
The mod operation has higher precedence than the divide but the intent was to divide first. It's supposed to count through one time for RX and a second time for TX but instead of doing "0 1 2 0 1 2" it does "0 0 1 1 2 2".
---
Static checker stuff. Untested.
drivers/usb/chipidea/debug.c +1 -1
@@ -709,7 +709,7 @@ static ssize_t show_requests(struct device *dev, struct device_attribute *attr, n +=scnprintf (buf + n,PAGE_SIZE - n,"EP=%02i: TD=%08X %s\n" , - i % ci->hw_ep_max/2 , (u32 )req->dma, + i % (ci->hw_ep_max /2 ), (u32 )req->dma, ((i < ci->hw_ep_max/2 ) ?"RX" :"TX" ));for (j =0 ; j < qSize; j++)
Hello.
Quoted 1 line · Dan Carpenter
The mod operation has higher precedence than the divide
They are of the same priority AFAIR, but that doesn't matter since these
operations are executed left to right.
Quoted 14 lines
but the intent
was to divide first. It's supposed to count through one time for RX and a second time for TX but instead of doing "0 1 2 0 1 2" it does "0 0 1 1 2 2".Signed-off-by Dan Carpenter <[email protected]>---
Static checker stuff. Untested.drivers/usb/chipidea/debug.c +0
-0
drivers/usb/chipidea/debug.c static ssize_t show_requests(struct device *dev, struct device_attribute *attr, · line 715
Quoted 8 lines
drivers/usb/chipidea/debug.c +1
-1@@ -709,7 +709,7 @@ static ssize_t show_requests(struct device *dev, struct device_attribute *attr, n +=scnprintf (buf + n,PAGE_SIZE - n,"EP=%02i: TD=%08X %s\n" , - i % ci->hw_ep_max/2 , (u32 )req->dma, + i % (ci->hw_ep_max /2 ), (u32 )req->dma, ((i < ci->hw_ep_max/2 ) ?"RX" :"TX" ));for (j =0 ; j < qSize; j++)
WBR, Sergei
Quoted 9 lines · Sergei Shtylyov
Hello.
Quoted 1 line · Dan Carpenter
The mod operation has higher precedence than the divide
They are of the same priority AFAIR, but that doesn't matter since
these operations are executed left to right.
Oh yeah, you're right. I feel dumb now. Let me resend with a different changelog.
regards,
dan carpenter