Skip to content

Commit 76b7bb4

Browse files
committed
USBDevice: Silence GCC warning
The following line in USBHAL_KL25Z.cpp would generate a warning in GCC because of a potential operator precendence issue: return((USB0->FRMNUML | (USB0->FRMNUMH << 8) & 0x07FF)); This would have been interpreted as: return((USB0->FRMNUML | ((USB0->FRMNUMH << 8) & 0x07FF))); since & has higher precedence than | I switched it to be: return((USB0->FRMNUML | (USB0->FRMNUMH << 8)) & 0x07FF); Since it makes more sense to & with 0x7FF after having merged the lower and upper bytes together rather than just the upper byte. It should have resulted in the same value either way.
1 parent dfd6fe6 commit 76b7bb4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libraries/USBDevice/USBDevice/USBHAL_KL25Z.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static uint8_t addr = 0;
7575
static uint32_t Data1 = 0x55555555;
7676

7777
static uint32_t frameNumber() {
78-
return((USB0->FRMNUML | (USB0->FRMNUMH << 8) & 0x07FF));
78+
return((USB0->FRMNUML | (USB0->FRMNUMH << 8)) & 0x07FF);
7979
}
8080

8181
uint32_t USBHAL::endpointReadcore(uint8_t endpoint, uint8_t *buffer) {

0 commit comments

Comments
 (0)