Skip to content

Commit

Permalink
Merge with latest zxlib version
Browse files Browse the repository at this point in the history
To remove CodeQL warnings.
  • Loading branch information
relatko committed Jan 4, 2024
1 parent 45b3c7b commit 24a4303
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 31 deletions.
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ endif
########################################

ifeq ($(DEBUG),1)
DEFINES += ZEMU_LOGGING=1
else
DEFINES += ZEMU_LOGGING=0
DEFINES += ZEMU_LOGGING
endif

#########################
Expand Down
12 changes: 1 addition & 11 deletions deps/ledger-zxlib/app/common/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "app_mode.h"
#ifdef HAVE_SWAP
#include "swap.h"
#endif
#endif // HAVE_SWAP

unsigned char G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B];

Expand Down Expand Up @@ -157,11 +157,6 @@ void app_init() {

#ifdef HAVE_BLE
// Enable Bluetooth
#ifdef HAVE_SWAP
if (G_swap_state.called_from_swap) {
memset(&G_io_asynch_ux_callback, 0, sizeof(G_io_asynch_ux_callback));
}
#endif // HAVE_SWAP
BLE_power(0, NULL);
BLE_power(1, NULL);
#endif // HAVE_BLE
Expand Down Expand Up @@ -220,11 +215,6 @@ void app_main() {
}
FINALLY;
{
#ifdef HAVE_SWAP
if (G_swap_state.called_from_swap && G_swap_state.should_exit) {
os_sched_exit(0);
}
#endif
}
}
END_TRY;
Expand Down
1 change: 1 addition & 0 deletions deps/ledger-zxlib/app/ui/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "view_internal.h"
#include "actions.h"
#include "zxmacros.h"

view_t viewdata;
unsigned int review_type = 0;
Expand Down
1 change: 1 addition & 0 deletions deps/ledger-zxlib/app/ui/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
********************************************************************************/
#pragma once

#include <stdbool.h>
#include <stdint.h>
#include "coin.h"
#include "zxerror.h"
Expand Down
1 change: 1 addition & 0 deletions deps/ledger-zxlib/app/ui/view_inspect_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "view_templates.h"
#include "ux.h"
#include "bagl.h"
#include "zxmacros.h"

static void h_inspect_button_left();
static void h_inspect_button_right();
Expand Down
1 change: 1 addition & 0 deletions deps/ledger-zxlib/app/ui/view_inspect_x.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "view_nano_inspect.h"
#include "view_templates.h"
#include "view_nano.h"
#include "zxmacros.h"

extern const ux_flow_step_t *ux_review_flow[MAX_REVIEW_UX_SCREENS];

Expand Down
7 changes: 3 additions & 4 deletions deps/ledger-zxlib/app/ui/view_nano_inspect.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "view_internal.h"
#include "view_templates.h"
#include "view_nano.h"
#include "zxmacros.h"

