1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-27 08:38:07 +00:00

core/embed: use MP_ROM_INT instead of MP_OBJ_NEW_SMALL_INT where intended

This commit is contained in:
Pavol Rusnak 2019-05-13 16:52:21 +02:00
parent 1dc2ccf4a5
commit 35945239eb
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
18 changed files with 48 additions and 72 deletions

View File

@ -184,11 +184,11 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_AES_locals_dict_table[] = {
MP_ROM_PTR(&mod_trezorcrypto_AES_decrypt_obj)},
{MP_ROM_QSTR(MP_QSTR___del__),
MP_ROM_PTR(&mod_trezorcrypto_AES___del___obj)},
{MP_ROM_QSTR(MP_QSTR_ECB), MP_OBJ_NEW_SMALL_INT(ECB)},
{MP_ROM_QSTR(MP_QSTR_CBC), MP_OBJ_NEW_SMALL_INT(CBC)},
{MP_ROM_QSTR(MP_QSTR_CFB), MP_OBJ_NEW_SMALL_INT(CFB)},
{MP_ROM_QSTR(MP_QSTR_OFB), MP_OBJ_NEW_SMALL_INT(OFB)},
{MP_ROM_QSTR(MP_QSTR_CTR), MP_OBJ_NEW_SMALL_INT(CTR)},
{MP_ROM_QSTR(MP_QSTR_ECB), MP_ROM_INT(ECB)},
{MP_ROM_QSTR(MP_QSTR_CBC), MP_ROM_INT(CBC)},
{MP_ROM_QSTR(MP_QSTR_CFB), MP_ROM_INT(CFB)},
{MP_ROM_QSTR(MP_QSTR_OFB), MP_ROM_INT(OFB)},
{MP_ROM_QSTR(MP_QSTR_CTR), MP_ROM_INT(CTR)},
};
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_AES_locals_dict,
mod_trezorcrypto_AES_locals_dict_table);

View File

@ -100,10 +100,8 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_Blake256_locals_dict_table[] = {
MP_ROM_PTR(&mod_trezorcrypto_Blake256_digest_obj)},
{MP_ROM_QSTR(MP_QSTR___del__),
MP_ROM_PTR(&mod_trezorcrypto_Blake256___del___obj)},
{MP_ROM_QSTR(MP_QSTR_block_size),
MP_OBJ_NEW_SMALL_INT(BLAKE256_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size),
MP_OBJ_NEW_SMALL_INT(BLAKE256_DIGEST_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_block_size), MP_ROM_INT(BLAKE256_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size), MP_ROM_INT(BLAKE256_DIGEST_LENGTH)},
};
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Blake256_locals_dict,
mod_trezorcrypto_Blake256_locals_dict_table);

View File

@ -149,10 +149,8 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_Blake2b_locals_dict_table[] = {
MP_ROM_PTR(&mod_trezorcrypto_Blake2b_digest_obj)},
{MP_ROM_QSTR(MP_QSTR___del__),
MP_ROM_PTR(&mod_trezorcrypto_Blake2b___del___obj)},
{MP_ROM_QSTR(MP_QSTR_block_size),
MP_OBJ_NEW_SMALL_INT(BLAKE2B_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size),
MP_OBJ_NEW_SMALL_INT(BLAKE2B_DIGEST_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_block_size), MP_ROM_INT(BLAKE2B_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size), MP_ROM_INT(BLAKE2B_DIGEST_LENGTH)},
};
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Blake2b_locals_dict,
mod_trezorcrypto_Blake2b_locals_dict_table);

View File

@ -149,10 +149,8 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_Blake2s_locals_dict_table[] = {
MP_ROM_PTR(&mod_trezorcrypto_Blake2s_digest_obj)},
{MP_ROM_QSTR(MP_QSTR___del__),
MP_ROM_PTR(&mod_trezorcrypto_Blake2s___del___obj)},
{MP_ROM_QSTR(MP_QSTR_block_size),
MP_OBJ_NEW_SMALL_INT(BLAKE2S_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size),
MP_OBJ_NEW_SMALL_INT(BLAKE2S_DIGEST_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_block_size), MP_ROM_INT(BLAKE2S_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size), MP_ROM_INT(BLAKE2S_DIGEST_LENGTH)},
};
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Blake2s_locals_dict,
mod_trezorcrypto_Blake2s_locals_dict_table);

View File

@ -105,10 +105,9 @@ STATIC const mp_rom_map_elem_t
MP_ROM_PTR(&mod_trezorcrypto_Groestl512_digest_obj)},
{MP_ROM_QSTR(MP_QSTR___del__),
MP_ROM_PTR(&mod_trezorcrypto_Groestl512___del___obj)},
{MP_ROM_QSTR(MP_QSTR_block_size),
MP_OBJ_NEW_SMALL_INT(GROESTL512_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_block_size), MP_ROM_INT(GROESTL512_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size),
MP_OBJ_NEW_SMALL_INT(GROESTL512_DIGEST_LENGTH)},
MP_ROM_INT(GROESTL512_DIGEST_LENGTH)},
};
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Groestl512_locals_dict,
mod_trezorcrypto_Groestl512_locals_dict_table);

View File

@ -1348,10 +1348,8 @@ STATIC const mp_rom_map_elem_t
MP_ROM_PTR(&mod_trezorcrypto_monero_hasher_copy_obj)},
{MP_ROM_QSTR(MP_QSTR___del__),
MP_ROM_PTR(&mod_trezorcrypto_monero_hasher___del___obj)},
{MP_ROM_QSTR(MP_QSTR_block_size),
MP_OBJ_NEW_SMALL_INT(SHA3_256_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size),
MP_OBJ_NEW_SMALL_INT(SHA3_256_DIGEST_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_block_size), MP_ROM_INT(SHA3_256_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size), MP_ROM_INT(SHA3_256_DIGEST_LENGTH)},
};
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_monero_hasher_locals_dict,
mod_trezorcrypto_monero_hasher_locals_dict_table);

View File

@ -149,8 +149,8 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_Pbkdf2_locals_dict_table[] = {
{MP_ROM_QSTR(MP_QSTR_key), MP_ROM_PTR(&mod_trezorcrypto_Pbkdf2_key_obj)},
{MP_ROM_QSTR(MP_QSTR___del__),
MP_ROM_PTR(&mod_trezorcrypto_Pbkdf2___del___obj)},
{MP_ROM_QSTR(MP_QSTR_HMAC_SHA256), MP_OBJ_NEW_SMALL_INT(PRF_HMAC_SHA256)},
{MP_ROM_QSTR(MP_QSTR_HMAC_SHA512), MP_OBJ_NEW_SMALL_INT(PRF_HMAC_SHA512)},
{MP_ROM_QSTR(MP_QSTR_HMAC_SHA256), MP_ROM_INT(PRF_HMAC_SHA256)},
{MP_ROM_QSTR(MP_QSTR_HMAC_SHA512), MP_ROM_INT(PRF_HMAC_SHA512)},
};
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Pbkdf2_locals_dict,
mod_trezorcrypto_Pbkdf2_locals_dict_table);

View File

@ -102,10 +102,8 @@ STATIC const mp_rom_map_elem_t
MP_ROM_PTR(&mod_trezorcrypto_Ripemd160_digest_obj)},
{MP_ROM_QSTR(MP_QSTR___del__),
MP_ROM_PTR(&mod_trezorcrypto_Ripemd160___del___obj)},
{MP_ROM_QSTR(MP_QSTR_block_size),
MP_OBJ_NEW_SMALL_INT(RIPEMD160_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size),
MP_OBJ_NEW_SMALL_INT(RIPEMD160_DIGEST_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_block_size), MP_ROM_INT(RIPEMD160_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size), MP_ROM_INT(RIPEMD160_DIGEST_LENGTH)},
};
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Ripemd160_locals_dict,
mod_trezorcrypto_Ripemd160_locals_dict_table);

View File

