Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Unified Diff: firmware/lib/cryptolib/sha2.c

Issue 2851015: Fixes to compiler warnings in MSVC (Closed) Base URL: ssh://gitrw.chromium.org/vboot_reference.git
Patch Set: Also fix gpt numbering bug Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: firmware/lib/cryptolib/sha2.c
diff --git a/firmware/lib/cryptolib/sha2.c b/firmware/lib/cryptolib/sha2.c
index e7f78885b25983e0b8c837b23e9fb1b01243ee02..aa2691766d08c834db81c6f461a8196fea70a1db 100644
--- a/firmware/lib/cryptolib/sha2.c
+++ b/firmware/lib/cryptolib/sha2.c
@@ -72,14 +72,14 @@
#define UNPACK64(x, str) \
{ \
- *((str) + 7) = (uint8_t) ((x) ); \
- *((str) + 6) = (uint8_t) ((x) >> 8); \
- *((str) + 5) = (uint8_t) ((x) >> 16); \
- *((str) + 4) = (uint8_t) ((x) >> 24); \
- *((str) + 3) = (uint8_t) ((x) >> 32); \
- *((str) + 2) = (uint8_t) ((x) >> 40); \
- *((str) + 1) = (uint8_t) ((x) >> 48); \
- *((str) + 0) = (uint8_t) ((x) >> 56); \
+ *((str) + 7) = (uint8_t) x; \
+ *((str) + 6) = (uint8_t) UINT64_RSHIFT(x, 8); \
+ *((str) + 5) = (uint8_t) UINT64_RSHIFT(x, 16); \
+ *((str) + 4) = (uint8_t) UINT64_RSHIFT(x, 24); \
+ *((str) + 3) = (uint8_t) UINT64_RSHIFT(x, 32); \
+ *((str) + 2) = (uint8_t) UINT64_RSHIFT(x, 40); \
+ *((str) + 1) = (uint8_t) UINT64_RSHIFT(x, 48); \
+ *((str) + 0) = (uint8_t) UINT64_RSHIFT(x, 56); \
}
#define PACK64(str, x) \
@@ -338,16 +338,16 @@ void SHA256_update(SHA256_CTX* ctx, const uint8_t* data, uint64_t len) {
const uint8_t *shifted_data;
tmp_len = SHA256_BLOCK_SIZE - ctx->len;
- rem_len = len < tmp_len ? len : tmp_len;
+ rem_len = len < tmp_len ? (unsigned int)len : tmp_len;
Memcpy(&ctx->block[ctx->len], data, rem_len);
if (ctx->len + len < SHA256_BLOCK_SIZE) {
- ctx->len += len;
+ ctx->len += (uint32_t)len;
return;
}
- new_len = len - rem_len;
+ new_len = (unsigned int)len - rem_len;
block_nb = new_len / SHA256_BLOCK_SIZE;
shifted_data = data + rem_len;
@@ -526,16 +526,16 @@ void SHA512_update(SHA512_CTX* ctx, const uint8_t* data,
const uint8_t* shifted_data;
tmp_len = SHA512_BLOCK_SIZE - ctx->len;
- rem_len = len < tmp_len ? len : tmp_len;
+ rem_len = len < tmp_len ? (unsigned int)len : tmp_len;
Memcpy(&ctx->block[ctx->len], data, rem_len);
if (ctx->len + len < SHA512_BLOCK_SIZE) {
- ctx->len += len;
+ ctx->len += (uint32_t)len;
return;
}
- new_len = len - rem_len;
+ new_len = (unsigned int)len - rem_len;
block_nb = new_len / SHA512_BLOCK_SIZE;
shifted_data = data + rem_len;

Powered by Google App Engine
This is Rietveld 408576698