diff options
| author | Jeff Epler <jepler@gmail.com> | 2025-07-06 08:14:31 +0100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-07-25 11:01:16 +1000 |
| commit | 87b7a9d7349c28b3acb13815bb63484d12203895 (patch) | |
| tree | 7c6a50d0c511b69a5d8124f9d11a3a786b38fef4 | |
| parent | ee4f27affa2a4cbf940081da4bdfa36d22351461 (diff) | |
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 <jepler@gmail.com>
| -rw-r--r-- | ports/stm32/extint.c | 2 | ||||
| -rw-r--r-- | ports/stm32/led.c | 2 | ||||
| -rw-r--r-- | ports/stm32/machine_uart.c | 2 | ||||
| -rw-r--r-- | ports/stm32/pin.c | 2 | ||||
| -rw-r--r-- | ports/stm32/timer.c | 2 |
5 files changed, 5 insertions, 5 deletions
diff --git a/ports/stm32/extint.c b/ports/stm32/extint.c index 9c3c24325..df0ed6e23 100644 --- a/ports/stm32/extint.c +++ b/ports/stm32/extint.c @@ -760,7 +760,7 @@ static mp_obj_t extint_make_new(const mp_obj_type_t *type, size_t n_args, size_t static void extint_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { extint_obj_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, "<ExtInt line=%u>", self->line); + mp_printf(print, "<ExtInt line=%u>", (int)self->line); } static const mp_rom_map_elem_t extint_locals_dict_table[] = { diff --git a/ports/stm32/led.c b/ports/stm32/led.c index 795d8c110..2fcb2abb6 100644 --- a/ports/stm32/led.c +++ b/ports/stm32/led.c @@ -305,7 +305,7 @@ void led_debug(int n, int delay) { void led_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { pyb_led_obj_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, "LED(%u)", self->led_id); + mp_printf(print, "LED(%u)", (int)self->led_id); } /// \classmethod \constructor(id) diff --git a/ports/stm32/machine_uart.c b/ports/stm32/machine_uart.c index 8f1faea4b..c93eade5d 100644 --- a/ports/stm32/machine_uart.c +++ b/ports/stm32/machine_uart.c @@ -93,7 +93,7 @@ static void mp_machine_uart_print(const mp_print_t *print, mp_obj_t self_in, mp_ #endif { mp_printf(print, "UART(%u, baudrate=%u, bits=%u, parity=", - self->uart_id, uart_get_baudrate(self), bits); + self->uart_id, uart_get_baudrate(self), (int)bits); } if (!(cr1 & USART_CR1_PCE)) { mp_print_str(print, "None"); diff --git a/ports/stm32/pin.c b/ports/stm32/pin.c index 7de87f2c7..515437ac8 100644 --- a/ports/stm32/pin.c +++ b/ports/stm32/pin.c @@ -232,7 +232,7 @@ static void pin_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t mp_uint_t af_idx = pin_get_af(self); const pin_af_obj_t *af_obj = pin_find_af_by_index(self, af_idx); if (af_obj == NULL) { - mp_printf(print, ", alt=%d)", af_idx); + mp_printf(print, ", alt=%d)", (int)af_idx); } else { mp_printf(print, ", alt=Pin.%q)", af_obj->name); } diff --git a/ports/stm32/timer.c b/ports/stm32/timer.c index 4ec467d9d..8aa0b3a2d 100644 --- a/ports/stm32/timer.c +++ b/ports/stm32/timer.c @@ -499,7 +499,7 @@ static uint32_t compute_dtg_from_ticks(mp_int_t ticks) { // Given the 8-bit value stored in the DTG field of the BDTR register, compute // the number of ticks. -static mp_int_t compute_ticks_from_dtg(uint32_t dtg) { +static unsigned compute_ticks_from_dtg(uint32_t dtg) { if ((dtg & 0x80) == 0) { return dtg & 0x7F; } |
