Skip to content

Commit c411823

Browse files
committed
Fix operator precedence warning in can_api.c
The original code was: if(LPC_CAN1->IER | LPC_CAN2->IER != 0) { This would actually be interpreted as: if(LPC_CAN1->IER | (LPC_CAN2->IER != 0)) { I simplified it to: if(LPC_CAN1->IER | LPC_CAN2->IER) { With the comparison removed, the GCC warning no longer fires since the user's intent is no longer unclear. However, the end result should be the same.
1 parent 15f833b commit c411823

File tree

1 file changed

+1
-1
lines changed
  • libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X

1 file changed

+1
-1
lines changed

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/can_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ void can_irq_set(can_t *obj, CanIrqType type, uint32_t enable) {
164164
obj->dev->MOD &= ~(1);
165165

166166
// Enable NVIC if at least 1 interrupt is active
167-
if(LPC_CAN1->IER | LPC_CAN2->IER != 0) {
167+
if(LPC_CAN1->IER | LPC_CAN2->IER) {
168168
NVIC_SetVector(CAN_IRQn, (uint32_t) &can_irq_n);
169169
NVIC_EnableIRQ(CAN_IRQn);
170170
}

0 commit comments

Comments
 (0)