aboutsummaryrefslogtreecommitdiff
path: root/src/uint256.h
diff options
context:
space:
mode:
authorDwayne C. Litzenberger <dlitz@dlitz.net>2012-04-16 01:32:55 -0400
committerDwayne C. Litzenberger <dlitz@dlitz.net>2012-04-18 00:33:32 -0400
commit8c8e8c2e931b26905112faffb12f527f3256f5dc (patch)
tree103e2d753213c1deab5bb31a84905f772ef31c45 /src/uint256.h
parenta6fa147c8d2dabe9f226bb8e1bc5904718ef1fc1 (diff)
downloadbitcoin-8c8e8c2e931b26905112faffb12f527f3256f5dc.tar.xz
Fix bugs on 'unsigned char' platforms.
In ISO C++, the signedness of 'char' is undefined. On some platforms (e.g. ARM), 'char' is an unsigned type, but some of the code relies on 'char' being signed (as it is on x86). This is indicated by compiler warnings like this: bignum.h: In constructor 'CBigNum::CBigNum(char)': bignum.h:81:59: warning: comparison is always true due to limited range of data type [-Wtype-limits] util.cpp: In function 'bool IsHex(const string&)': util.cpp:427:28: warning: comparison is always false due to limited range of data type [-Wtype-limits] In particular, IsHex erroneously returned true regardless of the input characters, as long as the length of the string was a positive multiple of 2. Note: For testing, it's possible using GCC to force char to be unsigned by adding the -funsigned-char parameter to xCXXFLAGS.
Diffstat (limited to 'src/uint256.h')
-rw-r--r--src/uint256.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/uint256.h b/src/uint256.h
index bf3c55bccb..104b84970a 100644
--- a/src/uint256.h
+++ b/src/uint256.h
@@ -305,7 +305,7 @@ public:
psz += 2;
// hex string to uint
- static char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
+ static unsigned char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
const char* pbegin = psz;
while (phexdigit[(unsigned char)*psz] || *psz == '0')
psz++;