void h_inspect_init() {
ZEMU_LOGF(50, "h_inspect_init\n")
Expand All @@ -41,14 +42,12 @@ void view_inspect_init(viewfunc_getInnerItem_t view_funcGetInnerItem,
}

bool h_paging_inspect_go_to_root_screen() {
return (viewdata.innerField.level >= 0) &&
(viewdata.innerField.paging.itemIdx == 0)
return (viewdata.innerField.paging.itemIdx == 0)
&& (viewdata.innerField.trace[0] != 0);
}

bool h_paging_inspect_back_screen() {
return (viewdata.innerField.level >= 0) &&
(viewdata.innerField.paging.itemIdx == (viewdata.innerField.paging.itemCount - 1))
return (viewdata.innerField.paging.itemIdx == (viewdata.innerField.paging.itemCount - 1))
&& (viewdata.innerField.trace[0] != 0);
}

Expand Down
4 changes: 4 additions & 0 deletions deps/ledger-zxlib/app/ui/view_x.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ UX_FLOW_DEF_NOCB(ux_review_flow_2_review_title, pbb, { &C_icon_app, REVIEW_SCREE
UX_FLOW_DEF_NOCB(ux_review_flow_3_review_title, pbb, { &C_icon_app, "Review", "configuration",});

UX_STEP_INIT(ux_review_flow_2_start_step, NULL, NULL, { h_review_loop_start(); });
#ifdef HAVE_INSPECT
UX_STEP_CB_INIT(ux_review_flow_2_step, bnnn_paging, h_review_loop_inside(), inspect_init(), { .title = viewdata.key, .text = viewdata.value, });
#else
UX_STEP_NOCB_INIT(ux_review_flow_2_step, bnnn_paging, { h_review_loop_inside(); }, { .title = viewdata.key, .text = viewdata.value, });
#endif
UX_STEP_INIT(ux_review_flow_2_end_step, NULL, NULL, { h_review_loop_end(); });
UX_STEP_VALID(ux_review_flow_3_step, pb, h_approve(0), { &C_icon_validate_14, APPROVE_LABEL });
UX_STEP_VALID(ux_review_flow_4_step, pb, h_reject(review_type), { &C_icon_crossmark, REJECT_LABEL });
Expand Down
1 change: 1 addition & 0 deletions deps/ledger-zxlib/include/segwit_addr.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define _SEGWIT_ADDR_H_ 1

#include <stdint.h>
#include <stddef.h>

/** Encode a SegWit address
*
Expand Down
4 changes: 2 additions & 2 deletions deps/ledger-zxlib/include/utf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ utf8_int8_t *c = utf8_null;
size_t bytes = 0;

/* Find the end of the string or stop when n is reached */
while ('\0' != src[bytes] && bytes < n) {
while (bytes < n && '\0' != src[bytes]) {
bytes++;
}

Expand All @@ -722,7 +722,7 @@ return utf8_null;
bytes = 0;

/* copy src byte-by-byte into our new utf8 string */
while ('\0' != src[bytes] && bytes < n) {
while (bytes < n && '\0' != src[bytes]) {
c[bytes] = src[bytes];
bytes++;
}
Expand Down
16 changes: 10 additions & 6 deletions deps/ledger-zxlib/include/zxformat.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,20 +413,24 @@ __Z_INLINE void pageStringHex(char *outValue, uint16_t outValueLen,
if (inValueLen == 0) {
return;
}
const uint16_t msgHexLen = inValueLen * 2;
// Last char from OutVal will be filled with a null terminator in array_to_hexstr function
*pageCount = (uint8_t) (msgHexLen / (outValueLen - 1) );
const uint16_t lastChunkLen = (msgHexLen % (outValueLen - 1));
// leaving space for null terminator
const uint16_t bytesPerPage = (outValueLen - 1) / 2;
*pageCount = (uint8_t) (inValueLen / bytesPerPage);
const uint16_t lastChunkLen = inValueLen % bytesPerPage;

if (lastChunkLen > 0) {
(*pageCount)++;
}

if (pageIdx < *pageCount) {
if (lastChunkLen > 0 && pageIdx == *pageCount - 1) {
array_to_hexstr(outValue, outValueLen, (const uint8_t*)inValue+(pageIdx * (outValueLen/2)), lastChunkLen/2);
array_to_hexstr(outValue, outValueLen,
(const uint8_t *)inValue + pageIdx * bytesPerPage,
lastChunkLen);
} else {
array_to_hexstr(outValue, outValueLen, (const uint8_t*)inValue+(pageIdx * (outValueLen/2)), outValueLen/2);
array_to_hexstr(outValue, outValueLen,
(const uint8_t *)inValue + pageIdx * bytesPerPage,
bytesPerPage);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion deps/ledger-zxlib/include/zxmacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ if( os_global_pin_is_validated() != BOLOS_UX_OK ) { \
}

#if (defined (TARGET_NANOS) || defined(TARGET_NANOX) || defined(TARGET_NANOS2) || defined(TARGET_STAX))
#if (ZEMU_LOGGING)
#if defined(ZEMU_LOGGING)
__Z_INLINE void zemu_log(const char *buf)
{
/*
Expand Down
12 changes: 10 additions & 2 deletions deps/ledger-zxlib/include/zxmacros_ledger.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ extern unsigned int app_stack_canary;
if (__cx_err != CX_OK) { \
return __cx_err; \
} \
} while (0);
} while (0)


#define CATCH_CXERROR(CALL) \
Expand All @@ -76,6 +76,14 @@ extern unsigned int app_stack_canary;
if (__cx_err != CX_OK) { \
goto catch_cx_error; \
} \
} while (0);
} while (0)

#define CHECK_CX_OK(CALL) \
do { \
cx_err_t __cx_err = CALL; \
if (__cx_err != CX_OK) { \
return zxerr_unknown; \
} \
} while (0)

#endif
4 changes: 2 additions & 2 deletions deps/ledger-zxlib/include/zxversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
********************************************************************************/
#pragma once

#define ZXLIB_MAJOR 19
#define ZXLIB_MINOR 8
#define ZXLIB_MAJOR 21
#define ZXLIB_MINOR 0
#define ZXLIB_PATCH 2

0 comments on commit 24a4303

Please sign in to comment.