Skip to content

Commit 3da012d

Browse files
authored
Merge pull request #10187 from jepler/warn-type-limits
Enable & Address -Wtype-limits diagnostics in raspberrypi port
2 parents 27f2b1c + 4d56785 commit 3da012d

File tree

6 files changed

+9
-12
lines changed

6 files changed

+9
-12
lines changed

main.c

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

shared-bindings/socketpool/SocketPool.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ static mp_obj_t socketpool_socketpool_socket(size_t n_args, const mp_obj_t *pos_
103103
socketpool_socketpool_sock_t type = args[ARG_type].u_int;
104104
socketpool_socketpool_ipproto_t proto = args[ARG_proto].u_int;
105105

106-
if (proto < 0) {
107-
proto = 0;
108-
}
109-
110106
return common_hal_socketpool_socket(self, family, type, proto);
111107
}
112108
MP_DEFINE_CONST_FUN_OBJ_KW(socketpool_socketpool_socket_obj, 1, socketpool_socketpool_socket);

supervisor/shared/serial.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ char serial_read(void) {
298298

299299
#if CIRCUITPY_WEB_WORKFLOW
300300
if (websocket_available()) {
301-
char c = websocket_read_char();
301+
int c = websocket_read_char();
302302
if (c != -1) {
303303
return c;
304304
}

0 commit comments

Comments
 (0)