Unify all the hex digits used in the app

This commit is contained in:
Alexandre Paillier
2022-06-07 14:44:01 +02:00
parent f99804de08
commit 10fbb8d5bc
6 changed files with 5 additions and 12 deletions

View File

@@ -24,13 +24,10 @@
#include "tokens.h"
#include "utils.h"
static const unsigned char hex_digits[] =
{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
void array_hexstr(char *strbuf, const void *bin, unsigned int len) {
while (len--) {
*strbuf++ = hex_digits[((*((char *) bin)) >> 4) & 0xF];
*strbuf++ = hex_digits[(*((char *) bin)) & 0xF];
*strbuf++ = HEXDIGITS[((*((char *) bin)) >> 4) & 0xF];
*strbuf++ = HEXDIGITS[(*((char *) bin)) & 0xF];
bin = (const void *) ((unsigned int) bin + 1);
}
*strbuf = 0; // EOS

View File

@@ -27,8 +27,6 @@
#include <stdint.h>
#include <string.h>
#include "os.h"
#include "cx.h"
#include "ethUtils.h"
#include "chainConfig.h"
#include "ethUstream.h"

View File

@@ -21,6 +21,7 @@
#include <string.h>
#include "uint128.h"
#include "uint_common.h"
#include "ethUtils.h" // HEXDIGITS
void readu128BE(const uint8_t *const buffer, uint128_t *const target) {
UPPER_P(target) = readUint64BE(buffer);

View File

@@ -19,9 +19,10 @@
#include <stdio.h>
#include <string.h>
#include "ethUstream.h" // INT256_LENGTH
#include "uint256.h"
#include "uint_common.h"
#include "ethUstream.h" // INT256_LENGTH
#include "ethUtils.h" // HEXDIGITS
void readu256BE(const uint8_t *const buffer, uint256_t *const target) {
readu128BE(buffer, &UPPER_P(target));

View File

@@ -19,8 +19,6 @@
#include "uint_common.h"
const char HEXDIGITS[] = "0123456789abcdef";
void write_u64_be(uint8_t *const buffer, uint64_t value) {
buffer[0] = ((value >> 56) & 0xff);
buffer[1] = ((value >> 48) & 0xff);

View File

@@ -27,8 +27,6 @@
#define UPPER(x) x.elements[0]
#define LOWER(x) x.elements[1]
extern const char HEXDIGITS[];
void write_u64_be(uint8_t *const buffer, uint64_t value);
void read_u64_be(const uint8_t *const in, uint64_t *const out);
uint64_t readUint64BE(const uint8_t *const buffer);