@ -247,9 +247,8 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_secp256k1_globals_table[] = {
{MP_ROM_QSTR(MP_QSTR_multiply),
MP_ROM_PTR(&mod_trezorcrypto_secp256k1_multiply_obj)},
{MP_ROM_QSTR(MP_QSTR_CANONICAL_SIG_ETHEREUM),
MP_OBJ_NEW_SMALL_INT(CANONICAL_SIG_ETHEREUM)},
{MP_ROM_QSTR(MP_QSTR_CANONICAL_SIG_EOS),
MP_OBJ_NEW_SMALL_INT(CANONICAL_SIG_EOS)},
MP_ROM_INT(CANONICAL_SIG_ETHEREUM)},
{MP_ROM_QSTR(MP_QSTR_CANONICAL_SIG_EOS), MP_ROM_INT(CANONICAL_SIG_EOS)},
};
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_secp256k1_globals,
mod_trezorcrypto_secp256k1_globals_table);

View File

@ -100,9 +100,8 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_Sha1_locals_dict_table[] = {
MP_ROM_PTR(&mod_trezorcrypto_Sha1_digest_obj)},
{MP_ROM_QSTR(MP_QSTR___del__),
MP_ROM_PTR(&mod_trezorcrypto_Sha1___del___obj)},
{MP_ROM_QSTR(MP_QSTR_block_size), MP_OBJ_NEW_SMALL_INT(SHA1_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size),
MP_OBJ_NEW_SMALL_INT(SHA1_DIGEST_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_block_size), MP_ROM_INT(SHA1_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size), MP_ROM_INT(SHA1_DIGEST_LENGTH)},
};
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Sha1_locals_dict,
mod_trezorcrypto_Sha1_locals_dict_table);

View File

@ -100,10 +100,8 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_Sha256_locals_dict_table[] = {
MP_ROM_PTR(&mod_trezorcrypto_Sha256_digest_obj)},
{MP_ROM_QSTR(MP_QSTR___del__),
MP_ROM_PTR(&mod_trezorcrypto_Sha256___del___obj)},
{MP_ROM_QSTR(MP_QSTR_block_size),
MP_OBJ_NEW_SMALL_INT(SHA256_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size),
MP_OBJ_NEW_SMALL_INT(SHA256_DIGEST_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_block_size), MP_ROM_INT(SHA256_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size), MP_ROM_INT(SHA256_DIGEST_LENGTH)},
};
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Sha256_locals_dict,
mod_trezorcrypto_Sha256_locals_dict_table);

View File

@ -136,10 +136,8 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_Sha3_256_locals_dict_table[] = {
MP_ROM_PTR(&mod_trezorcrypto_Sha3_256_copy_obj)},
{MP_ROM_QSTR(MP_QSTR___del__),
MP_ROM_PTR(&mod_trezorcrypto_Sha3_256___del___obj)},
{MP_ROM_QSTR(MP_QSTR_block_size),
MP_OBJ_NEW_SMALL_INT(SHA3_256_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size),
MP_OBJ_NEW_SMALL_INT(SHA3_256_DIGEST_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_block_size), MP_ROM_INT(SHA3_256_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size), MP_ROM_INT(SHA3_256_DIGEST_LENGTH)},
};
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Sha3_256_locals_dict,
mod_trezorcrypto_Sha3_256_locals_dict_table);

View File

@ -136,10 +136,8 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_Sha3_512_locals_dict_table[] = {
MP_ROM_PTR(&mod_trezorcrypto_Sha3_512_copy_obj)},
{MP_ROM_QSTR(MP_QSTR___del__),
MP_ROM_PTR(&mod_trezorcrypto_Sha3_512___del___obj)},
{MP_ROM_QSTR(MP_QSTR_block_size),
MP_OBJ_NEW_SMALL_INT(SHA3_512_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size),
MP_OBJ_NEW_SMALL_INT(SHA3_512_DIGEST_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_block_size), MP_ROM_INT(SHA3_512_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size), MP_ROM_INT(SHA3_512_DIGEST_LENGTH)},
};
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Sha3_512_locals_dict,
mod_trezorcrypto_Sha3_512_locals_dict_table);

View File

