msvc: Fix some compiler warnings
In particular, using the normal (or production) compiler warning level (-W3), msvc complains as follows: .../sha1.c(244) : warning C4018: '<' : signed/unsigned mismatch .../sha1.c(270) : warning C4244: 'function' : conversion from \ 'unsigned __int64' to 'unsigned long', possible loss of data .../sha1.c(271) : warning C4244: 'function' : conversion from \ 'unsigned __int64' to 'unsigned long', possible loss of data Note that gcc issues a similar complaint about line 244 when compiling with -Wextra. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ramsay Jones committed
Jun 23, 2010 at 20:47 UTC
9eafa1201b2dcc703258ca7cd53de8ac4de74565
1 file changed
+4
-4
block-sha1/sha1.c
+4
-4
@@ -236,13 +236,13 @@ void blk_SHA1_Init(blk_SHA_CTX *ctx)
236
237
void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *data, unsigned long len)
238
{
239
- int lenW = ctx->size & 63;
239
+ unsigned int lenW = ctx->size & 63;
240
241
ctx->size += len;
242
243
/* Read the data into W and process blocks as they get full */
244
if (lenW) {
245
- int left = 64 - lenW;
245
+ unsigned int left = 64 - lenW;
246
if (len < left)
247
left = len;
248
memcpy(lenW + (char *)ctx->W, data, left);
@@ -269,8 +269,8 @@ void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx)
269
int i;
270
271
/* Pad with a binary 1 (ie 0x80), then zeroes, then length */
272
- padlen[0] = htonl(ctx->size >> 29);
273
- padlen[1] = htonl(ctx->size << 3);
272
+ padlen[0] = htonl((uint32_t)(ctx->size >> 29));
273
+ padlen[1] = htonl((uint32_t)(ctx->size << 3));
274
275
i = ctx->size & 63;
276
blk_SHA1_Update(ctx, pad, 1+ (63 & (55 - i)));