diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-12-04 14:49:34 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-12-07 14:50:15 (GMT) |
commit | 49a56b22b572b1167098e5f96a84e30cdc64f38c (patch) | |
tree | a61124807ce698e6586b7fe93f82d4f306ac078f /config.tests/mac | |
parent | bd83b34da7049f7743c69b5efe019745801d6c34 (diff) | |
download | Qt-49a56b22b572b1167098e5f96a84e30cdc64f38c.zip Qt-49a56b22b572b1167098e5f96a84e30cdc64f38c.tar.gz Qt-49a56b22b572b1167098e5f96a84e30cdc64f38c.tar.bz2 |
Fixed calculating CRC32 on 64bit platforms
When compiling on a 64bit machine we should make sure that we won't overflow
the 32bit CRC value because of casting signed int to unsigned long.
Reviewed-by: Thiago
Diffstat (limited to 'config.tests/mac')
-rw-r--r-- | config.tests/mac/crc/main.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/config.tests/mac/crc/main.cpp b/config.tests/mac/crc/main.cpp index 894f88b..700a4cd 100644 --- a/config.tests/mac/crc/main.cpp +++ b/config.tests/mac/crc/main.cpp @@ -71,7 +71,7 @@ private: for(int iCodes = 0; iCodes <= 0xFF; iCodes++) { ulTable[iCodes] = Reflect(iCodes, 8) << 24; for(int iPos = 0; iPos < 8; iPos++) { - ulTable[iCodes] = (ulTable[iCodes] << 1) + ulTable[iCodes] = ((ulTable[iCodes] << 1) & 0xffffffff) ^ ((ulTable[iCodes] & (1 << 31)) ? ulPolynomial : 0); } @@ -84,7 +84,7 @@ private: // Swap bit 0 for bit 7, bit 1 For bit 6, etc.... for(int iPos = 1; iPos < (cChar + 1); iPos++) { if(ulReflect & 1) { - ulValue |= (1 << (cChar - iPos)); + ulValue |= (1ul << (cChar - iPos)); } ulReflect >>= 1; } |