Chromium Code Reviews| Index: base/md5.cc |
| diff --git a/base/md5.cc b/base/md5.cc |
| index 6227ee66042212dfaf2e28dba7197d7e2bbfb2dc..7ff44c23b1354e4324eaf227aa6668923168fcb5 100644 |
| --- a/base/md5.cc |
| +++ b/base/md5.cc |
| @@ -23,13 +23,14 @@ |
| #include "base/md5.h" |
| -#include "base/basictypes.h" |
| +#include <stddef.h> // For size_t. |
| +#include <stdint.h> // For intptr_t. |
|
Nico
2015/04/01 14:49:49
I think we usually don't do "// For $FOO" comments
tfarina
2015/04/01 15:51:28
I meant to remove those when I copied/pasted, but
|
| namespace { |
| struct Context { |
| - uint32 buf[4]; |
| - uint32 bits[2]; |
| + uint32_t buf[4]; |
| + uint32_t bits[2]; |
| unsigned char in[64]; |
| }; |
| @@ -37,11 +38,11 @@ struct Context { |
| * Note: this code is harmless on little-endian machines. |
| */ |
| void byteReverse(unsigned char *buf, unsigned longs) { |
| - uint32 t; |
| + uint32_t t; |
| do { |
| - t = (uint32)((unsigned)buf[3]<<8 | buf[2]) << 16 | |
| + t = (uint32_t)((unsigned)buf[3]<<8 | buf[2]) << 16 | |
| ((unsigned)buf[1]<<8 | buf[0]); |
|
Nico
2015/04/01 14:49:49
nit: indent 2
tfarina
2015/04/01 15:51:28
clang-formatted.
Done.
|
| - *(uint32 *)buf = t; |
| + *(uint32_t *)buf = t; |
| buf += 4; |
| } while (--longs); |
| } |
| @@ -63,8 +64,8 @@ void byteReverse(unsigned char *buf, unsigned longs) { |
| * reflect the addition of 16 longwords of new data. MD5Update blocks |
| * the data and converts bytes into longwords for this routine. |
| */ |
| -void MD5Transform(uint32 buf[4], const uint32 in[16]) { |
| - register uint32 a, b, c, d; |
| +void MD5Transform(uint32_t buf[4], const uint32_t in[16]) { |
| + register uint32_t a, b, c, d; |
|
Nico
2015/04/01 14:49:49
If you're touching this line anyways, can you remo
tfarina
2015/04/01 15:51:28
Done.
|
| a = buf[0]; |
| b = buf[1]; |
| @@ -172,14 +173,14 @@ void MD5Update(MD5Context* context, const StringPiece& data) { |
| size_t len = data.size(); |
| struct Context *ctx = (struct Context *)context; |
| const unsigned char* buf = (const unsigned char*)inbuf; |
| - uint32 t; |
| + uint32_t t; |
| /* Update bitcount */ |
| t = ctx->bits[0]; |
| - if ((ctx->bits[0] = t + ((uint32)len << 3)) < t) |
| + if ((ctx->bits[0] = t + ((uint32_t)len << 3)) < t) |
| ctx->bits[1]++; /* Carry from low to high */ |
| - ctx->bits[1] += static_cast<uint32>(len >> 29); |
| + ctx->bits[1] += static_cast<uint32_t>(len >> 29); |
| t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ |
| @@ -195,7 +196,7 @@ void MD5Update(MD5Context* context, const StringPiece& data) { |
| } |
| memcpy(p, buf, t); |
| byteReverse(ctx->in, 16); |
| - MD5Transform(ctx->buf, (uint32 *)ctx->in); |
| + MD5Transform(ctx->buf, (uint32_t *)ctx->in); |
| buf += t; |
| len -= t; |
| } |
| @@ -205,7 +206,7 @@ void MD5Update(MD5Context* context, const StringPiece& data) { |
| while (len >= 64) { |
| memcpy(ctx->in, buf, 64); |
| byteReverse(ctx->in, 16); |
| - MD5Transform(ctx->buf, (uint32 *)ctx->in); |
| + MD5Transform(ctx->buf, (uint32_t *)ctx->in); |
| buf += 64; |
| len -= 64; |
| } |
| @@ -240,7 +241,7 @@ void MD5Final(MD5Digest* digest, MD5Context* context) { |
| /* Two lots of padding: Pad the first block to 64 bytes */ |
| memset(p, 0, count); |
| byteReverse(ctx->in, 16); |
| - MD5Transform(ctx->buf, (uint32 *)ctx->in); |
| + MD5Transform(ctx->buf, (uint32_t *)ctx->in); |
| /* Now fill the next block with 56 bytes */ |
| memset(ctx->in, 0, 56); |
| @@ -258,7 +259,7 @@ void MD5Final(MD5Digest* digest, MD5Context* context) { |
| &ctx->bits[1], |
| sizeof(ctx->bits[1])); |
| - MD5Transform(ctx->buf, (uint32 *)ctx->in); |
| + MD5Transform(ctx->buf, (uint32_t *)ctx->in); |
| byteReverse((unsigned char *)ctx->buf, 4); |
| memcpy(digest->a, ctx->buf, 16); |
| memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ |