Skip to content

Commit 9eafa12

Browse files
Ramsay Jonesgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8b6d792 commit 9eafa12

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

block-sha1/sha1.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,13 @@ void blk_SHA1_Init(blk_SHA_CTX *ctx)
236236

237237
void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *data, unsigned long len)
238238
{
239-
int lenW = ctx->size & 63;
239+
unsigned int lenW = ctx->size & 63;
240240

241241
ctx->size += len;
242242

243243
/* Read the data into W and process blocks as they get full */
244244
if (lenW) {
245-
int left = 64 - lenW;
245+
unsigned int left = 64 - lenW;
246246
if (len < left)
247247
left = len;
248248
memcpy(lenW + (char *)ctx->W, data, left);
@@ -269,8 +269,8 @@ void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx)
269269
int i;
270270

271271
/* 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));
274274

275275
i = ctx->size & 63;
276276
blk_SHA1_Update(ctx, pad, 1+ (63 & (55 - i)));

0 commit comments

Comments
 (0)