Skip to content

Commit d06f778

Browse files
committed
Address -Wtype-limits diagnostics
This fixes an unlikely problem with the USB host implementation on rp2350 that would not have detected failure to allocate a DMA channel. Together with #10186 this should give a clean build. As it is, this will error.
1 parent 03a56ba commit d06f778

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

main.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ static uint8_t *_allocate_memory(safe_mode_t safe_mode, const char *env_key, siz
131131
*final_size = default_size;
132132
#if CIRCUITPY_OS_GETENV
133133
if (safe_mode == SAFE_MODE_NONE) {
134-
(void)common_hal_os_getenv_int(env_key, (mp_int_t *)final_size);
135-
if (*final_size < 0) {
136-
*final_size = default_size;
134+
mp_int_t size;
135+
if (common_hal_os_getenv_int(env_key, &size) == GETENV_OK && size > 0) {
136+
*final_size = size;
137137
}
138138
}
139139
#endif

ports/raspberrypi/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ endif
222222

223223
DISABLE_WARNINGS = -Wno-cast-align
224224

225-
CFLAGS += $(INC) -Wall -Werror -std=gnu11 -fshort-enums $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT) $(DISABLE_WARNINGS) -Werror=missing-prototypes
225+
CFLAGS += $(INC) -Wtype-limits -Wall -Werror -std=gnu11 -fshort-enums $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT) $(DISABLE_WARNINGS) -Werror=missing-prototypes
226226

227227
PICO_LDFLAGS = --specs=nosys.specs --specs=nano.specs
228228

ports/raspberrypi/common-hal/usb_host/Port.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,11 @@ usb_host_port_obj_t *common_hal_usb_host_port_construct(const mcu_pin_obj_t *dp,
138138
}
139139
pio_cfg.pio_tx_num = get_usb_pio();
140140
pio_cfg.pio_rx_num = pio_cfg.pio_tx_num;
141-
pio_cfg.tx_ch = dma_claim_unused_channel(false); // DMA channel
142-
if (pio_cfg.tx_ch < 0) {
141+
int dma_ch = dma_claim_unused_channel(false);
142+
if (dma_ch < 0) {
143143
mp_raise_RuntimeError(MP_ERROR_TEXT("All dma channels in use"));
144144
}
145+
pio_cfg.tx_ch = dma_ch;
145146

146147
self->base.type = &usb_host_port_type;
147148
self->dp = dp;

py/circuitpy_defns.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ SRC_CIRCUITPY_COMMON = \
944944

945945
ifeq ($(CIRCUITPY_QRIO),1)
946946
SRC_CIRCUITPY_COMMON += lib/quirc/lib/decode.c lib/quirc/lib/identify.c lib/quirc/lib/quirc.c lib/quirc/lib/version_db.c
947-
$(BUILD)/lib/quirc/lib/%.o: CFLAGS += -Wno-shadow -Wno-sign-compare -include shared-module/qrio/quirc_alloc.h
947+
$(BUILD)/lib/quirc/lib/%.o: CFLAGS += -Wno-type-limits -Wno-shadow -Wno-sign-compare -include shared-module/qrio/quirc_alloc.h
948948
endif
949949

950950
ifdef LD_TEMPLATE_FILE

0 commit comments

Comments
 (0)