Skip to content

Commit 87b7a9d

Browse files
jeplerdpgeorge
authored andcommitted
stm32: Add casts when printing small integers.
All these arguments are of type `mp_{u,}int_t`, but the actual value is always a small integer. Cast it so that it can format with the `%d/%u` formatter. Before, the compiler plugin produced an error in the PYBD_SF6 build, which is a nanboxing build with 64-bit ints. Signed-off-by: Jeff Epler <[email protected]>
1 parent ee4f27a commit 87b7a9d

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

ports/stm32/extint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ static mp_obj_t extint_make_new(const mp_obj_type_t *type, size_t n_args, size_t
760760

761761
static void extint_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
762762
extint_obj_t *self = MP_OBJ_TO_PTR(self_in);
763-
mp_printf(print, "<ExtInt line=%u>", self->line);
763+
mp_printf(print, "<ExtInt line=%u>", (int)self->line);
764764
}
765765

766766
static const mp_rom_map_elem_t extint_locals_dict_table[] = {

ports/stm32/led.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ void led_debug(int n, int delay) {
305305

306306
void led_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
307307
pyb_led_obj_t *self = MP_OBJ_TO_PTR(self_in);
308-
mp_printf(print, "LED(%u)", self->led_id);
308+
mp_printf(print, "LED(%u)", (int)self->led_id);
309309
}
310310

311311
/// \classmethod \constructor(id)

ports/stm32/machine_uart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static void mp_machine_uart_print(const mp_print_t *print, mp_obj_t self_in, mp_
9393
#endif
9494
{
9595
mp_printf(print, "UART(%u, baudrate=%u, bits=%u, parity=",
96-
self->uart_id, uart_get_baudrate(self), bits);
96+
self->uart_id, uart_get_baudrate(self), (int)bits);
9797
}
9898
if (!(cr1 & USART_CR1_PCE)) {
9999
mp_print_str(print, "None");

ports/stm32/pin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static void pin_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t
232232
mp_uint_t af_idx = pin_get_af(self);
233233
const pin_af_obj_t *af_obj = pin_find_af_by_index(self, af_idx);
234234
if (af_obj == NULL) {
235-
mp_printf(print, ", alt=%d)", af_idx);
235+
mp_printf(print, ", alt=%d)", (int)af_idx);
236236
} else {
237237
mp_printf(print, ", alt=Pin.%q)", af_obj->name);
238238
}

ports/stm32/timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ static uint32_t compute_dtg_from_ticks(mp_int_t ticks) {
499499

500500
// Given the 8-bit value stored in the DTG field of the BDTR register, compute
501501
// the number of ticks.
502-
static mp_int_t compute_ticks_from_dtg(uint32_t dtg) {
502+
static unsigned compute_ticks_from_dtg(uint32_t dtg) {
503503
if ((dtg & 0x80) == 0) {
504504
return dtg & 0x7F;
505505
}

0 commit comments

Comments
 (0)