Module Name: othersrc
Committed By: agc
Date: Thu Jun 12 06:19:35 UTC 2014
Modified Files:
othersrc/external/bsd/multigest/dist: blake2.c crc32c.c keccak.c main.c
multigest.c rmd160.c sha1.c tiger.c whirlpool.c
Log Message:
Make this compile WARNS=6 with gcc-4.8
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 othersrc/external/bsd/multigest/dist/blake2.c
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/bsd/multigest/dist/crc32c.c \
othersrc/external/bsd/multigest/dist/rmd160.c \
othersrc/external/bsd/multigest/dist/sha1.c \
othersrc/external/bsd/multigest/dist/tiger.c \
othersrc/external/bsd/multigest/dist/whirlpool.c
cvs rdiff -u -r1.4 -r1.5 othersrc/external/bsd/multigest/dist/keccak.c
cvs rdiff -u -r1.5 -r1.6 othersrc/external/bsd/multigest/dist/main.c
cvs rdiff -u -r1.14 -r1.15 othersrc/external/bsd/multigest/dist/multigest.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: othersrc/external/bsd/multigest/dist/blake2.c
diff -u othersrc/external/bsd/multigest/dist/blake2.c:1.3 othersrc/external/bsd/multigest/dist/blake2.c:1.4
--- othersrc/external/bsd/multigest/dist/blake2.c:1.3 Tue Mar 4 02:12:58 2014
+++ othersrc/external/bsd/multigest/dist/blake2.c Thu Jun 12 06:19:35 2014
@@ -311,7 +311,7 @@ blake2b_compress(BLAKE2_CTX *S, const ui
int i;
for (i = 0; i < 16; ++i) {
- m[i] = load64(block + i * sizeof(m[i]));
+ m[i] = load64(block + (sizeof(m[i]) * (uint64_t)i));
}
for (i = 0; i < 8; ++i) {
v[i] = S->h[i];
@@ -412,7 +412,7 @@ blake2b_final(BLAKE2_CTX *S, uint8_t *ou
blake2b_compress(S, S->buf);
for (i = 0; i < 8; ++i) {
/* Output full hash to temp buffer */
- store64(buffer + sizeof(S->h[i]) * i, S->h[i]);
+ store64(buffer + (sizeof(S->h[i]) * (uint64_t)i), S->h[i]);
}
memcpy(out, buffer, outlen);
return 0;
Index: othersrc/external/bsd/multigest/dist/crc32c.c
diff -u othersrc/external/bsd/multigest/dist/crc32c.c:1.1.1.1 othersrc/external/bsd/multigest/dist/crc32c.c:1.2
--- othersrc/external/bsd/multigest/dist/crc32c.c:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/dist/crc32c.c Thu Jun 12 06:19:35 2014
@@ -540,9 +540,9 @@ crc32c_sb8_64_bit(uint32_t crc,
p_buf += 4;
} else {
crc ^= *p_buf++;
- crc ^= (*p_buf++) << 8;
- crc ^= (*p_buf++) << 16;
- crc ^= (*p_buf++) << 24;
+ crc ^= (uint32_t)(*p_buf++) << 8;
+ crc ^= (uint32_t)(*p_buf++) << 16;
+ crc ^= (uint32_t)(*p_buf++) << 24;
}
term1 = crc_tableil8_o88[crc & 0x000000FF] ^
crc_tableil8_o80[(crc >> 8) & 0x000000FF];
Index: othersrc/external/bsd/multigest/dist/rmd160.c
diff -u othersrc/external/bsd/multigest/dist/rmd160.c:1.1.1.1 othersrc/external/bsd/multigest/dist/rmd160.c:1.2
--- othersrc/external/bsd/multigest/dist/rmd160.c:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/dist/rmd160.c Thu Jun 12 06:19:35 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: rmd160.c,v 1.1.1.1 2013/08/16 06:47:53 agc Exp $ */
+/* $NetBSD: rmd160.c,v 1.2 2014/06/12 06:19:35 agc Exp $ */
/********************************************************************\
*
@@ -430,10 +430,10 @@ RMD160Final(uint8_t digest[20], RMD160_C
if (digest != NULL) {
for (i = 0; i < 20; i += 4) {
/* extracts the 8 least significant bits. */
- digest[i] = context->state[i>>2];
- digest[i + 1] = (context->state[i>>2] >> 8);
- digest[i + 2] = (context->state[i>>2] >> 16);
- digest[i + 3] = (context->state[i>>2] >> 24);
+ digest[i] = (uint8_t)context->state[i>>2];
+ digest[i + 1] = (uint8_t)(context->state[i>>2] >> 8);
+ digest[i + 2] = (uint8_t)(context->state[i>>2] >> 16);
+ digest[i + 3] = (uint8_t)(context->state[i>>2] >> 24);
}
}
}
Index: othersrc/external/bsd/multigest/dist/sha1.c
diff -u othersrc/external/bsd/multigest/dist/sha1.c:1.1.1.1 othersrc/external/bsd/multigest/dist/sha1.c:1.2
--- othersrc/external/bsd/multigest/dist/sha1.c:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/dist/sha1.c Thu Jun 12 06:19:35 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: sha1.c,v 1.1.1.1 2013/08/16 06:47:53 agc Exp $ */
+/* $NetBSD: sha1.c,v 1.2 2014/06/12 06:19:35 agc Exp $ */
/* $OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $ */
/*
@@ -225,8 +225,8 @@ SHA1Update(SHA1_CTX *context, const uint
_DIAGASSERT(data != 0);
j = context->count[0];
- if ((context->count[0] += len << 3) < j)
- context->count[1] += (len>>29)+1;
+ if ((context->count[0] += (uint32_t)(len << 3)) < j)
+ context->count[1] += (uint32_t)((len>>29)+1);
j = (j >> 3) & 63;
if ((j + len) > 63) {
i = 64 - j;
Index: othersrc/external/bsd/multigest/dist/tiger.c
diff -u othersrc/external/bsd/multigest/dist/tiger.c:1.1.1.1 othersrc/external/bsd/multigest/dist/tiger.c:1.2
--- othersrc/external/bsd/multigest/dist/tiger.c:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/dist/tiger.c Thu Jun 12 06:19:35 2014
@@ -819,7 +819,7 @@ TIGER_Update(TIGER_CTX *ctx, const void
for (; j < 56; j++) {
u.temp8[j] = 0;
}
- ((uint64_t *)(void *)(&(u.temp8[56])))[0] = ((uint64_t)length) << 3;
+ u.temp64[7] = ((uint64_t)length) << 3;
tiger_compress(u.temp64, ctx->ctx);
}
Index: othersrc/external/bsd/multigest/dist/whirlpool.c
diff -u othersrc/external/bsd/multigest/dist/whirlpool.c:1.1.1.1 othersrc/external/bsd/multigest/dist/whirlpool.c:1.2
--- othersrc/external/bsd/multigest/dist/whirlpool.c:1.1.1.1 Fri Aug 16 06:47:54 2013
+++ othersrc/external/bsd/multigest/dist/whirlpool.c Thu Jun 12 06:19:35 2014
@@ -1453,7 +1453,7 @@ whirlpool_update(whirlpool_context_t *st
/*
* tally the length of the added data:
*/
- u64 value = sourceBits;
+ u64 value = (u64)sourceBits;
for (i = 31, carry = 0; i >= 0 && (carry != 0 || value != LL(0)); i--) {
carry += bitLength[i] + ((u32)value & 0xff);
bitLength[i] = (u8)carry;
@@ -1485,7 +1485,7 @@ whirlpool_update(whirlpool_context_t *st
*/
bufferBits = bufferPos = 0;
}
- buffer[bufferPos] = b << (8 - bufferRem);
+ buffer[bufferPos] = (u8)(b << (8 - bufferRem));
bufferBits += bufferRem;
/*
* proceed to remaining data:
@@ -1501,7 +1501,7 @@ whirlpool_update(whirlpool_context_t *st
/*
* process the remaining bits:
*/
- buffer[bufferPos] |= b >> bufferRem;
+ buffer[bufferPos] |= (u8)(b >> bufferRem);
} else {
b = 0;
}
@@ -1531,7 +1531,7 @@ whirlpool_update(whirlpool_context_t *st
*/
bufferBits = bufferPos = 0;
}
- buffer[bufferPos] = b << (8 - bufferRem);
+ buffer[bufferPos] = (u8)(b << (8 - bufferRem));
bufferBits += (int)sourceBits;
}
structpointer->bufferBits = bufferBits;
@@ -1556,14 +1556,14 @@ whirlpool_finalize(char *result, whirlpo
/*
* append a '1'-bit:
*/
- buffer[bufferPos] |= 0x80U >> (bufferBits & 7);
+ buffer[bufferPos] |= (u8)(0x80U >> (bufferBits & 7));
bufferPos++; /* all remaining bits on the current u8 are set to zero. */
/*
* pad with zero bits to complete (N*WHIRLPOOL_WBLOCK_BITS - WHIRLPOOL_LENGTH_BITS) bits:
*/
if (bufferPos > WHIRLPOOL_WBLOCK_BYTES - WHIRLPOOL_LENGTH_BYTES) {
if (bufferPos < WHIRLPOOL_WBLOCK_BYTES) {
- memset(&buffer[bufferPos], 0, WHIRLPOOL_WBLOCK_BYTES - bufferPos);
+ memset(&buffer[bufferPos], 0, (size_t)(WHIRLPOOL_WBLOCK_BYTES - bufferPos));
}
/*
* process data block:
@@ -1575,7 +1575,7 @@ whirlpool_finalize(char *result, whirlpo
bufferPos = 0;
}
if (bufferPos < WHIRLPOOL_WBLOCK_BYTES - WHIRLPOOL_LENGTH_BYTES) {
- memset(&buffer[bufferPos], 0, (WHIRLPOOL_WBLOCK_BYTES - WHIRLPOOL_LENGTH_BYTES) - bufferPos);
+ memset(&buffer[bufferPos], 0, (size_t)((WHIRLPOOL_WBLOCK_BYTES - WHIRLPOOL_LENGTH_BYTES) - bufferPos));
}
bufferPos = WHIRLPOOL_WBLOCK_BYTES - WHIRLPOOL_LENGTH_BYTES;
/*
@@ -1590,14 +1590,14 @@ whirlpool_finalize(char *result, whirlpo
* return the completed message digest:
*/
for (i = 0; i < WHIRLPOOL_DIGEST_BYTES/8; i++) {
- digest[0] = (u8)(structpointer->hash[i] >> 56);
- digest[1] = (u8)(structpointer->hash[i] >> 48);
- digest[2] = (u8)(structpointer->hash[i] >> 40);
- digest[3] = (u8)(structpointer->hash[i] >> 32);
- digest[4] = (u8)(structpointer->hash[i] >> 24);
- digest[5] = (u8)(structpointer->hash[i] >> 16);
- digest[6] = (u8)(structpointer->hash[i] >> 8);
- digest[7] = (u8)(structpointer->hash[i] );
+ digest[0] = (char)(structpointer->hash[i] >> 56);
+ digest[1] = (char)(structpointer->hash[i] >> 48);
+ digest[2] = (char)(structpointer->hash[i] >> 40);
+ digest[3] = (char)(structpointer->hash[i] >> 32);
+ digest[4] = (char)(structpointer->hash[i] >> 24);
+ digest[5] = (char)(structpointer->hash[i] >> 16);
+ digest[6] = (char)(structpointer->hash[i] >> 8);
+ digest[7] = (char)(structpointer->hash[i] );
digest += 8;
}
structpointer->bufferBits = bufferBits;
Index: othersrc/external/bsd/multigest/dist/keccak.c
diff -u othersrc/external/bsd/multigest/dist/keccak.c:1.4 othersrc/external/bsd/multigest/dist/keccak.c:1.5
--- othersrc/external/bsd/multigest/dist/keccak.c:1.4 Thu Aug 22 06:37:29 2013
+++ othersrc/external/bsd/multigest/dist/keccak.c Thu Jun 12 06:19:35 2014
@@ -192,9 +192,9 @@ LFSR86540(uint8_t *LFSR)
if (((*LFSR) & 0x80) != 0) {
/* Primitive polynomial over GF(2): x^8+x^6+x^5+x^4+1 */
- (*LFSR) = ((*LFSR) << 1) ^ 0x71;
+ (*LFSR) = (uint8_t)((*LFSR) << 1) ^ 0x71;
} else {
- (*LFSR) = (*LFSR) << 1;
+ (*LFSR) = (uint8_t)((*LFSR) << 1);
}
return result;
}
@@ -208,7 +208,7 @@ keccak_initialise_RoundConstants(KECCAK_
for (i = 0; i < KECCAK_NUM_ROUNDS; i++) {
ctx->RoundConstants[i] = 0;
for (j = 0; j < 7; j++) {
- bitPosition = (1<<j)-1; /*2^j-1 */
+ bitPosition = (unsigned)(1<<j)-1; /*2^j-1 */
if (LFSR86540(&LFSRstate)) {
ctx->RoundConstants[i] ^= (uint64_t)1<<bitPosition;
}
@@ -298,7 +298,7 @@ absorb(KECCAK_CTX *ctx, const uint8_t *d
absorb_queue(ctx);
}
if (partialByte > 0) {
- uint8_t mask = (1 << partialByte)-1;
+ uint8_t mask = (uint8_t)((1 << partialByte)-1);
ctx->dataQueue[ctx->bitsInQueue/8] = data[(unsigned long)i/8] & mask;
ctx->bitsInQueue += partialByte;
i += partialByte;
@@ -313,14 +313,14 @@ PadAndSwitchToSqueezingPhase(KECCAK_CTX
{
/* Note: the bits are numbered from 0=LSB to 7=MSB */
if (ctx->bitsInQueue + 1 == ctx->rate) {
- ctx->dataQueue[ctx->bitsInQueue/8 ] |= 1 << (ctx->bitsInQueue % 8);
+ ctx->dataQueue[ctx->bitsInQueue/8 ] |= (uint8_t)(1 << (ctx->bitsInQueue % 8));
absorb_queue(ctx);
memset(ctx->dataQueue, 0, ctx->rate/8);
} else {
memset(ctx->dataQueue + (ctx->bitsInQueue+7)/8, 0, ctx->rate/8 - (ctx->bitsInQueue+7)/8);
- ctx->dataQueue[ctx->bitsInQueue/8 ] |= 1 << (ctx->bitsInQueue % 8);
+ ctx->dataQueue[ctx->bitsInQueue/8 ] |= (uint8_t)(1 << (ctx->bitsInQueue % 8));
}
- ctx->dataQueue[(ctx->rate-1)/8] |= 1 << ((ctx->rate-1) % 8);
+ ctx->dataQueue[(ctx->rate-1)/8] |= (uint8_t)(1 << ((ctx->rate-1) % 8));
absorb_queue(ctx);
memcpy(ctx->dataQueue, ctx->state, ctx->rate/8);
ctx->bitsAvailableForSqueezing = ctx->rate;
@@ -381,7 +381,7 @@ KECCAK_Init(KECCAK_CTX *ctx, int hashbit
default:
return BAD_HASHLEN;
}
- ctx->fixedOutputLength = hashbitlen;
+ ctx->fixedOutputLength = (uint32_t)hashbitlen;
return SUCCESS;
}
@@ -398,7 +398,7 @@ KECCAK_Update(KECCAK_CTX *ctx, const uin
uint8_t lastByte;
/* Align the last partial byte to the least significant bits */
- lastByte = data[(unsigned long)databitlen/8] >> (8 - (databitlen % 8));
+ lastByte = (uint8_t)(data[(unsigned long)databitlen/8] >> (8 - (databitlen % 8)));
return absorb((KECCAK_CTX*)ctx, &lastByte, databitlen % 8);
}
return ret;
Index: othersrc/external/bsd/multigest/dist/main.c
diff -u othersrc/external/bsd/multigest/dist/main.c:1.5 othersrc/external/bsd/multigest/dist/main.c:1.6
--- othersrc/external/bsd/multigest/dist/main.c:1.5 Sun Aug 18 06:03:14 2013
+++ othersrc/external/bsd/multigest/dist/main.c Thu Jun 12 06:19:35 2014
@@ -41,12 +41,12 @@
static int
do_input(const char *alg, uint8_t *raw, const char *pat, const char *repl)
{
+ ssize_t rc;
size_t cc;
- size_t rc;
char *data;
if ((data = calloc(1, MB(4))) != NULL) {
- for (cc = 0 ; cc < MB(4) ; cc += rc) {
+ for (cc = 0 ; cc < MB(4) ; cc += (size_t)rc) {
if ((rc = read(fileno(stdin), &data[cc], MB(4) - cc)) <= 0) {
break;
}
@@ -110,11 +110,11 @@ read_check(const char *check)
return 0;
}
fstat(fileno(fp), &st);
- if ((in = calloc(1, st.st_size + 1)) == NULL) {
+ if ((in = calloc(1, (size_t)(st.st_size + 1))) == NULL) {
fclose(fp);
return 0;
}
- read(fileno(fp), in, st.st_size);
+ read(fileno(fp), in, (size_t)(st.st_size));
in[st.st_size] = 0x0;
fclose(fp);
if (regexec(&r, in, 10, match, 0) != 0) {
@@ -129,7 +129,7 @@ read_check(const char *check)
getsubst(subs, from, sizeof(from), to, sizeof(to));
multigest_file(alg, file, raw, from, to);
multigest_format_hex(raw, alg, calc, sizeof(calc));
- if ((ret = memcmp(calc, provided, match[4].rm_eo - match[4].rm_so)) != 0) {
+ if ((ret = memcmp(calc, provided, (size_t)(match[4].rm_eo - match[4].rm_so))) != 0) {
fprintf(stderr, "multigest: provided digest: '%s', calculated digest: '%s'\n", provided, calc);
}
regfree(&r);
Index: othersrc/external/bsd/multigest/dist/multigest.c
diff -u othersrc/external/bsd/multigest/dist/multigest.c:1.14 othersrc/external/bsd/multigest/dist/multigest.c:1.15
--- othersrc/external/bsd/multigest/dist/multigest.c:1.14 Wed Mar 26 22:13:44 2014
+++ othersrc/external/bsd/multigest/dist/multigest.c Thu Jun 12 06:19:35 2014
@@ -445,7 +445,7 @@ normalise(multigest_t *multigest, const
*from = 0;
while (multigest->r && len > 0) {
match[0].rm_so = *from;
- match[0].rm_eo = len;
+ match[0].rm_eo = (regoff_t)len;
if (regexec(multigest->r, data, 2, match, REG_STARTEND) != 0) {
break;
}
@@ -496,8 +496,8 @@ comb4p_round(multigest_t *m, uint8_t *ou
}
(*d1->update)(&m->ctx[d1->ctxoff], (const char *)&r, sizeof(r));
(*d2->update)(&m->ctx[d2->ctxoff], (const char *)&r, sizeof(r));
- (*d1->update)(&m->ctx[d1->ctxoff], (const char *)in, d1->rawsize);
- (*d2->update)(&m->ctx[d2->ctxoff], (const char *)in, d2->rawsize);
+ (*d1->update)(&m->ctx[d1->ctxoff], (const char *)in, (unsigned)d1->rawsize);
+ (*d2->update)(&m->ctx[d2->ctxoff], (const char *)in, (unsigned)d2->rawsize);
(*d1->final)(h1, &m->ctx[d1->ctxoff]);
xorbuf(out, out, h1, d1->rawsize);
(*d2->final)(h2, &m->ctx[d2->ctxoff]);
@@ -646,7 +646,7 @@ multigest_update(multigest_t *multigest,
normalise(multigest, data, len, &from);
for (d = multigest->digs, i = 0 ; i < multigest->digc ; i++, d++) {
if (d->rawsize) {
- (*d->update)(&multigest->ctx[d->ctxoff], &data[from], (unsigned)(len - from));
+ (*d->update)(&multigest->ctx[d->ctxoff], &data[from], (unsigned)(len - (unsigned)from));
}
}
}
@@ -693,7 +693,7 @@ multigest_final(multigest_t *m, uint8_t
return;
}
(*d2->final)(h2, &m->ctx[d2->ctxoff]);
- (*d1->update)(&m->ctx[d1->ctxoff], (const char *)h2, d1->rawsize);
+ (*d1->update)(&m->ctx[d1->ctxoff], (const char *)h2, (unsigned)d1->rawsize);
(*d1->final)(raw, &m->ctx[d1->ctxoff]);
break;
case COMBINE_XOR:
@@ -735,6 +735,7 @@ multigest_unpcstring(const char *in, siz
static const char *hexes = "0123456789abcdef";
const char *p[2];
const char *i;
+ uint8_t num;
char *o;
for (i = in, o = out ; (size_t)(o - out) < osize - 1 && (size_t)(i - in) < isize && *i ; o++) {
@@ -743,7 +744,8 @@ multigest_unpcstring(const char *in, siz
(p[1] = strchr(hexes, i[2])) == NULL) {
break;
}
- *o = ((char)(p[0] - hexes) * 16) + (p[1] - hexes);
+ num = (uint8_t)((p[0] - hexes) << 4) | (uint8_t)(p[1] - hexes);
+ *o = (char)num;
i += 3;
} else {
*o = *i++;
@@ -898,11 +900,11 @@ multigest_file(const char *alg, const ch
return 0;
}
fstat(fileno(fp), &st);
- size = st.st_size;
+ size = (size_t)st.st_size;
mapped = mmap(NULL, size, PROT_READ, MAP_SHARED, fileno(fp), 0);
if (mapped == MAP_FAILED) {
mapped = calloc(1, MB(1));
- for (cc = 0 ; cc < size ; cc += rc) {
+ for (cc = 0 ; cc < size ; cc += (size_t)rc) {
if ((rc = read(fileno(fp), mapped, MB(1))) <= 0) {
break;
}