Skip to content

Commit 37620d4

Browse files
committed
Fix several classes of compiler diagnostic & make fatal
* -Wno-nested-externs * -Wno-strict-prototypes * -Wno-double-promotion * -Wno-sign-compare
1 parent c6eef39 commit 37620d4

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

ports/raspberrypi/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ else
198198
endif
199199

200200
# Remove -Wno-stringop-overflow after we can test with CI's GCC 10. Mac's looks weird.
201-
DISABLE_WARNINGS = -Wno-stringop-overflow -Wno-unused-variable -Wno-strict-overflow -Wno-cast-align -Wno-strict-prototypes -Wno-nested-externs -Wno-double-promotion -Wno-sign-compare
201+
DISABLE_WARNINGS = -Wno-stringop-overflow -Wno-unused-variable -Wno-strict-overflow -Wno-cast-align
202202

203203
CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib -fshort-enums $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT) $(DISABLE_WARNINGS) -Werror=missing-prototypes
204204

@@ -256,7 +256,7 @@ SRC_SDK := \
256256
$(SRC_SDK_CYW43) \
257257

258258
SRC_SDK := $(addprefix sdk/, $(SRC_SDK))
259-
$(patsubst %.c,$(BUILD)/%.o,$(SRC_SDK) $(SRC_CYW43)): CFLAGS += -Wno-missing-prototypes -Wno-undef -Wno-unused-function
259+
$(patsubst %.c,$(BUILD)/%.o,$(SRC_SDK) $(SRC_CYW43)): CFLAGS += -Wno-missing-prototypes -Wno-undef -Wno-unused-function -Wno-nested-externs -Wno-strict-prototypes -Wno-double-promotion -Wno-sign-compare
260260

261261
SRC_C += \
262262
boards/$(BOARD)/board.c \

ports/raspberrypi/common-hal/busio/I2C.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ STATIC uint8_t _common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr,
190190
return status;
191191
}
192192

193-
int result = i2c_write_timeout_us(self->peripheral, addr, data, len, !transmit_stop_bit, BUS_TIMEOUT_US);
193+
size_t result = i2c_write_timeout_us(self->peripheral, addr, data, len, !transmit_stop_bit, BUS_TIMEOUT_US);
194194
if (result == len) {
195195
return 0;
196196
}
@@ -211,7 +211,7 @@ uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr,
211211