@ -99,10 +99,8 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_Sha512_locals_dict_table[] = {
MP_ROM_PTR(&mod_trezorcrypto_Sha512_digest_obj)},
{MP_ROM_QSTR(MP_QSTR___del__),
MP_ROM_PTR(&mod_trezorcrypto_Sha512___del___obj)},
{MP_ROM_QSTR(MP_QSTR_block_size),
MP_OBJ_NEW_SMALL_INT(SHA512_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size),
MP_OBJ_NEW_SMALL_INT(SHA512_DIGEST_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_block_size), MP_ROM_INT(SHA512_BLOCK_LENGTH)},
{MP_ROM_QSTR(MP_QSTR_digest_size), MP_ROM_INT(SHA512_DIGEST_LENGTH)},
};
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Sha512_locals_dict,
mod_trezorcrypto_Sha512_locals_dict_table);

View File

@ -119,7 +119,7 @@ STATIC const mp_rom_map_elem_t mod_trezorio_SDCard_locals_dict_table[] = {
{MP_ROM_QSTR(MP_QSTR_power), MP_ROM_PTR(&mod_trezorio_SDCard_power_obj)},
{MP_ROM_QSTR(MP_QSTR_capacity),
MP_ROM_PTR(&mod_trezorio_SDCard_capacity_obj)},
{MP_ROM_QSTR(MP_QSTR_block_size), MP_OBJ_NEW_SMALL_INT(SDCARD_BLOCK_SIZE)},
{MP_ROM_QSTR(MP_QSTR_block_size), MP_ROM_INT(SDCARD_BLOCK_SIZE)},
{MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mod_trezorio_SDCard_read_obj)},
{MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mod_trezorio_SDCard_write_obj)},
};

View File

