summaryrefslogtreecommitdiffstats
path: root/Utilities/cmliblzma/liblzma/check
diff options
context:
space:
mode:
authorDaniel Pfeifer <daniel@pfeifer-mail.de>2014-07-13 20:21:58 (GMT)
committerBrad King <brad.king@kitware.com>2014-07-29 12:44:36 (GMT)
commit7a92eddbcb2b2e6419062538e346908f0e502586 (patch)
treeb1985ad4a8904211f12cb07742a9d776fa28152f /Utilities/cmliblzma/liblzma/check
parentb2a07ca49c66665f5b51b592f44ecc4f66c7556b (diff)
downloadCMake-7a92eddbcb2b2e6419062538e346908f0e502586.zip
CMake-7a92eddbcb2b2e6419062538e346908f0e502586.tar.gz
CMake-7a92eddbcb2b2e6419062538e346908f0e502586.tar.bz2
liblzma: Port from C99 to C89/90
Remove use of designated initializers and declarations of variables after statements. Leave "//" comments as-is for now.
Diffstat (limited to 'Utilities/cmliblzma/liblzma/check')
-rw-r--r--Utilities/cmliblzma/liblzma/check/check.c12
-rw-r--r--Utilities/cmliblzma/liblzma/check/crc32_fast.c8
-rw-r--r--Utilities/cmliblzma/liblzma/check/crc64_fast.c4
-rw-r--r--Utilities/cmliblzma/liblzma/check/sha256.c14
4 files changed, 26 insertions, 12 deletions
diff --git a/Utilities/cmliblzma/liblzma/check/check.c b/Utilities/cmliblzma/liblzma/check/check.c
index 428ddae..979b0a8 100644
--- a/Utilities/cmliblzma/liblzma/check/check.c
+++ b/Utilities/cmliblzma/liblzma/check/check.c
@@ -16,9 +16,6 @@
extern LZMA_API(lzma_bool)
lzma_check_is_supported(lzma_check type)
{
- if ((unsigned int)(type) > LZMA_CHECK_ID_MAX)
- return false;
-
static const lzma_bool available_checks[LZMA_CHECK_ID_MAX + 1] = {
true, // LZMA_CHECK_NONE
@@ -56,6 +53,9 @@ lzma_check_is_supported(lzma_check type)
false, // Reserved
};
+ if ((unsigned int)(type) > LZMA_CHECK_ID_MAX)
+ return false;
+
return available_checks[(unsigned int)(type)];
}
@@ -63,9 +63,6 @@ lzma_check_is_supported(lzma_check type)
extern LZMA_API(uint32_t)
lzma_check_size(lzma_check type)
{
- if ((unsigned int)(type) > LZMA_CHECK_ID_MAX)
- return UINT32_MAX;
-
// See file-format.txt section 2.1.1.2.
static const uint8_t check_sizes[LZMA_CHECK_ID_MAX + 1] = {
0,
@@ -76,6 +73,9 @@ lzma_check_size(lzma_check type)
64, 64, 64
};
+ if ((unsigned int)(type) > LZMA_CHECK_ID_MAX)
+ return UINT32_MAX;
+
return check_sizes[(unsigned int)(type)];
}
diff --git a/Utilities/cmliblzma/liblzma/check/crc32_fast.c b/Utilities/cmliblzma/liblzma/check/crc32_fast.c
index 94da855..13f65b4 100644
--- a/Utilities/cmliblzma/liblzma/check/crc32_fast.c
+++ b/Utilities/cmliblzma/liblzma/check/crc32_fast.c
@@ -33,6 +33,8 @@ lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
#endif
if (size > 8) {
+ const uint8_t * limit;
+
// Fix the alignment, if needed. The if statement above
// ensures that this won't read past the end of buf[].
while ((uintptr_t)(buf) & 7) {
@@ -41,7 +43,7 @@ lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
}
// Calculate the position where to stop.
- const uint8_t *const limit = buf + (size & ~(size_t)(7));
+ limit = buf + (size & ~(size_t)(7));
// Calculate how many bytes must be calculated separately
// before returning the result.
@@ -49,6 +51,8 @@ lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
// Calculate the CRC32 using the slice-by-eight algorithm.
while (buf < limit) {
+ uint32_t tmp;
+
crc ^= *(const uint32_t *)(buf);
buf += 4;
@@ -57,7 +61,7 @@ lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
^ lzma_crc32_table[5][C(crc)]
^ lzma_crc32_table[4][D(crc)];
- const uint32_t tmp = *(const uint32_t *)(buf);
+ tmp = *(const uint32_t *)(buf);
buf += 4;
// At least with some compilers, it is critical for
diff --git a/Utilities/cmliblzma/liblzma/check/crc64_fast.c b/Utilities/cmliblzma/liblzma/check/crc64_fast.c
index 52af29e..1436557 100644
--- a/Utilities/cmliblzma/liblzma/check/crc64_fast.c
+++ b/Utilities/cmliblzma/liblzma/check/crc64_fast.c
@@ -36,12 +36,14 @@ lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc)
#endif
if (size > 4) {
+ const uint8_t *limit;
+
while ((uintptr_t)(buf) & 3) {
crc = lzma_crc64_table[0][*buf++ ^ A1(crc)] ^ S8(crc);
--size;
}
- const uint8_t *const limit = buf + (size & ~(size_t)(3));
+ limit = buf + (size & ~(size_t)(3));
size &= (size_t)(3);
while (buf < limit) {
diff --git a/Utilities/cmliblzma/liblzma/check/sha256.c b/Utilities/cmliblzma/liblzma/check/sha256.c
index 23bda92..b09ccbf 100644
--- a/Utilities/cmliblzma/liblzma/check/sha256.c
+++ b/Utilities/cmliblzma/liblzma/check/sha256.c
@@ -80,16 +80,21 @@ static const uint32_t SHA256_K[64] = {
static void
+#ifndef _MSC_VER
transform(uint32_t state[static 8], const uint32_t data[static 16])
+#else
+transform(uint32_t state[], const uint32_t data[])
+#endif
{
uint32_t W[16];
uint32_t T[8];
+ unsigned int j;
// Copy state[] to working vars.
memcpy(T, state, sizeof(T));
// 64 operations, partially loop unrolled
- for (unsigned int j = 0; j < 64; j += 16) {
+ for (j = 0; j < 64; j += 16) {
R( 0); R( 1); R( 2); R( 3);
R( 4); R( 5); R( 6); R( 7);
R( 8); R( 9); R(10); R(11);
@@ -116,8 +121,9 @@ process(lzma_check_state *check)
#else
uint32_t data[16];
+ size_t i;
- for (size_t i = 0; i < 16; ++i)
+ for (i = 0; i < 16; ++i)
data[i] = bswap32(check->buffer.u32[i]);
transform(check->state.sha256.state, data);
@@ -172,6 +178,8 @@ lzma_sha256_update(const uint8_t *buf, size_t size, lzma_check_state *check)
extern void
lzma_sha256_finish(lzma_check_state *check)
{
+ size_t i;
+
// Add padding as described in RFC 3174 (it describes SHA-1 but
// the same padding style is used for SHA-256 too).
size_t pos = check->state.sha256.size & 0x3F;
@@ -193,7 +201,7 @@ lzma_sha256_finish(lzma_check_state *check)
process(check);
- for (size_t i = 0; i < 8; ++i)
+ for (i = 0; i < 8; ++i)
check->buffer.u32[i] = conv32be(check->state.sha256.state[i]);
return;