Skip to content

Commit bced768

Browse files
authored
Merge pull request #6973 from jepler/rp2040-fix-warnings
Rp2040 fix warnings
2 parents 9f8a68f + c02602a commit bced768

File tree

13 files changed

+23
-56
lines changed

13 files changed

+23
-56
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-function -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-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
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 -Wno-unused-variable -Wno-strict-overflow
260260

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

ports/raspberrypi/bindings/rp2pio/StateMachine.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,10 @@ STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n
259259
bufinfo.buf, bufinfo.len / 2,
260260
args[ARG_frequency].u_int,
261261
init_bufinfo.buf, init_bufinfo.len / 2,
262-
first_out_pin, args[ARG_out_pin_count].u_int, args[ARG_initial_out_pin_state].u_int, args[ARG_initial_out_pin_direction].u_int,
263-
first_in_pin, args[ARG_in_pin_count].u_int, args[ARG_pull_in_pin_up].u_int, args[ARG_pull_in_pin_down].u_int,
264-
first_set_pin, args[ARG_set_pin_count].u_int, args[ARG_initial_set_pin_state].u_int, args[ARG_initial_set_pin_direction].u_int,
265-
first_sideset_pin, args[ARG_sideset_pin_count].u_int, args[ARG_initial_sideset_pin_state].u_int, args[ARG_initial_sideset_pin_direction].u_int,
262+
first_out_pin, out_pin_count, args[ARG_initial_out_pin_state].u_int, args[ARG_initial_out_pin_direction].u_int,
263+
first_in_pin, in_pin_count, args[ARG_pull_in_pin_up].u_int, args[ARG_pull_in_pin_down].u_int,
264+
first_set_pin, set_pin_count, args[ARG_initial_set_pin_state].u_int, args[ARG_initial_set_pin_direction].u_int,
265+
first_sideset_pin, sideset_pin_count, args[ARG_initial_sideset_pin_state].u_int, args[ARG_initial_sideset_pin_direction].u_int,
266266
args[ARG_sideset_enable].u_bool,
267267
jmp_pin, jmp_pin_pull,
268268
0,
@@ -397,7 +397,6 @@ STATIC mp_obj_t rp2pio_statemachine_write(size_t n_args, const mp_obj_t *pos_arg
397397
return mp_const_none;
398398
}
399399

