diff options
author | Brad King <brad.king@kitware.com> | 2011-11-17 16:07:43 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2011-11-17 16:07:43 (GMT) |
commit | 24b1feb5ca9dbc3461d373e4de30a33157f81375 (patch) | |
tree | 2dab4fb6e933ab11dccd217630398e9115def20b /Source/cm_sha2.c | |
parent | 1ec3fa00c920ca0d13ef30965ce2560ecd006e0c (diff) | |
download | CMake-24b1feb5ca9dbc3461d373e4de30a33157f81375.zip CMake-24b1feb5ca9dbc3461d373e4de30a33157f81375.tar.gz CMake-24b1feb5ca9dbc3461d373e4de30a33157f81375.tar.bz2 |
sha2: Cast safe conversions to smaller integer types
Add a cast to lines converting "uint64_t" to "unsigned int" that are
known safe due to use of modulus with a small integer. This avoids
compiler warnings such as
conversion from 'cm_sha2_uint64_t' to 'unsigned int',
possible loss of data
from MSVC.
Diffstat (limited to 'Source/cm_sha2.c')
-rw-r--r-- | Source/cm_sha2.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Source/cm_sha2.c b/Source/cm_sha2.c index b89f8fe..7991d27 100644 --- a/Source/cm_sha2.c +++ b/Source/cm_sha2.c @@ -652,7 +652,7 @@ void SHA1_Update(SHA_CTX* context, const sha_byte *data, size_t len) { /* Sanity check: */ assert(context != (SHA_CTX*)0 && data != (sha_byte*)0); - usedspace = (context->s1.bitcount >> 3) % 64; + usedspace = (unsigned int)((context->s1.bitcount >> 3) % 64); if (usedspace > 0) { /* Calculate how much free space is available in the buffer */ freespace = 64 - usedspace; @@ -705,7 +705,7 @@ void SHA1_Final(sha_byte digest[], SHA_CTX* context) { return; } - usedspace = (context->s1.bitcount >> 3) % 64; + usedspace = (unsigned int)((context->s1.bitcount >> 3) % 64); if (usedspace == 0) { /* Set-up for the last transform: */ MEMSET_BZERO(context->s1.buffer, 56); @@ -992,7 +992,7 @@ void SHA256_Update(SHA_CTX* context, const sha_byte *data, size_t len) { /* Sanity check: */ assert(context != (SHA_CTX*)0 && data != (sha_byte*)0); - usedspace = (context->s256.bitcount >> 3) % 64; + usedspace = (unsigned int)((context->s256.bitcount >> 3) % 64); if (usedspace > 0) { /* Calculate how much free space is available in the buffer */ freespace = 64 - usedspace; @@ -1032,7 +1032,7 @@ void SHA256_Update(SHA_CTX* context, const sha_byte *data, size_t len) { void SHA256_Internal_Last(SHA_CTX* context) { unsigned int usedspace; - usedspace = (context->s256.bitcount >> 3) % 64; + usedspace = (unsigned int)((context->s256.bitcount >> 3) % 64); #if BYTE_ORDER == LITTLE_ENDIAN /* Convert FROM host byte order */ REVERSE64(context->s256.bitcount,context->s256.bitcount); @@ -1399,7 +1399,7 @@ void SHA512_Update(SHA_CTX* context, const sha_byte *data, size_t len) { /* Sanity check: */ assert(context != (SHA_CTX*)0 && data != (sha_byte*)0); - usedspace = (context->s512.bitcount[0] >> 3) % 128; + usedspace = (unsigned int)((context->s512.bitcount[0] >> 3) % 128); if (usedspace > 0) { /* Calculate how much free space is available in the buffer */ freespace = 128 - usedspace; @@ -1439,7 +1439,7 @@ void SHA512_Update(SHA_CTX* context, const sha_byte *data, size_t len) { void SHA512_Internal_Last(SHA_CTX* context) { unsigned int usedspace; - usedspace = (context->s512.bitcount[0] >> 3) % 128; + usedspace = (unsigned int)((context->s512.bitcount[0] >> 3) % 128); #if BYTE_ORDER == LITTLE_ENDIAN /* Convert FROM host byte order */ REVERSE64(context->s512.bitcount[0],context->s512.bitcount[0]); |