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>
This commit is contained in:
Jeff Epler 2025-07-06 08:14:31 +01:00 committed by Damien George
parent ee4f27affa
commit 87b7a9d734
5 changed files with 5 additions and 5 deletions

View file

@ -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[] = {

View file

@ -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)

View file

@ -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");

View file

@ -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);
}

View file

@ -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;
}