add shorten 64 to 32 warnings back on with fixes

This commit is contained in:
toddouska 2012-10-19 12:44:23 -07:00
parent ba4d058ba7
commit c974d77213
17 changed files with 68 additions and 64 deletions

View File

@ -23,7 +23,7 @@ RESULT=$?
# make sure full config is ok
echo -e "\n\nTesting full config as well...\n\n"
./configure --enable-opensslExtra --enable-fastmath --enable-dtls --enable-aesgcm --enable-hc128;
./configure --enable-opensslExtra --enable-fastmath --enable-dtls --enable-aesgcm --enable-hc128 --enable-sniffer;
RESULT=$?
[ $RESULT -ne 0 ] && echo -e "\n\nFull config ./configure failed" && exit 1

View File

@ -1860,7 +1860,7 @@ int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y,
}
/* grab the next msb from the exponent */
y = (mp_digit)(buf >> (DIGIT_BIT - 1)) & 1;
y = (int)(buf >> (DIGIT_BIT - 1)) & 1;
buf <<= (mp_digit)1;
/* if the bit is zero and mode == 0 then we ignore it
@ -3268,7 +3268,7 @@ int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
}
/* grab the next msb from the exponent */
y = (buf >> (mp_digit)(DIGIT_BIT - 1)) & 1;
y = (int)(buf >> (mp_digit)(DIGIT_BIT - 1)) & 1;
buf <<= (mp_digit)1;
/* if the bit is zero and mode == 0 then we ignore it

View File

@ -91,7 +91,7 @@ STATIC INLINE word32 ByteReverseWord32(word32 value)
STATIC INLINE void ByteReverseWords(word32* out, const word32* in,
word32 byteCount)
{
word32 count = byteCount/sizeof(word32), i;
word32 count = byteCount/(word32)sizeof(word32), i;
for (i = 0; i < count; i++)
out[i] = ByteReverseWord32(in[i]);
@ -132,7 +132,7 @@ STATIC INLINE word64 ByteReverseWord64(word64 value)
STATIC INLINE void ByteReverseWords64(word64* out, const word64* in,
word32 byteCount)
{
word32 count = byteCount/sizeof(word64), i;
word32 count = byteCount/(word32)sizeof(word64), i;
for (i = 0; i < count; i++)
out[i] = ByteReverseWord64(in[i]);

View File

@ -181,7 +181,7 @@ int GenerateSeed(OS_Seed* os, byte* output, word32 sz)
}
while (sz) {
int len = read(os->fd, output, sz);
int len = (int)read(os->fd, output, sz);
if (len == -1) {
ret = READ_RAN_E;
break;

View File

@ -81,7 +81,7 @@ static const word32 K[64] = {
#define Ch(x,y,z) (z ^ (x & (y ^ z)))
#define Maj(x,y,z) (((x | y) & z) | (x & y))
#define S(x, n) rotrFixed(x, n)
#define R(x, n) (((x)&0xFFFFFFFFL)>>(n))
#define R(x, n) (((x)&0xFFFFFFFFU)>>(n))
#define Sigma0(x) (S(x, 2) ^ S(x, 13) ^ S(x, 22))
#define Sigma1(x) (S(x, 6) ^ S(x, 11) ^ S(x, 25))
#define Gamma0(x) (S(x, 7) ^ S(x, 18) ^ R(x, 3))

View File

@ -1107,7 +1107,7 @@ static int _fp_exptmod(fp_int * G, fp_int * X, fp_int * P, fp_int * Y)
}
/* grab the next msb from the exponent */
y = (fp_digit)(buf >> (DIGIT_BIT - 1)) & 1;
y = (int)(buf >> (DIGIT_BIT - 1)) & 1;
buf <<= (fp_digit)1;
/* if the bit is zero and mode == 0 then we ignore it

View File

@ -2154,8 +2154,8 @@ int pbkdf2_test(void)
};
PBKDF2(derived, (byte*)passwd, strlen(passwd), salt, 8, iterations, kLen,
SHA);
PBKDF2(derived, (byte*)passwd, (int)strlen(passwd), salt, 8, iterations,
kLen, SHA);
if (memcmp(derived, verify, sizeof(verify)) != 0)
return -102;
@ -2177,8 +2177,8 @@ int pbkdf1_test(void)
0x4A, 0x3D, 0x2A, 0x20
};
PBKDF1(derived, (byte*)passwd, strlen(passwd), salt, 8, iterations, kLen,
SHA);
PBKDF1(derived, (byte*)passwd, (int)strlen(passwd), salt, 8, iterations,
kLen, SHA);
if (memcmp(derived, verify, sizeof(verify)) != 0)
return -101;

View File

@ -467,8 +467,8 @@ static INLINE int udp_read_connect(SOCKET_T sockfd)
int n;
socklen_t len = sizeof(cliaddr);
n = recvfrom(sockfd, (char*)b, sizeof(b), MSG_PEEK,
(struct sockaddr*)&cliaddr, &len);
n = (int)recvfrom(sockfd, (char*)b, sizeof(b), MSG_PEEK,
(struct sockaddr*)&cliaddr, &len);
if (n > 0) {
if (connect(sockfd, (const struct sockaddr*)&cliaddr,
sizeof(cliaddr)) != 0)

View File

@ -122,7 +122,7 @@ void client_test(void* args)
char msg[64] = "hello cyassl!";
char reply[1024];
int input;
int msgSz = strlen(msg);
int msgSz = (int)strlen(msg);
int port = yasslPort;
char* host = (char*)yasslIP;

View File

@ -223,11 +223,11 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
echoSz = sizeof(type) - 1;
strncpy(&command[echoSz], header, sizeof(header));
echoSz += sizeof(header) - 1;
echoSz += (int)sizeof(header) - 1;
strncpy(&command[echoSz], body, sizeof(body));
echoSz += sizeof(body) - 1;
echoSz += (int)sizeof(body) - 1;
strncpy(&command[echoSz], footer, sizeof(footer));
echoSz += sizeof(footer);
echoSz += (int)sizeof(footer);
if (CyaSSL_write(ssl, command, echoSz) != echoSz)
err_sys("SSL_write failed");

View File

@ -58,7 +58,7 @@
# AX_APPEND_COMPILE_FLAGS([-Wold-style-definition],,[$ax_append_compile_flags_extra])
# AX_APPEND_COMPILE_FLAGS([-std=c99],,[$ax_append_compile_flags_extra])
# AX_APPEND_COMPILE_FLAGS([-Wlogical-op],,[$ax_append_compile_flags_extra])
# AX_APPEND_COMPILE_FLAGS([-Wshorten-64-to-32],,[$ax_append_compile_flags_extra]) -- Fix these TAO, put back after -Wshadow when done
# AX_APPEND_COMPILE_FLAGS([-Wshorten-64-to-32],,[$ax_append_compile_flags_extra])
#serial 3
@ -128,6 +128,7 @@
AX_APPEND_COMPILE_FLAGS([-Wpointer-sign],,[$ax_append_compile_flags_extra])
AX_APPEND_COMPILE_FLAGS([-Wredundant-decls],,[$ax_append_compile_flags_extra])
AX_APPEND_COMPILE_FLAGS([-Wshadow],,[$ax_append_compile_flags_extra])
AX_APPEND_COMPILE_FLAGS([-Wshorten-64-to-32],,[$ax_append_compile_flags_extra])
AX_APPEND_COMPILE_FLAGS([-Wsign-compare],,[$ax_append_compile_flags_extra])
AX_APPEND_COMPILE_FLAGS([-Wstrict-overflow=1],,[$ax_append_compile_flags_extra])
AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes],,[$ax_append_compile_flags_extra])
@ -185,6 +186,7 @@
AX_APPEND_COMPILE_FLAGS([-Wpointer-arith],,[$ax_append_compile_flags_extra])
AX_APPEND_COMPILE_FLAGS([-Wredundant-decls],,[$ax_append_compile_flags_extra])
AX_APPEND_COMPILE_FLAGS([-Wshadow],,[$ax_append_compile_flags_extra])
AX_APPEND_COMPILE_FLAGS([-Wshorten-64-to-32],,[$ax_append_compile_flags_extra])
AX_APPEND_COMPILE_FLAGS([-Wsign-compare],,[$ax_append_compile_flags_extra])
AX_APPEND_COMPILE_FLAGS([-Wstrict-overflow=1],,[$ax_append_compile_flags_extra])
AX_APPEND_COMPILE_FLAGS([-Wswitch-enum],,[$ax_append_compile_flags_extra])

View File

@ -1486,7 +1486,7 @@ ProtocolVersion MakeDTLSv1(void)
word32 LowResTimer(void)
{
return time(0);
return (word32)time(0);
}
@ -4843,7 +4843,7 @@ int SetCipherList(Suites* s, const char* list)
haystack = XSTRSTR(haystack, needle);
if (!haystack) /* last cipher */
len = min(sizeof(name), XSTRLEN(prev));
len = min(sizeof(name), (word32)XSTRLEN(prev));
else
len = min(sizeof(name), (word32)(haystack - prev));
@ -5034,7 +5034,7 @@ int SetCipherList(Suites* s, const char* list)
return SUITES_ERROR;
}
length = sizeof(ProtocolVersion) + RAN_LEN
length = (word32)sizeof(ProtocolVersion) + RAN_LEN
+ idSz + ENUM_LEN
+ ssl->suites->suiteSz + SUITE_LEN
+ COMP_LEN + ENUM_LEN;
@ -5065,7 +5065,7 @@ int SetCipherList(Suites* s, const char* list)
/* client hello, first version */
XMEMCPY(output + idx, &ssl->version, sizeof(ProtocolVersion));
idx += sizeof(ProtocolVersion);
idx += (int)sizeof(ProtocolVersion);
ssl->chVersion = ssl->version; /* store in case changed */
/* then random */
@ -5176,7 +5176,7 @@ int SetCipherList(Suites* s, const char* list)
}
#endif
XMEMCPY(&pv, input + *inOutIdx, sizeof(pv));
*inOutIdx += sizeof(pv);
*inOutIdx += (word32)sizeof(pv);
cookieSz = input[(*inOutIdx)++];
@ -5209,7 +5209,7 @@ int SetCipherList(Suites* s, const char* list)
if (ssl->toInfoOn) AddLateName("ServerHello", &ssl->timeoutInfo);
#endif
XMEMCPY(&pv, input + i, sizeof(pv));
i += sizeof(pv);
i += (word32)sizeof(pv);
if (pv.minor > ssl->version.minor) {
CYASSL_MSG("Server using higher version, fatal error");
return VERSION_ERROR;
@ -5958,7 +5958,7 @@ int SetCipherList(Suites* s, const char* list)
/* now write to output */
/* first version */
XMEMCPY(output + idx, &ssl->version, sizeof(ProtocolVersion));
idx += sizeof(ProtocolVersion);
idx += (word32)sizeof(ProtocolVersion);
/* then random */
if (!ssl->options.resuming)
@ -7079,7 +7079,7 @@ int SetCipherList(Suites* s, const char* list)
XMEMCPY(&pv, input + i, sizeof(pv));
ssl->chVersion = pv; /* store */
i += sizeof(pv);
i += (word32)sizeof(pv);
if (ssl->version.minor > pv.minor) {
byte havePSK = 0;
if (!ssl->options.downgrade) {

View File

@ -160,7 +160,7 @@ int EmbedReceive(CYASSL *ssl, char *buf, int sz, void *ctx)
}
#endif
recvd = RECV_FUNCTION(sd, (char *)buf, sz, 0);
recvd = (int)RECV_FUNCTION(sd, (char *)buf, sz, 0);
if (recvd < 0) {
err = LastError();
@ -213,7 +213,7 @@ int EmbedSend(CYASSL* ssl, char *buf, int sz, void *ctx)
(void)ssl;
sent = SEND_FUNCTION(sd, &buf[sz - len], len, 0);
sent = (int)SEND_FUNCTION(sd, &buf[sz - len], len, 0);
if (sent < 0) {
err = LastError();
@ -283,8 +283,8 @@ int EmbedReceiveFrom(CYASSL *ssl, char *buf, int sz, void *ctx)
(char*)&timeout, sizeof(timeout));
}
recvd = RECVFROM_FUNCTION(sd, (char *)buf, sz, 0,
(struct sockaddr*)&peer, &peerSz);
recvd = (int)RECVFROM_FUNCTION(sd, (char *)buf, sz, 0,
(struct sockaddr*)&peer, &peerSz);
if (recvd < 0) {
err = LastError();
@ -345,8 +345,8 @@ int EmbedSendTo(CYASSL* ssl, char *buf, int sz, void *ctx)
(void)ssl;
CYASSL_ENTER("EmbedSendTo()");
sent = SENDTO_FUNCTION(sd, &buf[sz - len], len, 0,
dtlsCtx->peer.sa, dtlsCtx->peer.sz);
sent = (int)SENDTO_FUNCTION(sd, &buf[sz - len], len, 0,
dtlsCtx->peer.sa, dtlsCtx->peer.sz);
if (sent < 0) {
err = LastError();

View File

@ -1173,7 +1173,7 @@ int DeriveKeys(CYASSL* ssl)
idx += RAN_LEN;
XMEMCPY(shaInput + idx, ssl->arrays->clientRandom, RAN_LEN);
ShaUpdate(&sha, shaInput, sizeof(shaInput) - KEY_PREFIX + j);
ShaUpdate(&sha, shaInput, (word32)sizeof(shaInput) - KEY_PREFIX + j);
ShaFinal(&sha, shaOutput);
XMEMCPY(&md5Input[SECRET_LEN], shaOutput, SHA_DIGEST_SIZE);

View File

@ -513,7 +513,7 @@ static int SetPassword(char* passwd, int sz, int rw, void* userdata)
{
(void)rw;
XSTRNCPY(passwd, userdata, sz);
return XSTRLEN(userdata);
return (int)XSTRLEN(userdata);
}
@ -1150,7 +1150,7 @@ static int ProcessServerHello(const byte* input, int* sslBytes,
XMEMCPY(&pv, input, sizeof(ProtocolVersion));
input += sizeof(ProtocolVersion);
*sslBytes -= sizeof(ProtocolVersion);
*sslBytes -= (int)sizeof(ProtocolVersion);
session->sslServer->version = pv;
session->sslClient->version = pv;
@ -1275,7 +1275,7 @@ static int ProcessClientHello(const byte* input, int* sslBytes,
/* skip, get negotiated one from server hello */
input += sizeof(ProtocolVersion);
*sslBytes -= sizeof(ProtocolVersion);
*sslBytes -= (int)sizeof(ProtocolVersion);
XMEMCPY(session->sslServer->arrays->clientRandom, input, RAN_LEN);
XMEMCPY(session->sslClient->arrays->clientRandom, input, RAN_LEN);
@ -1828,7 +1828,7 @@ static int CheckHeaders(IpInfo* ipInfo, TcpInfo* tcpInfo, const byte* packet,
SetError(PACKET_HDR_SHORT_STR, error, NULL, 0);
return -1;
}
*sslBytes = packet + length - *sslFrame;
*sslBytes = (int)(packet + length - *sslFrame);
return 0;
}
@ -2315,7 +2315,7 @@ doMessage:
if (tmp < end) {
Trace(ANOTHER_MSG_STR);
sslFrame = tmp;
sslBytes = end - tmp;
sslBytes = (int)(end - tmp);
goto doMessage;
}

View File

@ -84,7 +84,7 @@
char* mystrnstr(const char* s1, const char* s2, unsigned int n)
{
unsigned int s2_len = XSTRLEN(s2);
unsigned int s2_len = (unsigned int)XSTRLEN(s2);
if (s2_len == 0)
return (char*)s1;
@ -466,7 +466,7 @@ char* CyaSSL_ERR_error_string(unsigned long errNumber, char* data)
CYASSL_ENTER("ERR_error_string");
if (data) {
SetErrorString(errNumber, data);
SetErrorString((int)errNumber, data);
return data;
}
@ -820,7 +820,7 @@ int AddCA(CYASSL_CERT_MANAGER* cm, buffer der, int type, int verify)
/* Remove PEM header/footer, convert to ASN1, store any encrypted data
info->consumed tracks of PEM bytes consumed in case multiple parts */
int PemToDer(const unsigned char* buff, long sz, int type,
int PemToDer(const unsigned char* buff, long longSz, int type,
buffer* der, void* heap, EncryptedInfo* info, int* eccKey)
{
char header[PEM_LINE_LEN];
@ -832,6 +832,7 @@ int AddCA(CYASSL_CERT_MANAGER* cm, buffer der, int type, int verify)
int pkcs8 = 0;
int pkcs8Enc = 0;
int dynamicType = 0;
int sz = (int)longSz;
(void)heap;
(void)dynamicType;
@ -971,9 +972,9 @@ int AddCA(CYASSL_CERT_MANAGER* cm, buffer der, int type, int verify)
if (neededSz > sz || neededSz < 0) return SSL_BAD_FILE;
der->buffer = (byte*) XMALLOC(neededSz, heap, dynamicType);
if (!der->buffer) return MEMORY_ERROR;
der->length = neededSz;
der->length = (word32)neededSz;
if (Base64_Decode((byte*)headerEnd, neededSz, der->buffer,
if (Base64_Decode((byte*)headerEnd, (word32)neededSz, der->buffer,
&der->length) < 0)
return SSL_BAD_FILE;
@ -1051,7 +1052,8 @@ int AddCA(CYASSL_CERT_MANAGER* cm, buffer der, int type, int verify)
if ( (sz - consumed) > (int)bufferSz) {
CYASSL_MSG("Growing Tmp Chain Buffer");
bufferSz = sz - consumed; /* will shrink to actual size */
bufferSz = (word32)(sz - consumed);
/* will shrink to actual size */
chainBuffer = (byte*)XMALLOC(bufferSz, ctx->heap,
DYNAMIC_TYPE_FILE);
if (chainBuffer == NULL) {
@ -1120,7 +1122,7 @@ int AddCA(CYASSL_CERT_MANAGER* cm, buffer der, int type, int verify)
der.buffer = (byte*) XMALLOC(sz, ctx->heap, dynamicType);
if (!der.buffer) return MEMORY_ERROR;
XMEMCPY(der.buffer, buff, sz);
der.length = sz;
der.length = (word32)sz;
}
#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
@ -1400,7 +1402,7 @@ int ProcessFile(CYASSL_CTX* ctx, const char* fname, int format, int type,
dynamic = 1;
}
if ( (ret = XFREAD(myBuffer, sz, 1, file)) < 0)
if ( (ret = (int)XFREAD(myBuffer, sz, 1, file)) < 0)
ret = SSL_BAD_FILE;
else {
if (type == CA_TYPE && format == SSL_FILETYPE_PEM)
@ -1563,10 +1565,10 @@ int CyaSSL_CertManagerVerify(CYASSL_CERT_MANAGER* cm, const char* fname,
dynamic = 1;
}
if ( (ret = XFREAD(myBuffer, sz, 1, file)) < 0)
if ( (ret = (int)XFREAD(myBuffer, sz, 1, file)) < 0)
ret = SSL_BAD_FILE;
else
ret = CyaSSL_CertManagerVerifyBuffer(cm, myBuffer, sz, format);
ret = CyaSSL_CertManagerVerifyBuffer(cm, myBuffer, (int)sz, format);
XFCLOSE(file);
if (dynamic) XFREE(myBuffer, cm->heap, DYNAMIC_TYPE_FILE);
@ -1982,7 +1984,7 @@ static int CyaSSL_SetTmpDH_buffer_wrapper(CYASSL_CTX* ctx, CYASSL* ssl,
word32 gSz = sizeof(g);
der.buffer = (byte*)buf;
der.length = sz;
der.length = (word32)sz;
if (format != SSL_FILETYPE_ASN1 && format != SSL_FILETYPE_PEM)
return SSL_BAD_FILETYPE;
@ -2084,7 +2086,7 @@ static int CyaSSL_SetTmpDH_file_wrapper(CYASSL_CTX* ctx, CYASSL* ssl,
dynamic = 1;
}
if ( (ret = XFREAD(myBuffer, sz, 1, file)) < 0)
if ( (ret = (int)XFREAD(myBuffer, sz, 1, file)) < 0)
ret = SSL_BAD_FILE;
else {
if (ssl)
@ -3133,7 +3135,7 @@ int CyaSSL_set_compression(CYASSL* ssl)
CYASSL_ENTER("CyaSSL_writev");
for (i = 0; i < iovcnt; i++)
send += iov[i].iov_len;
send += (int)iov[i].iov_len;
if (send > (int)sizeof(tmp)) {
byte* tmp2 = (byte*) XMALLOC(send, ssl->heap,
@ -3146,7 +3148,7 @@ int CyaSSL_set_compression(CYASSL* ssl)
for (i = 0; i < iovcnt; i++) {
XMEMCPY(&myBuffer[idx], iov[i].iov_base, iov[i].iov_len);
idx += iov[i].iov_len;
idx += (int)iov[i].iov_len;
}
ret = CyaSSL_write(ssl, myBuffer, send);
@ -4172,7 +4174,7 @@ int CyaSSL_set_compression(CYASSL* ssl)
unsigned long sz)
{
CYASSL_ENTER("CyaSSL_MD5_Update");
Md5Update((Md5*)md5, (const byte*)input, sz);
Md5Update((Md5*)md5, (const byte*)input, (word32)sz);
}
@ -4197,7 +4199,7 @@ int CyaSSL_set_compression(CYASSL* ssl)
unsigned long sz)
{
CYASSL_ENTER("SHA_Update");
ShaUpdate((Sha*)sha, (const byte*)input, sz);
ShaUpdate((Sha*)sha, (const byte*)input, (word32)sz);
}
@ -4244,7 +4246,7 @@ int CyaSSL_set_compression(CYASSL* ssl)
unsigned long sz)
{
CYASSL_ENTER("SHA256_Update");
Sha256Update((Sha256*)sha, (const byte*)input, sz);
Sha256Update((Sha256*)sha, (const byte*)input, (word32)sz);
}
@ -4271,7 +4273,7 @@ int CyaSSL_set_compression(CYASSL* ssl)
unsigned long sz)
{
CYASSL_ENTER("SHA384_Update");
Sha384Update((Sha384*)sha, (const byte*)input, sz);
Sha384Update((Sha384*)sha, (const byte*)input, (word32)sz);
}
@ -4300,7 +4302,7 @@ int CyaSSL_set_compression(CYASSL* ssl)
unsigned long sz)
{
CYASSL_ENTER("SHA512_Update");
Sha512Update((Sha512*)sha, (const byte*)input, sz);
Sha512Update((Sha512*)sha, (const byte*)input, (word32)sz);
}
@ -5000,9 +5002,9 @@ int CyaSSL_set_compression(CYASSL* ssl)
Des_SetKey(&myDes, (const byte*)schedule, (const byte*)ivec, !enc);
if (enc)
Des_CbcEncrypt(&myDes, output, input, length);
Des_CbcEncrypt(&myDes, output, input, (word32)length);
else
Des_CbcDecrypt(&myDes, output, input, length);
Des_CbcDecrypt(&myDes, output, input, (word32)length);
}
@ -5017,9 +5019,9 @@ int CyaSSL_set_compression(CYASSL* ssl)
Des_SetKey(&myDes, (const byte*)schedule, (const byte*)ivec, !enc);
if (enc)
Des_CbcEncrypt(&myDes, output, input, length);
Des_CbcEncrypt(&myDes, output, input, (word32)length);
else
Des_CbcDecrypt(&myDes, output, input, length);
Des_CbcDecrypt(&myDes, output, input, (word32)length);
XMEMCPY(ivec, output + length - sizeof(DES_cblock), sizeof(DES_cblock));
}
@ -6564,7 +6566,7 @@ static int initGlobalRNG = 0;
return 0;
}
if (Base16_Decode((byte*)str, strlen(str), decoded, &decSz) < 0) {
if (Base16_Decode((byte*)str, (int)strlen(str), decoded, &decSz) < 0) {
CYASSL_MSG("Bad Base16_Decode error");
return 0;
}

View File

@ -662,7 +662,7 @@ void test_client_nofail(void* args)
char msg[64] = "hello cyassl!";
char reply[1024];
int input;
int msgSz = strlen(msg);
int msgSz = (int)strlen(msg);
int argc = ((func_args*)args)->argc;
char** argv = ((func_args*)args)->argv;