400-
uint8_t *original_pointer = bufinfo.buf;
401400
int stride_in_bytes = mp_binary_get_size('@', bufinfo.typecode, NULL);
402401
if (stride_in_bytes > 4) {
403402
mp_raise_ValueError(translate("Buffer elements must be 4 bytes long or less"));
@@ -606,7 +605,6 @@ STATIC mp_obj_t rp2pio_statemachine_readinto(size_t n_args, const mp_obj_t *pos_
606605
return mp_const_none;
607606
}
608607

609-
uint8_t *original_pointer = bufinfo.buf;
610608
int stride_in_bytes = mp_binary_get_size('@', bufinfo.typecode, NULL);
611609
if (stride_in_bytes > 4) {
612610
mp_raise_ValueError(translate("Buffer elements must be 4 bytes long or less"));
@@ -832,10 +830,3 @@ const mp_obj_type_t rp2pio_statemachine_type = {
832830
.make_new = rp2pio_statemachine_make_new,
833831
.locals_dict = (mp_obj_dict_t *)&rp2pio_statemachine_locals_dict,
834832
};
835-
836-
static rp2pio_statemachine_obj_t *validate_obj_is_statemachine(mp_obj_t obj) {
837-
if (!mp_obj_is_type(obj, &rp2pio_statemachine_type)) {
838-
mp_raise_TypeError_varg(translate("Expected a %q"), rp2pio_statemachine_type.name);
839-
}
840-
return MP_OBJ_TO_PTR(obj);
841-
}

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/countio/Counter.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ void common_hal_countio_counter_construct(countio_counter_obj_t *self,
3131
mp_raise_RuntimeError(translate("PWM slice already in use"));
3232
}
3333

34-
uint8_t ab_channel = pwm_gpio_to_channel(self->pin);
3534
if (!pwmio_claim_slice_ab_channels(self->slice_num)) {
3635
mp_raise_RuntimeError(translate("PWM slice channel A already in use"));
3736
}

ports/raspberrypi/common-hal/digitalio/DigitalInOut.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ digitalinout_result_t common_hal_digitalio_digitalinout_set_drive_mode(
158158
}
159159
}
160160
#endif
161-
const uint8_t pin = self->pin->number;
162161
bool value = common_hal_digitalio_digitalinout_get_value(self);
163162
self->open_drain = drive_mode == DRIVE_MODE_OPEN_DRAIN;
164163
// True is implemented differently between modes so reset the value to make

ports/raspberrypi/common-hal/i2ctarget/I2CTarget.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ void common_hal_i2ctarget_i2c_target_deinit(i2ctarget_i2c_target_obj_t *self) {
104104
return;
105105
}
106106

107-
static int i2c_peripheral_check_error(i2ctarget_i2c_target_obj_t *self, bool raise) {
108-
return 0;
109-
}
110-
111107
int common_hal_i2ctarget_i2c_target_is_addressed(i2ctarget_i2c_target_obj_t *self, uint8_t *address, bool *is_read, bool *is_restart) {
112108
if (!((self->peripheral->hw->raw_intr_stat & I2C_IC_INTR_STAT_R_RX_FULL_BITS) || (self->peripheral->hw->raw_intr_stat & I2C_IC_INTR_STAT_R_RD_REQ_BITS))) {
113109
return 0;

ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,6 @@ void common_hal_imagecapture_parallelimagecapture_construct(imagecapture_paralle
120120
true, 32, true, // in settings
121121
false, // Not user-interruptible.
122122
2, 5); // wrap settings
123-
124-
125-
PIO pio = self->state_machine.pio;
126-
uint8_t pio_index = pio_get_index(pio);
127-
uint sm = self->state_machine.state_machine;
128123
}
129124

130125
void common_hal_imagecapture_parallelimagecapture_deinit(imagecapture_parallelimagecapture_obj_t *self) {

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

Lines changed: 3 additions & 3 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++) {
@@ -871,7 +871,7 @@ bool common_hal_rp2pio_statemachine_get_txstall(rp2pio_statemachine_obj_t *self)
871871
}
872872

873873
void common_hal_rp2pio_statemachine_clear_txstall(rp2pio_statemachine_obj_t *self) {
874-
uint8_t level = pio_sm_get_rx_fifo_level(self->pio, self->state_machine);
874+
(void)pio_sm_get_rx_fifo_level(self->pio, self->state_machine);
875875
uint32_t stall_mask = 1 << (PIO_FDEBUG_TXSTALL_LSB + self->state_machine);
876876
self->pio->fdebug = stall_mask;
877877
}

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 & 9 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
@@ -829,7 +829,6 @@ socketpool_socket_obj_t *common_hal_socketpool_socket_accept(socketpool_socket_o
829829

830830
bool common_hal_socketpool_socket_bind(socketpool_socket_obj_t *socket,
831831
const char *host, size_t hostlen, uint32_t port) {
832-
uint8_t ip[NETUTILS_IPV4ADDR_BUFSIZE];
833832

834833
// get address
835834
ip_addr_t bind_addr;
@@ -952,7 +951,7 @@ void common_hal_socketpool_socket_connect(socketpool_socket_obj_t *socket,
952951
MICROPY_PY_LWIP_EXIT
953952

954953
// And now we wait...
955-
if (socket->timeout != -1) {
954+
if (socket->timeout != (unsigned)-1) {
956955
for (mp_uint_t retries = socket->timeout / 100; retries--;) {
957956
mp_hal_delay_ms(100);
958957
if (socket->state != STATE_CONNECTING) {
@@ -1048,7 +1047,7 @@ mp_uint_t common_hal_socketpool_socket_recvfrom_into(socketpool_socket_obj_t *so
10481047
ret = lwip_raw_udp_receive(socket, (byte *)buf, len, ip, port, &_errno);
10491048
break;
10501049
}
1051-
if (ret == -1) {
1050+
if (ret == (unsigned)-1) {
10521051
mp_raise_OSError(_errno);
10531052
}
10541053

@@ -1097,7 +1096,7 @@ int socketpool_socket_send(socketpool_socket_obj_t *socket, const uint8_t *buf,
10971096
ret = lwip_raw_udp_send(socket, buf, len, NULL, 0, &_errno);
10981097
break;
10991098
}
1100-
if (ret == -1) {
1099+
if (ret == (unsigned)-1) {
11011100
return -_errno;
11021101
}
11031102
return ret;
@@ -1134,7 +1133,7 @@ mp_uint_t common_hal_socketpool_socket_sendto(socketpool_socket_obj_t *socket,
11341133
ret = lwip_raw_udp_send(socket, buf, len, &ip, port, &_errno);
11351134
break;
11361135
}
1137-
if (ret == -1) {
1136+
if (ret == (unsigned)-1) {
11381137
mp_raise_OSError(_errno);
11391138
}
11401139

0 commit comments

Comments
 (0)