mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-12 18:49:07 +00:00
extmod: replace mp_obj_tuple_get and mp_obj_list_get calls with mp_obj_get_array
This commit is contained in:
parent
9c3c19959b
commit
28e62c6270
@ -56,11 +56,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Random_bytes_obj, mod_TrezorCr
|
||||
STATIC mp_obj_t mod_TrezorCrypto_Random_shuffle(mp_obj_t self, mp_obj_t data) {
|
||||
mp_uint_t item_cnt;
|
||||
mp_obj_t *items;
|
||||
if (MP_OBJ_IS_TYPE(data, &mp_type_list)) {
|
||||
mp_obj_list_get(data, &item_cnt, &items);
|
||||
} else {
|
||||
mp_raise_TypeError("List expected");
|
||||
}
|
||||
mp_obj_get_array(data, &item_cnt, &items);
|
||||
if (item_cnt > 256) {
|
||||
mp_raise_ValueError("Maximum list size is 256 items");
|
||||
}
|
||||
|
@ -60,14 +60,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorCrypto_SSSS_split_obj, 4, 4
|
||||
STATIC mp_obj_t mod_TrezorCrypto_SSSS_combine(mp_obj_t self, mp_obj_t shares) {
|
||||
mp_uint_t n;
|
||||
mp_obj_t *share;
|
||||
if (MP_OBJ_IS_TYPE(shares, &mp_type_tuple)) {
|
||||
mp_obj_tuple_get(shares, &n, &share);
|
||||
} else
|
||||
if (MP_OBJ_IS_TYPE(shares, &mp_type_list)) {
|
||||
mp_obj_list_get(shares, &n, &share);
|
||||
} else {
|
||||
mp_raise_TypeError("List or tuple expected");
|
||||
}
|
||||
mp_obj_get_array(shares, &n, &share);
|
||||
if (n < 1 || n > 15) {
|
||||
mp_raise_ValueError("Invalid number of shares");
|
||||
}
|
||||
|
@ -47,14 +47,7 @@ STATIC mp_obj_t mod_TrezorMsg_Msg_make_new(const mp_obj_type_t *type, size_t n_a
|
||||
STATIC mp_obj_t mod_TrezorMsg_Msg_set_interfaces(mp_obj_t self, mp_obj_t ifaces) {
|
||||
mp_uint_t iface_cnt;
|
||||
mp_obj_t *usage_pages;
|
||||
if (MP_OBJ_IS_TYPE(ifaces, &mp_type_tuple)) {
|
||||
mp_obj_tuple_get(ifaces, &iface_cnt, &usage_pages);
|
||||
} else
|
||||
if (MP_OBJ_IS_TYPE(ifaces, &mp_type_list)) {
|
||||
mp_obj_list_get(ifaces, &iface_cnt, &usage_pages);
|
||||
} else {
|
||||
mp_raise_TypeError("List or tuple expected");
|
||||
}
|
||||
mp_obj_get_array(ifaces, &iface_cnt, &usage_pages);
|
||||
if (iface_cnt > MAX_INTERFACES) {
|
||||
mp_raise_ValueError("Maximum number of interfaces exceeded");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user