From 1335dade2639b20aac9542cc0a397ba1c118c446 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 13 Apr 2014 21:41:00 +1000 Subject: [PATCH] Use this opportunity to avoid signed warnings with chars by taking void for hex2bin --- src/bitcoin.c | 3 ++- src/libckpool.c | 13 +++++++++---- src/libckpool.h | 6 +++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/bitcoin.c b/src/bitcoin.c index 1bde6477..c914be91 100644 --- a/src/bitcoin.c +++ b/src/bitcoin.c @@ -78,9 +78,10 @@ out: static bool gbt_merkle_bins(gbtbase_t *gbt, json_t *transaction_arr) { - char hashhex[68], *hashbin; int i, j, binleft, binlen; + char hashhex[68]; json_t *arr_val; + uchar *hashbin; dealloc(gbt->txn_data); gbt->transactions = 0; diff --git a/src/libckpool.c b/src/libckpool.c index 1301e26d..cb3788e8 100644 --- a/src/libckpool.c +++ b/src/libckpool.c @@ -626,9 +626,11 @@ void _dealloc(void **ptr) } /* Adequate size s==len*2 + 1 must be alloced to use this variant */ -void __bin2hex(uchar *s, const uchar *p, size_t len) +void __bin2hex(void *vs, const void *vp, size_t len) { static const char hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + const uchar *p = vp; + uchar *s = vs; int i; for (i = 0; i < (int)len; i++) { @@ -641,8 +643,9 @@ void __bin2hex(uchar *s, const uchar *p, size_t len) /* Returns a malloced array string of a binary value of arbitrary length. The * array is rounded up to a 4 byte size to appease architectures that need * aligned array sizes */ -void *bin2hex(const uchar *p, size_t len) +void *bin2hex(const void *vp, size_t len) { + const uchar *p = vp; size_t slen; uchar *s; @@ -673,11 +676,13 @@ static const int hex2bin_tbl[256] = { }; /* Does the reverse of bin2hex but does not allocate any ram */ -bool hex2bin(uchar *p, const uchar *hexstr, size_t len) +bool hex2bin(void *vp, const void *vhexstr, size_t len) { + const uchar *hexstr = vhexstr; int nibble1, nibble2; - uchar idx; bool ret = false; + uchar *p = vp; + uchar idx; while (*hexstr && len) { if (unlikely(!hexstr[1])) { diff --git a/src/libckpool.h b/src/libckpool.h index ea54f0a0..9e66371e 100644 --- a/src/libckpool.h +++ b/src/libckpool.h @@ -196,9 +196,9 @@ void realloc_strcat(char **ptr, const char *s); void *_ckalloc(size_t len, const char *file, const char *func, const int line); void *_ckzalloc(size_t len, const char *file, const char *func, const int line); void _dealloc(void **ptr); -void __bin2hex(uchar *s, const uchar *p, size_t len); -void *bin2hex(const uchar *p, size_t len); -bool hex2bin(uchar *p, const uchar *hexstr, size_t len); +void __bin2hex(void *vs, const void *vp, size_t len); +void *bin2hex(const void *vp, size_t len); +bool hex2bin(void *p, const void *vhexstr, size_t len); char *http_base64(const char *src); void b58tobin(char *b58bin, const char *b58);