1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-12 18:49:07 +00:00

extmod: use size_t for mp_obj_get_array and mp_obj_tuple_get

This commit is contained in:
Jan Pochyla 2017-04-06 18:36:30 +02:00
parent cb8e957379
commit 9f985dba46
6 changed files with 9 additions and 9 deletions

View File

@ -47,7 +47,7 @@ STATIC mp_obj_t mod_TrezorCrypto_HDNode_derive_path(mp_obj_t self, mp_obj_t path
mp_obj_HDNode_t *o = MP_OBJ_TO_PTR(self);
// get path objects and length
mp_uint_t plen;
size_t plen;
mp_obj_t *pitems;
mp_obj_get_array(path, &plen, &pitems);
if (plen > 32) {

View File

@ -106,7 +106,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorCrypto_Ed25519_verify_obj,
/// Combines a list of public keys used in COSI cosigning scheme
/// '''
STATIC mp_obj_t mod_TrezorCrypto_Ed25519_cosi_combine_publickeys(mp_obj_t self, mp_obj_t public_keys) {
mp_uint_t pklen;
size_t pklen;
mp_obj_t *pkitems;
mp_obj_get_array(public_keys, &pklen, &pkitems);
if (pklen > 15) {
@ -140,7 +140,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Ed25519_cosi_combine_signatures(mp_obj_t self,
if (sigR.len != 32) {
mp_raise_ValueError("Invalid length of R");
}
mp_uint_t siglen;
size_t siglen;
mp_obj_t *sigitems;
mp_obj_get_array(signatures, &siglen, &sigitems);
if (siglen > 15) {

View File

@ -54,7 +54,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Random_bytes_obj, mod_TrezorCr
/// Shuffles items of given list (in-place)
/// '''
STATIC mp_obj_t mod_TrezorCrypto_Random_shuffle(mp_obj_t self, mp_obj_t data) {
mp_uint_t item_cnt;
size_t item_cnt;
mp_obj_t *items;
mp_obj_get_array(data, &item_cnt, &items);
if (item_cnt > 256) {

View File

@ -58,14 +58,14 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorCrypto_SSSS_split_obj, 4, 4
/// Combine M shares of Shamir's Secret Sharing Scheme into secret
/// '''
STATIC mp_obj_t mod_TrezorCrypto_SSSS_combine(mp_obj_t self, mp_obj_t shares) {
mp_uint_t n;
size_t n;
mp_obj_t *share;
mp_obj_get_array(shares, &n, &share);
if (n < 1 || n > 15) {
mp_raise_ValueError("Invalid number of shares");
}
bignum256 bnshares[n];
for (mp_uint_t i = 0; i < n; i++) {
for (size_t i = 0; i < n; i++) {
if (MP_OBJ_IS_TYPE(share[i], &mp_type_bytes)) {
mp_buffer_info_t s;
mp_get_buffer_raise(share[i], &s, MP_BUFFER_READ);

View File

@ -45,14 +45,14 @@ STATIC mp_obj_t mod_TrezorMsg_Msg_make_new(const mp_obj_type_t *type, size_t n_a
/// Configures USB interfaces with a list/tuple of (usage_page, ...)
/// '''
STATIC mp_obj_t mod_TrezorMsg_Msg_set_interfaces(mp_obj_t self, mp_obj_t ifaces) {
mp_uint_t iface_cnt;
size_t iface_cnt;
mp_obj_t *usage_pages;
mp_obj_get_array(ifaces, &iface_cnt, &usage_pages);
if (iface_cnt > MAX_INTERFACES) {
mp_raise_ValueError("Maximum number of interfaces exceeded");
}
mp_obj_Msg_t *o = MP_OBJ_TO_PTR(self);
for (mp_uint_t i = 0; i < iface_cnt; i++) {
for (size_t i = 0; i < iface_cnt; i++) {
uint16_t usage_page = mp_obj_get_int(usage_pages[i]);
o->usage_pages[i] = usage_page;
}

View File

@ -331,7 +331,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_backlight_obj, 1
STATIC mp_obj_t mod_TrezorUi_Display_offset(size_t n_args, const mp_obj_t *args) {
int xy[2], *ret;
if (n_args > 1) {
mp_uint_t xy_cnt;
size_t xy_cnt;
mp_obj_t *xy_obj;
if (MP_OBJ_IS_TYPE(args[1], &mp_type_tuple)) {
mp_obj_tuple_get(args[1], &xy_cnt, &xy_obj);