Code improvements / Fix warnings

- Fix CodeQL warnings
- Port lots of improvements/fixes from PR #225
- replace 'array_hexstr' and '%*H' format by sdk function 'format_hex'
- Add 'noreturn' attribute in 'main.c'
This commit is contained in:
Charles-Edouard de la Vergne
2024-04-12 16:40:05 +02:00
parent 90d536402b
commit aa38ee9959
29 changed files with 103 additions and 71 deletions

View File

@@ -27,7 +27,7 @@ static void handle_init_contract(void *parameters) {
}
uint8_t i;
for (i = 0; i < SELECTORS_COUNT; i++) {
if (memcmp((uint8_t *) PIC(ERC1155_SELECTORS[i]), msg->selector, SELECTOR_SIZE) == 0) {
if (memcmp(PIC(ERC1155_SELECTORS[i]), msg->selector, SELECTOR_SIZE) == 0) {
context->selectorIndex = i;
break;
}

View File

@@ -64,7 +64,7 @@ const contract_t CONTRACTS[NUM_CONTRACTS] = {
bool check_contract(erc20_parameters_t *context) {
for (size_t i = 0; i < NUM_CONTRACTS; i++) {
contract_t *contract = (contract_t *) PIC(&CONTRACTS[i]);
const contract_t *contract = (const contract_t *) PIC(&CONTRACTS[i]);
if (memcmp(contract->address, context->destinationAddress, ADDRESS_LENGTH) == 0) {
strlcpy(context->contract_name, contract->name, sizeof(context->contract_name));
return true;

View File

@@ -32,7 +32,7 @@ static void handle_init_contract(void *parameters) {
}
uint8_t i;
for (i = 0; i < SELECTORS_COUNT; i++) {
if (memcmp((uint8_t *) PIC(ERC721_SELECTORS[i]), msg->selector, SELECTOR_SIZE) == 0) {
if (memcmp(PIC(ERC721_SELECTORS[i]), msg->selector, SELECTOR_SIZE) == 0) {
context->selectorIndex = i;
break;
}

View File

@@ -199,7 +199,7 @@ void eth2_plugin_call(int message, void *parameters) {
switch (msg->screenIndex) {
case 0: { // Amount screen
uint8_t decimals = WEI_TO_ETHER;
char *ticker = chainConfig->coinName;
const char *ticker = chainConfig->coinName;
strlcpy(msg->title, "Amount", msg->titleLength);
if (!amountToString(tmpContent.txContent.value.value,
tmpContent.txContent.value.length,