212212
uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr,
213213
uint8_t *data, size_t len) {
214-
int result = i2c_read_timeout_us(self->peripheral, addr, data, len, false, BUS_TIMEOUT_US);
214+
size_t result = i2c_read_timeout_us(self->peripheral, addr, data, len, false, BUS_TIMEOUT_US);
215215
if (result == len) {
216216
return 0;
217217
}

ports/raspberrypi/common-hal/rp2pio/StateMachine.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ STATIC void *_interrupt_arg[NUM_PIOS][NUM_PIO_STATE_MACHINES];
7171
STATIC void rp2pio_statemachine_interrupt_handler(void);
7272

7373
static void rp2pio_statemachine_set_pull(uint32_t pull_pin_up, uint32_t pull_pin_down, uint32_t pins_we_use) {
74-
for (int i = 0; i < TOTAL_GPIO_COUNT; i++) {
74+
for (size_t i = 0; i < TOTAL_GPIO_COUNT; i++) {
7575
bool used = pins_we_use & (1 << i);
7676
if (used) {
7777
bool pull_up = pull_pin_up & (1 << i);
@@ -231,7 +231,7 @@ bool rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self,
231231
program_offset = 32;
232232
}
233233

234-
int state_machine = -1;
234+
size_t state_machine = NUM_PIO_STATE_MACHINES;
235235
if (pio_index < NUM_PIOS) {
236236
PIO pio = pio_instances[pio_index];
237237
for (size_t i = 0; i < NUM_PIOS; i++) {

ports/raspberrypi/common-hal/rp2pio/__init__.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ bool common_hal_rp2pio_pins_are_sequential(size_t len, mp_obj_t *items) {
3333
return true;
3434
}
3535
const mcu_pin_obj_t *last_pin = validate_obj_is_pin(items[0]);
36-
for (int i = 1; i < len; i++) {
36+
for (size_t i = 1; i < len; i++) {
3737
const mcu_pin_obj_t *pin = validate_obj_is_pin(items[i]);
3838
if (pin->number != last_pin->number + 1) {
3939
return false;

ports/raspberrypi/common-hal/socketpool/Socket.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ STATIC mp_uint_t lwip_raw_udp_receive(socketpool_socket_obj_t *socket, byte *buf
409409
// Wait for data to arrive on UDP socket.
410410
mp_uint_t start = mp_hal_ticks_ms();
411411
while (socket->incoming.pbuf == NULL) {
412-
if (socket->timeout != -1 && mp_hal_ticks_ms() - start > socket->timeout) {
412+
if (socket->timeout != (unsigned)-1 && mp_hal_ticks_ms() - start > socket->timeout) {
413413
*_errno = MP_ETIMEDOUT;
414414
return -1;
415415
}
@@ -479,7 +479,7 @@ STATIC mp_uint_t lwip_tcp_send(socketpool_socket_obj_t *socket, const byte *buf,
479479
// Avoid sending too small packets, so wait until at least 16 bytes available
480480
while (socket->state >= STATE_CONNECTED && (available = tcp_sndbuf(socket->pcb.tcp)) < 16) {
481481
MICROPY_PY_LWIP_EXIT
482-
if (socket->timeout != -1 && mp_hal_ticks_ms() - start > socket->timeout) {
482+
if (socket->timeout != (unsigned)-1 && mp_hal_ticks_ms() - start > socket->timeout) {
483483
*_errno = MP_ETIMEDOUT;
484484
return MP_STREAM_ERROR;
485485
}
@@ -546,7 +546,7 @@ STATIC mp_uint_t lwip_tcp_receive(socketpool_socket_obj_t *socket, byte *buf, mp
546546

547547
mp_uint_t start = mp_hal_ticks_ms();
548548
while (socket->state == STATE_CONNECTED && socket->incoming.pbuf == NULL) {
549-
if (socket->timeout != -1 && mp_hal_ticks_ms() - start > socket->timeout) {
549+
if (socket->timeout != (unsigned)-1 && mp_hal_ticks_ms() - start > socket->timeout) {
550550
*_errno = MP_ETIMEDOUT;
551551
return -1;
552552
}
@@ -778,7 +778,7 @@ socketpool_socket_obj_t *common_hal_socketpool_socket_accept(socketpool_socket_o
778778
MICROPY_PY_LWIP_EXIT
779779
m_del_obj(socketpool_socket_obj_t, socket2);
780780
mp_raise_OSError(MP_EAGAIN);
781-
} else if (socket->timeout != -1) {
781+
} else if (socket->timeout != (unsigned)-1) {
782782
mp_uint_t retries = socket->timeout / 100;
783783
while (*incoming_connection == NULL) {
784784
MICROPY_PY_LWIP_EXIT
@@ -952,7 +952,7 @@ void common_hal_socketpool_socket_connect(socketpool_socket_obj_t *socket,
952952
MICROPY_PY_LWIP_EXIT
953953

954954
// And now we wait...
955-
if (socket->timeout != -1) {
955+
if (socket->timeout != (unsigned)-1) {
956956
for (mp_uint_t retries = socket->timeout / 100; retries--;) {
957957
mp_hal_delay_ms(100);
958958
if (socket->state != STATE_CONNECTING) {
@@ -1048,7 +1048,7 @@ mp_uint_t common_hal_socketpool_socket_recvfrom_into(socketpool_socket_obj_t *so
10481048
ret = lwip_raw_udp_receive(socket, (byte *)buf, len, ip, port, &_errno);
10491049
break;
10501050
}
1051-
if (ret == -1) {
1051+
if (ret == (unsigned)-1) {
10521052
mp_raise_OSError(_errno);
10531053
}
10541054

@@ -1097,7 +1097,7 @@ int socketpool_socket_send(socketpool_socket_obj_t *socket, const uint8_t *buf,
10971097
ret = lwip_raw_udp_send(socket, buf, len, NULL, 0, &_errno);
10981098
break;
10991099
}
1100-
if (ret == -1) {
1100+
if (ret == (unsigned)-1) {
11011101
return -_errno;
11021102
}
11031103
return ret;
@@ -1134,7 +1134,7 @@ mp_uint_t common_hal_socketpool_socket_sendto(socketpool_socket_obj_t *socket,
11341134
ret = lwip_raw_udp_send(socket, buf, len, &ip, port, &_errno);
11351135
break;
11361136
}
1137-
if (ret == -1) {
1137+
if (ret == (unsigned)-1) {
11381138
mp_raise_OSError(_errno);
11391139
}
11401140

ports/raspberrypi/common-hal/wifi/ScannedNetworks.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static void scan_result_put(const cyw43_ev_scan_result_t *result) {
5252
}
5353
}
5454

55-
static bool scan_result_available() {
55+
static bool scan_result_available(void) {
5656
return scan_full || (scan_get != scan_put);
5757
}
5858

@@ -83,15 +83,15 @@ static int scan_result(void *env, const cyw43_ev_scan_result_t *result) {
8383

8484
mp_obj_t common_hal_wifi_scannednetworks_next(wifi_scannednetworks_obj_t *self) {
8585
// no results available, wait for some
86-
while (!scan_result_available(self) && cyw43_wifi_scan_active(&cyw43_state)) {
86+
while (!scan_result_available() && cyw43_wifi_scan_active(&cyw43_state)) {
8787
RUN_BACKGROUND_TASKS;
8888
if (mp_hal_is_interrupted()) {
8989
return mp_const_none;
9090
}
9191
cyw43_arch_poll();
9292
}
9393

94-
if (!scan_result_available(self)) {
94+
if (!scan_result_available()) {
9595
common_hal_wifi_radio_obj.current_scan = NULL;
9696
return mp_const_none;
9797
}

0 commit comments

Comments
 (0)