Skip to content

Commit

Permalink
remove GCC warnings ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
tdejoigny-ledger committed Nov 28, 2023
1 parent 8464a2c commit f35921a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 13 deletions.
27 changes: 22 additions & 5 deletions src/ui/bagl_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

#ifdef HAVE_BAGL

#pragma GCC diagnostic ignored "-Wformat-invalid-specifier" // snprintf
#pragma GCC diagnostic ignored "-Wformat-extra-args" // snprintf

#include <stdbool.h> // bool
#include <string.h> // memset

Expand Down Expand Up @@ -102,7 +99,17 @@ int ui_display_address() {
if (!address_from_pubkey(G_context.pk_info.raw_public_key, address, sizeof(address))) {
return io_send_sw(SW_DISPLAY_ADDRESS_FAIL);
}
snprintf(g_address, sizeof(g_address), "0x%.*H", sizeof(address), address);

if (format_hex(address,
sizeof(address),
g_address + 2, // keep 2 bytes for "0x"
sizeof(g_address) - 2) == -1) {
return io_send_sw(SW_DISPLAY_ADDRESS_FAIL);
}

// add "0x" at the beginning of address
g_address[0] = '0';
g_address[1] = 'x';

g_validate_callback = &ui_action_validate_pubkey;

Expand Down Expand Up @@ -157,7 +164,17 @@ int ui_display_transaction() {
PRINTF("Amount: %s\n", g_amount);

memset(g_address, 0, sizeof(g_address));
snprintf(g_address, sizeof(g_address), "0x%.*H", ADDRESS_LEN, G_context.tx_info.transaction.to);

if (format_hex(G_context.tx_info.transaction.to,
ADDRESS_LEN,
g_address + 2, // keep 2 bytes for "0x"
sizeof(g_address) - 2) == -1) {
return io_send_sw(SW_DISPLAY_ADDRESS_FAIL);
}

// add "0x" at the beginning of address
g_address[0] = '0';
g_address[1] = 'x';

g_validate_callback = &ui_action_validate_transaction;

Expand Down
15 changes: 11 additions & 4 deletions src/ui/nbgl_display_address.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

#ifdef HAVE_NBGL

#pragma GCC diagnostic ignored "-Wformat-invalid-specifier" // snprintf
#pragma GCC diagnostic ignored "-Wformat-extra-args" // snprintf

#include <stdbool.h> // bool
#include <string.h> // memset

Expand Down Expand Up @@ -75,7 +72,17 @@ int ui_display_address() {
if (!address_from_pubkey(G_context.pk_info.raw_public_key, address, sizeof(address))) {
return io_send_sw(SW_DISPLAY_ADDRESS_FAIL);
}
snprintf(g_address, sizeof(g_address), "0x%.*H", sizeof(address), address);

if (format_hex(address,
sizeof(address),
g_address + 2, // keep 2 bytes for "0x"
sizeof(g_address) - 2) == -1) {
return io_send_sw(SW_DISPLAY_ADDRESS_FAIL);
}

// add "0x" at the beginning of address
g_address[0] = '0';
g_address[1] = 'x';

nbgl_useCaseReviewStart(&C_app_boilerplate_64px,
"Verify BOL address",
Expand Down
15 changes: 11 additions & 4 deletions src/ui/nbgl_display_transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

#ifdef HAVE_NBGL

#pragma GCC diagnostic ignored "-Wformat-invalid-specifier" // snprintf
#pragma GCC diagnostic ignored "-Wformat-extra-args" // snprintf

#include <stdbool.h> // bool
#include <string.h> // memset

Expand Down Expand Up @@ -116,7 +113,17 @@ int ui_display_transaction() {
}
snprintf(g_amount, sizeof(g_amount), "BOL %.*s", sizeof(amount), amount);
memset(g_address, 0, sizeof(g_address));
snprintf(g_address, sizeof(g_address), "0x%.*H", ADDRESS_LEN, G_context.tx_info.transaction.to);

if (format_hex(G_context.tx_info.transaction.to,
ADDRESS_LEN,
g_address + 2, // keep 2 bytes for "0x"
sizeof(g_address) - 2) == -1) {
return io_send_sw(SW_DISPLAY_ADDRESS_FAIL);
}

// add "0x" at the beginning of address
g_address[0] = '0';
g_address[1] = 'x';

// Start review
nbgl_useCaseReviewStart(&C_app_boilerplate_64px,
Expand Down

0 comments on commit f35921a

Please sign in to comment.