summaryrefslogtreecommitdiff
path: root/src/base/crc.cc
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2009-06-04 23:21:12 -0700
committerNathan Binkert <nate@binkert.org>2009-06-04 23:21:12 -0700
commit6faf377b5305f9dcc3c7b013c4d67f5accb92617 (patch)
tree0e437fb49a32dd3d2d2bec95a8dc3bdb4ddf05b0 /src/base/crc.cc
parent4e3426624557b555c354035ee3961eab7554d81d (diff)
downloadgem5-6faf377b5305f9dcc3c7b013c4d67f5accb92617.tar.xz
types: clean up types, especially signed vs unsigned
Diffstat (limited to 'src/base/crc.cc')
-rw-r--r--src/base/crc.cc37
1 files changed, 14 insertions, 23 deletions
diff --git a/src/base/crc.cc b/src/base/crc.cc
index d4b0de70e..6b04213c9 100644
--- a/src/base/crc.cc
+++ b/src/base/crc.cc
@@ -48,15 +48,12 @@
uint32_t
crc32le(const uint8_t *buf, size_t len)
{
- uint32_t c, crc, carry;
- size_t i, j;
+ uint32_t crc = 0xffffffffU; /* initial value */
- crc = 0xffffffffU; /* initial value */
-
- for (i = 0; i < len; i++) {
- c = buf[i];
- for (j = 0; j < 8; j++) {
- carry = ((crc & 0x01) ? 1 : 0) ^ (c & 0x01);
+ for (size_t i = 0; i < len; i++) {
+ uint32_t c = buf[i];
+ for (size_t j = 0; j < 8; j++) {
+ uint32_t carry = ((crc & 0x01) ? 1 : 0) ^ (c & 0x01);
crc >>= 1;
c >>= 1;
if (carry)
@@ -64,7 +61,7 @@ crc32le(const uint8_t *buf, size_t len)
}
}
- return (crc);
+ return crc;
}
#else
uint32_t
@@ -76,33 +73,27 @@ crc32le(const uint8_t *buf, size_t len)
0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c,
0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c
};
- uint32_t crc;
- int i;
-
- crc = 0xffffffffU; /* initial value */
+ uint32_t crc = 0xffffffffU; /* initial value */
- for (i = 0; i < len; i++) {
+ for (size_t i = 0; i < len; i++) {
crc ^= buf[i];
crc = (crc >> 4) ^ crctab[crc & 0xf];
crc = (crc >> 4) ^ crctab[crc & 0xf];
}
- return (crc);
+ return crc;
}
#endif
uint32_t
crc32be(const uint8_t *buf, size_t len)
{
- uint32_t c, crc, carry;
- size_t i, j;
-
- crc = 0xffffffffU; /* initial value */
+ uint32_t crc = 0xffffffffU; /* initial value */
- for (i = 0; i < len; i++) {
- c = buf[i];
- for (j = 0; j < 8; j++) {
- carry = ((crc & 0x80000000U) ? 1 : 0) ^ (c & 0x01);
+ for (size_t i = 0; i < len; i++) {
+ uint32_t c = buf[i];
+ for (size_t j = 0; j < 8; j++) {
+ uint32_t carry = ((crc & 0x80000000U) ? 1 : 0) ^ (c & 0x01);
crc <<= 1;
c >>= 1;
if (carry)