From 08b786e72d7b9bd91c159ea15dadab7aea6ea81b Mon Sep 17 00:00:00 2001 From: Francois Beutin Date: Thu, 18 Jan 2024 11:08:04 +0100 Subject: [PATCH] Remove unused big uint utilities --- {src_common => src}/uint128.c | 18 ++++++++++++++++++ {src_common => src}/uint128.h | 2 ++ {src_common => src}/uint256.c | 8 ++++++++ {src_common => src}/uint256.h | 1 + {src_common => src}/uint_common.c | 0 {src_common => src}/uint_common.h | 0 src_common/common_utils.c | 28 ---------------------------- src_common/common_utils.h | 5 ----- src_common/eth_plugin_interface.h | 3 --- 9 files changed, 29 insertions(+), 36 deletions(-) rename {src_common => src}/uint128.c (94%) rename {src_common => src}/uint128.h (93%) rename {src_common => src}/uint256.c (97%) rename {src_common => src}/uint256.h (96%) rename {src_common => src}/uint_common.c (100%) rename {src_common => src}/uint_common.h (100%) diff --git a/src_common/uint128.c b/src/uint128.c similarity index 94% rename from src_common/uint128.c rename to src/uint128.c index 54d8f6bd5a..b720e35c18 100644 --- a/src_common/uint128.c +++ b/src/uint128.c @@ -290,3 +290,21 @@ bool tostring128_signed(const uint128_t *const number, } return tostring128(number, base, out, out_length); // positive value } + +void convertUint64BEto128(const uint8_t *const data, uint32_t length, uint128_t *const target) { + uint8_t tmp[INT128_LENGTH]; + int64_t value; + + value = u64_from_BE(data, length); + memset(tmp, ((value < 0) ? 0xff : 0), sizeof(tmp) - length); + memmove(tmp + sizeof(tmp) - length, data, length); + readu128BE(tmp, target); +} + +void convertUint128BE(const uint8_t *const data, uint32_t length, uint128_t *const target) { + uint8_t tmp[INT128_LENGTH]; + + memset(tmp, 0, sizeof(tmp) - length); + memmove(tmp + sizeof(tmp) - length, data, length); + readu128BE(tmp, target); +} diff --git a/src_common/uint128.h b/src/uint128.h similarity index 93% rename from src_common/uint128.h rename to src/uint128.h index e1166c20b3..b857089c33 100644 --- a/src_common/uint128.h +++ b/src/uint128.h @@ -56,5 +56,7 @@ bool tostring128_signed(const uint128_t *const number, uint32_t base, char *const out, uint32_t out_length); +void convertUint64BEto128(const uint8_t *const data, uint32_t length, uint128_t *const target); +void convertUint128BE(const uint8_t *const data, uint32_t length, uint128_t *const target); #endif // _UINT128_H_ diff --git a/src_common/uint256.c b/src/uint256.c similarity index 97% rename from src_common/uint256.c rename to src/uint256.c index 21f3d92cde..8829c906df 100644 --- a/src_common/uint256.c +++ b/src/uint256.c @@ -289,3 +289,11 @@ bool tostring256_signed(const uint256_t *const number, } return tostring256(number, base, out, out_length); // positive value } + +void convertUint256BE(const uint8_t *const data, uint32_t length, uint256_t *const target) { + uint8_t tmp[INT256_LENGTH]; + + memset(tmp, 0, sizeof(tmp) - length); + memmove(tmp + sizeof(tmp) - length, data, length); + readu256BE(tmp, target); +} diff --git a/src_common/uint256.h b/src/uint256.h similarity index 96% rename from src_common/uint256.h rename to src/uint256.h index 97b8cfb1f7..4addf7f78b 100644 --- a/src_common/uint256.h +++ b/src/uint256.h @@ -57,5 +57,6 @@ bool tostring256_signed(const uint256_t *const number, uint32_t base, char *const out, uint32_t out_length); +void convertUint256BE(const uint8_t *const data, uint32_t length, uint256_t *const target); #endif // _UINT256_H_ diff --git a/src_common/uint_common.c b/src/uint_common.c similarity index 100% rename from src_common/uint_common.c rename to src/uint_common.c diff --git a/src_common/uint_common.h b/src/uint_common.h similarity index 100% rename from src_common/uint_common.h rename to src/uint_common.h diff --git a/src_common/common_utils.c b/src_common/common_utils.c index 049eebcada..84a424ea06 100644 --- a/src_common/common_utils.c +++ b/src_common/common_utils.c @@ -18,8 +18,6 @@ #include #include -#include "uint128.h" -#include "uint256.h" #include "asset_info.h" #include "common_utils.h" @@ -32,32 +30,6 @@ void array_hexstr(char *strbuf, const void *bin, unsigned int len) { *strbuf = 0; // EOS } -void convertUint64BEto128(const uint8_t *const data, uint32_t length, uint128_t *const target) { - uint8_t tmp[INT128_LENGTH]; - int64_t value; - - value = u64_from_BE(data, length); - memset(tmp, ((value < 0) ? 0xff : 0), sizeof(tmp) - length); - memmove(tmp + sizeof(tmp) - length, data, length); - readu128BE(tmp, target); -} - -void convertUint128BE(const uint8_t *const data, uint32_t length, uint128_t *const target) { - uint8_t tmp[INT128_LENGTH]; - - memset(tmp, 0, sizeof(tmp) - length); - memmove(tmp + sizeof(tmp) - length, data, length); - readu128BE(tmp, target); -} - -void convertUint256BE(const uint8_t *const data, uint32_t length, uint256_t *const target) { - uint8_t tmp[INT256_LENGTH]; - - memset(tmp, 0, sizeof(tmp) - length); - memmove(tmp + sizeof(tmp) - length, data, length); - readu256BE(tmp, target); -} - uint64_t u64_from_BE(const uint8_t *in, uint8_t size) { uint8_t i = 0; uint64_t res = 0; diff --git a/src_common/common_utils.h b/src_common/common_utils.h index c70cf5a1a2..fd198d95f8 100644 --- a/src_common/common_utils.h +++ b/src_common/common_utils.h @@ -22,7 +22,6 @@ #include "os.h" #include "cx.h" -#include "uint256.h" #define WEI_TO_ETHER 18 @@ -38,10 +37,6 @@ static const char HEXDIGITS[] = "0123456789abcdef"; void array_hexstr(char *strbuf, const void *bin, unsigned int len); -void convertUint128BE(const uint8_t *const data, uint32_t length, uint128_t *const target); -void convertUint256BE(const uint8_t *const data, uint32_t length, uint256_t *const target); -void convertUint64BEto128(const uint8_t *const data, uint32_t length, uint128_t *const target); - uint64_t u64_from_BE(const uint8_t *in, uint8_t size); bool u64_to_string(uint64_t src, char *dst, uint8_t dst_size); diff --git a/src_common/eth_plugin_interface.h b/src_common/eth_plugin_interface.h index 96609c1bbe..98218368ad 100644 --- a/src_common/eth_plugin_interface.h +++ b/src_common/eth_plugin_interface.h @@ -11,9 +11,6 @@ #include "common_utils.h" #include "plugin_utils.h" #include "tx_content.h" -#include "uint128.h" -#include "uint256.h" -#include "uint_common.h" /************************************************************************************************* * Comments provided in this file are quick reminders on the usage of the plugin interface *