@ -59,16 +59,13 @@ STATIC const mp_rom_map_elem_t mp_module_trezorio_globals_table[] = {
{MP_ROM_QSTR(MP_QSTR_WebUSB), MP_ROM_PTR(&mod_trezorio_WebUSB_type)},
{MP_ROM_QSTR(MP_QSTR_poll), MP_ROM_PTR(&mod_trezorio_poll_obj)},
{MP_ROM_QSTR(MP_QSTR_POLL_READ), MP_OBJ_NEW_SMALL_INT(POLL_READ)},
{MP_ROM_QSTR(MP_QSTR_POLL_WRITE), MP_OBJ_NEW_SMALL_INT(POLL_WRITE)},
{MP_ROM_QSTR(MP_QSTR_POLL_READ), MP_ROM_INT(POLL_READ)},
{MP_ROM_QSTR(MP_QSTR_POLL_WRITE), MP_ROM_INT(POLL_WRITE)},
{MP_ROM_QSTR(MP_QSTR_TOUCH), MP_OBJ_NEW_SMALL_INT(TOUCH_IFACE)},
{MP_ROM_QSTR(MP_QSTR_TOUCH_START),
MP_OBJ_NEW_SMALL_INT((TOUCH_START >> 24) & 0xFFU)},
{MP_ROM_QSTR(MP_QSTR_TOUCH_MOVE),
MP_OBJ_NEW_SMALL_INT((TOUCH_MOVE >> 24) & 0xFFU)},
{MP_ROM_QSTR(MP_QSTR_TOUCH_END),
MP_OBJ_NEW_SMALL_INT((TOUCH_END >> 24) & 0xFFU)},
{MP_ROM_QSTR(MP_QSTR_TOUCH), MP_ROM_INT(TOUCH_IFACE)},
{MP_ROM_QSTR(MP_QSTR_TOUCH_START), MP_ROM_INT((TOUCH_START >> 24) & 0xFFU)},
{MP_ROM_QSTR(MP_QSTR_TOUCH_MOVE), MP_ROM_INT((TOUCH_MOVE >> 24) & 0xFFU)},
{MP_ROM_QSTR(MP_QSTR_TOUCH_END), MP_ROM_INT((TOUCH_END >> 24) & 0xFFU)},
};
STATIC MP_DEFINE_CONST_DICT(mp_module_trezorio_globals,

View File

@ -510,13 +510,13 @@ STATIC const mp_rom_map_elem_t mod_trezorui_Display_locals_dict_table[] = {
MP_ROM_PTR(&mod_trezorui_Display_backlight_obj)},
{MP_ROM_QSTR(MP_QSTR_offset), MP_ROM_PTR(&mod_trezorui_Display_offset_obj)},
{MP_ROM_QSTR(MP_QSTR_save), MP_ROM_PTR(&mod_trezorui_Display_save_obj)},
{MP_ROM_QSTR(MP_QSTR_WIDTH), MP_OBJ_NEW_SMALL_INT(DISPLAY_RESX)},
{MP_ROM_QSTR(MP_QSTR_HEIGHT), MP_OBJ_NEW_SMALL_INT(DISPLAY_RESY)},
{MP_ROM_QSTR(MP_QSTR_FONT_SIZE), MP_OBJ_NEW_SMALL_INT(FONT_SIZE)},
{MP_ROM_QSTR(MP_QSTR_FONT_NORMAL), MP_OBJ_NEW_SMALL_INT(FONT_NORMAL)},
{MP_ROM_QSTR(MP_QSTR_FONT_BOLD), MP_OBJ_NEW_SMALL_INT(FONT_BOLD)},
{MP_ROM_QSTR(MP_QSTR_FONT_MONO), MP_OBJ_NEW_SMALL_INT(FONT_MONO)},
{MP_ROM_QSTR(MP_QSTR_FONT_MONO_BOLD), MP_OBJ_NEW_SMALL_INT(FONT_MONO_BOLD)},
{MP_ROM_QSTR(MP_QSTR_WIDTH), MP_ROM_INT(DISPLAY_RESX)},
{MP_ROM_QSTR(MP_QSTR_HEIGHT), MP_ROM_INT(DISPLAY_RESY)},
{MP_ROM_QSTR(MP_QSTR_FONT_SIZE), MP_ROM_INT(FONT_SIZE)},
{MP_ROM_QSTR(MP_QSTR_FONT_NORMAL), MP_ROM_INT(FONT_NORMAL)},
{MP_ROM_QSTR(MP_QSTR_FONT_BOLD), MP_ROM_INT(FONT_BOLD)},
{MP_ROM_QSTR(MP_QSTR_FONT_MONO), MP_ROM_INT(FONT_MONO)},
{MP_ROM_QSTR(MP_QSTR_FONT_MONO_BOLD), MP_ROM_INT(FONT_MONO_BOLD)},
};
STATIC MP_DEFINE_CONST_DICT(mod_trezorui_Display_locals_dict,
mod_trezorui_Display_locals_dict_table);

View File

@ -131,9 +131,9 @@ STATIC const mp_rom_map_elem_t mp_module_trezorutils_globals_table[] = {
MP_ROM_PTR(&mod_trezorutils_set_mode_unprivileged_obj)},
// various built-in constants
{MP_ROM_QSTR(MP_QSTR_GITREV), MP_ROM_QSTR(MP_QSTR(GITREV))},
{MP_ROM_QSTR(MP_QSTR_VERSION_MAJOR), MP_OBJ_NEW_SMALL_INT(VERSION_MAJOR)},
{MP_ROM_QSTR(MP_QSTR_VERSION_MINOR), MP_OBJ_NEW_SMALL_INT(VERSION_MINOR)},
{MP_ROM_QSTR(MP_QSTR_VERSION_PATCH), MP_OBJ_NEW_SMALL_INT(VERSION_PATCH)},
{MP_ROM_QSTR(MP_QSTR_VERSION_MAJOR), MP_ROM_INT(VERSION_MAJOR)},
{MP_ROM_QSTR(MP_QSTR_VERSION_MINOR), MP_ROM_INT(VERSION_MINOR)},
{MP_ROM_QSTR(MP_QSTR_VERSION_PATCH), MP_ROM_INT(VERSION_PATCH)},
{MP_ROM_QSTR(MP_QSTR_MODEL), MP_ROM_QSTR(MP_QSTR(TREZOR_MODEL))},
#ifdef TREZOR_EMULATOR
{MP_ROM_QSTR(MP_QSTR_EMULATOR), mp_const_true},