Skip to content

Commit 8fe7276

Browse files
committed
Silence signed/unsigned comparison warnings in GCC.
Why do the wait APIs take a signed integer if they are going to be compared to unsigned quantities?
1 parent c411823 commit 8fe7276

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

libraries/mbed/common/wait_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ void wait_ms(int ms) {
2626

2727
void wait_us(int us) {
2828
uint32_t start = us_ticker_read();
29-
while ((us_ticker_read() - start) < us);
29+
while ((us_ticker_read() - start) < (uint32_t)us);
3030
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ int ethernet_receive() {
697697
if(receive_idx == -1) {
698698
receive_idx = LPC_EMAC->RxConsumeIndex;
699699
} else {
700-
while(!(rxstat[receive_idx].Info & RINFO_LAST_FLAG) && (receive_idx != LPC_EMAC->RxProduceIndex)) {
700+
while(!(rxstat[receive_idx].Info & RINFO_LAST_FLAG) && ((uint32_t)receive_idx != LPC_EMAC->RxProduceIndex)) {
701701
receive_idx = rinc(receive_idx, NUM_RX_FRAG);
702702
}
703703
unsigned int info = rxstat[receive_idx].Info;
@@ -713,7 +713,7 @@ int ethernet_receive() {
713713
LPC_EMAC->RxConsumeIndex = receive_idx;
714714
}
715715

716-
if(receive_idx == LPC_EMAC->RxProduceIndex) {
716+
if((uint32_t)receive_idx == LPC_EMAC->RxProduceIndex) {
717717
receive_idx = -1;
718718
return 0;
719719
}
@@ -762,7 +762,7 @@ int ethernet_read(char *data, int dlen) {
762762
void *pdst, *psrc;
763763
int doff = 0;
764764

765-
if(receive_idx == LPC_EMAC->RxProduceIndex || receive_idx == -1) {
765+
if((uint32_t)receive_idx == LPC_EMAC->RxProduceIndex || receive_idx == -1) {
766766
return 0;
767767
}
768768

0 commit comments

Comments
 (0)