Skip to content

Commit 81eb658

Browse files
author
ldg-github-ci
committed
[update] Branch develop | Commit 39d7a183dc27fc499eb8198ca920c80402805a6a
1 parent 0de74c6 commit 81eb658

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

include/eth_internals.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,21 @@ void copy_parameter(uint8_t* dst, const uint8_t* parameter, uint8_t dst_size) {
256256
uint8_t copy_size = MIN(dst_size, PARAMETER_LENGTH);
257257
memmove(dst, parameter, copy_size);
258258
}
259+
260+
bool U2BE_from_parameter(const uint8_t* parameter, uint16_t* value) {
261+
if (allzeroes(parameter, PARAMETER_LENGTH - sizeof(uint16_t))) {
262+
*value = U2BE(parameter, PARAMETER_LENGTH - sizeof(uint16_t));
263+
return true;
264+
}
265+
266+
return false;
267+
}
268+
269+
bool U4BE_from_parameter(const uint8_t* parameter, uint32_t* value) {
270+
if (allzeroes(parameter, PARAMETER_LENGTH - sizeof(uint32_t))) {
271+
*value = U4BE(parameter, PARAMETER_LENGTH - sizeof(uint32_t));
272+
return true;
273+
}
274+
275+
return false;
276+
}

include/eth_internals.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ typedef union extraInfo_t {
6060
nftInfo_t nft;
6161
} extraInfo_t;
6262

63-
static __attribute__((no_instrument_function)) inline int allzeroes(void *buf, size_t n) {
63+
static __attribute__((no_instrument_function)) inline int allzeroes(const void *buf, size_t n) {
6464
uint8_t *p = (uint8_t *) buf;
6565
for (size_t i = 0; i < n; ++i) {
6666
if (p[i]) {
@@ -105,3 +105,7 @@ void u64_to_string(uint64_t src, char *dst, uint8_t dst_size);
105105
void copy_address(uint8_t* dst, const uint8_t* parameter, uint8_t dst_size);
106106

107107
void copy_parameter(uint8_t* dst, const uint8_t* parameter, uint8_t dst_size);
108+
109+
bool U2BE_from_parameter(const uint8_t* parameter, uint16_t* value);
110+
111+
bool U4BE_from_parameter(const uint8_t* parameter, uint32_t* value);

0 commit comments

Comments
 (0)