diff options
author | Andy Polyakov <appro@openssl.org> | 2017-11-11 22:23:12 +0100 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2017-11-13 10:58:57 +0100 |
commit | 3a63c0edab842af3e84ef1cad2b4eb701eece3e1 (patch) | |
tree | c45bf7fb2f69874b2779b33e5597a59bbc92e648 /test | |
parent | 802127e8fc07cbef499b645e7e1ae48ce3ed981c (diff) |
Resolve warnings in VC-WIN32 build, which allows to add /WX.
It's argued that /WX allows to keep better focus on new code, which
motivates its comeback...
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4721)
Diffstat (limited to 'test')
-rw-r--r-- | test/asn1_encode_test.c | 10 | ||||
-rw-r--r-- | test/asn1_time_test.c | 15 | ||||
-rw-r--r-- | test/bad_dtls_test.c | 8 | ||||
-rw-r--r-- | test/clienthellotest.c | 2 | ||||
-rw-r--r-- | test/crltest.c | 2 | ||||
-rw-r--r-- | test/ct_test.c | 5 | ||||
-rw-r--r-- | test/handshake_helper.c | 4 | ||||
-rw-r--r-- | test/packettest.c | 4 | ||||
-rw-r--r-- | test/sanitytest.c | 3 | ||||
-rw-r--r-- | test/ssltest_old.c | 2 | ||||
-rw-r--r-- | test/testutil/driver.c | 4 |
11 files changed, 32 insertions, 27 deletions
diff --git a/test/asn1_encode_test.c b/test/asn1_encode_test.c index 3b8d4184be..e9f459ad65 100644 --- a/test/asn1_encode_test.c +++ b/test/asn1_encode_test.c @@ -577,14 +577,14 @@ static size_t der_encode_length(size_t len, unsigned char **pp) if (pp != NULL) { if (lenbytes == 1) { - *(*pp)++ = len; + *(*pp)++ = (unsigned char)len; } else { - *(*pp)++ = lenbytes - 1; + *(*pp)++ = (unsigned char)(lenbytes - 1); if (lenbytes == 2) { - *(*pp)++ = 0x80 | len; + *(*pp)++ = (unsigned char)(0x80 | len); } else { - *(*pp)++ = 0x80 | (len >> 8); - *(*pp)++ = len & 0xff; + *(*pp)++ = (unsigned char)(0x80 | (len >> 8)); + *(*pp)++ = (unsigned char)(len); } } } diff --git a/test/asn1_time_test.c b/test/asn1_time_test.c index 874260ec84..113b6fb01d 100644 --- a/test/asn1_time_test.c +++ b/test/asn1_time_test.c @@ -79,22 +79,23 @@ static struct testdata tbl_testdata_pos[] = { /* ASSUMES SIGNED TIME_T */ static struct testdata tbl_testdata_neg[] = { - { "19011213204552Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 1, -2147483648, -1, 0, }, + { "19011213204552Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 1, INT_MIN, -1, 0, }, { "691006121456Z", V_ASN1_UTCTIME, V_ASN1_UTCTIME, 1, -7472704, -1, 1, }, { "19691006121456Z", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 1, -7472704, -1, 1, }, }; +/* explicit casts to time_t short warnings on systems with 32-bit time_t */ static struct testdata tbl_testdata_pos_64bit[] = { - { "20380119031408Z", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 1, 0x80000000, 1, 1, }, - { "20380119031409Z", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 1, 0x80000001, 1, 1, }, - { "380119031408Z", V_ASN1_UTCTIME, V_ASN1_UTCTIME, 1, 0x80000000, 1, 1, }, - { "20500101120000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 1, 2524651200, 1, 0, }, + { "20380119031408Z", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 1, (time_t)0x80000000, 1, 1, }, + { "20380119031409Z", V_ASN1_GENERALIZEDTIME, V_ASN1_UTCTIME, 1, (time_t)0x80000001, 1, 1, }, + { "380119031408Z", V_ASN1_UTCTIME, V_ASN1_UTCTIME, 1, (time_t)0x80000000, 1, 1, }, + { "20500101120000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 1, (time_t)2524651200, 1, 0, }, }; /* ASSUMES SIGNED TIME_T */ static struct testdata tbl_testdata_neg_64bit[] = { - { "19011213204551Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 1, -2147483649, -1, 0, }, - { "19000101120000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 1, -2208945600, -1, 0, }, + { "19011213204551Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 1, (time_t)-2147483649LL, -1, 0, }, + { "19000101120000Z", V_ASN1_GENERALIZEDTIME, V_ASN1_GENERALIZEDTIME, 1, (time_t)-2208945600LL, -1, 0, }, }; /* A baseline time to compare to */ diff --git a/test/bad_dtls_test.c b/test/bad_dtls_test.c index 102de24464..5bd4e22d0a 100644 --- a/test/bad_dtls_test.c +++ b/test/bad_dtls_test.c @@ -306,8 +306,8 @@ static int send_record(BIO *rbio, unsigned char type, uint64_t seqnr, HMAC_Update(ctx, seq, 6); HMAC_Update(ctx, &type, 1); HMAC_Update(ctx, ver, 2); /* Version */ - lenbytes[0] = len >> 8; - lenbytes[1] = len & 0xff; + lenbytes[0] = (unsigned char)(len >> 8); + lenbytes[1] = (unsigned char)(len); HMAC_Update(ctx, lenbytes, 2); /* Length */ HMAC_Update(ctx, enc, len); /* Finally the data itself */ HMAC_Final(ctx, enc + len, NULL); @@ -331,8 +331,8 @@ static int send_record(BIO *rbio, unsigned char type, uint64_t seqnr, BIO_write(rbio, ver, 2); BIO_write(rbio, epoch, 2); BIO_write(rbio, seq, 6); - lenbytes[0] = (len + sizeof(iv)) >> 8; - lenbytes[1] = (len + sizeof(iv)) & 0xff; + lenbytes[0] = (unsigned char)((len + sizeof(iv)) >> 8); + lenbytes[1] = (unsigned char)(len + sizeof(iv)); BIO_write(rbio, lenbytes, 2); BIO_write(rbio, iv, sizeof(iv)); diff --git a/test/clienthellotest.c b/test/clienthellotest.c index acd27d4a2b..8ba65ce4fb 100644 --- a/test/clienthellotest.c +++ b/test/clienthellotest.c @@ -126,7 +126,7 @@ static int test_client_hello(int currtest) * We reset the creation time so that we don't discard the session as * too old. */ - if (!TEST_true(SSL_SESSION_set_time(sess, time(NULL))) + if (!TEST_true(SSL_SESSION_set_time(sess, (long)time(NULL))) || !TEST_true(SSL_set_session(con, sess))) goto end; } diff --git a/test/crltest.c b/test/crltest.c index 738ca23ce5..b96463705c 100644 --- a/test/crltest.c +++ b/test/crltest.c @@ -261,7 +261,7 @@ static int verify(X509 *leaf, X509 *root, STACK_OF(X509_CRL) *crls, X509_STORE_CTX_set0_trusted_stack(ctx, roots); X509_STORE_CTX_set0_crls(ctx, crls); X509_VERIFY_PARAM_set_time(param, PARAM_TIME); - if (!TEST_long_eq(X509_VERIFY_PARAM_get_time(param), PARAM_TIME)) + if (!TEST_long_eq((long)X509_VERIFY_PARAM_get_time(param), PARAM_TIME)) goto err; X509_VERIFY_PARAM_set_depth(param, 16); if (flags) diff --git a/test/ct_test.c b/test/ct_test.c index 45dd2e92f5..21f1868220 100644 --- a/test/ct_test.c +++ b/test/ct_test.c @@ -501,10 +501,11 @@ static int test_default_ct_policy_eval_ctx_time_is_now(void) int success = 0; CT_POLICY_EVAL_CTX *ct_policy_ctx = CT_POLICY_EVAL_CTX_new(); const time_t default_time = CT_POLICY_EVAL_CTX_get_time(ct_policy_ctx) / - 1000; + 1000; const time_t time_tolerance = 600; /* 10 minutes */ - if (!TEST_uint_le(fabs(difftime(time(NULL), default_time)), time_tolerance)) + if (!TEST_uint_le((unsigned int)fabs(difftime(time(NULL), default_time)), + (unsigned int)time_tolerance)) goto end; success = 1; diff --git a/test/handshake_helper.c b/test/handshake_helper.c index ad1b7090a6..188ec9ed96 100644 --- a/test/handshake_helper.c +++ b/test/handshake_helper.c @@ -350,14 +350,14 @@ static int parse_protos(const char *protos, unsigned char **out, size_t *outlen) if ((*out)[i] == ',') { if (!TEST_int_gt(i - 1, prefix)) goto err; - (*out)[prefix] = i - 1 - prefix; + (*out)[prefix] = (unsigned char)(i - 1 - prefix); prefix = i; } i++; } if (!TEST_int_gt(len, prefix)) goto err; - (*out)[prefix] = len - prefix; + (*out)[prefix] = (unsigned char)(len - prefix); return 1; err: diff --git a/test/packettest.c b/test/packettest.c index 98b9ec4889..716dec303d 100644 --- a/test/packettest.c +++ b/test/packettest.c @@ -352,7 +352,7 @@ static int test_PACKET_get_length_prefixed_1(void) unsigned int i; PACKET pkt, short_pkt, subpkt = {0}; - buf1[0] = len; + buf1[0] = (unsigned char)len; for (i = 1; i < BUF_LEN; i++) buf1[i] = (i * 2) & 0xff; @@ -422,7 +422,7 @@ static int test_PACKET_as_length_prefixed_1(void) unsigned int i; PACKET pkt, exact_pkt, subpkt = {0}; - buf1[0] = len; + buf1[0] = (unsigned char)len; for (i = 1; i < BUF_LEN; i++) buf1[i] = (i * 2) & 0xff; diff --git a/test/sanitytest.c b/test/sanitytest.c index e9afb443f9..5954f7e507 100644 --- a/test/sanitytest.c +++ b/test/sanitytest.c @@ -8,9 +8,8 @@ */ #include <string.h> -#include "internal/numbers.h" - #include "testutil.h" +#include "internal/numbers.h" static int test_sanity_null_zero(void) { diff --git a/test/ssltest_old.c b/test/ssltest_old.c index ebe052f55c..a4e596a109 100644 --- a/test/ssltest_old.c +++ b/test/ssltest_old.c @@ -281,7 +281,7 @@ static unsigned char *next_protos_parse(size_t *outlen, OPENSSL_free(out); return NULL; } - out[start] = i - start; + out[start] = (unsigned char)(i - start); start = i + 1; } else out[i + 1] = in[i]; diff --git a/test/testutil/driver.c b/test/testutil/driver.c index 2c28a73eb2..48593f9201 100644 --- a/test/testutil/driver.c +++ b/test/testutil/driver.c @@ -17,6 +17,10 @@ #include "internal/nelem.h" #include <openssl/bio.h> +#ifdef _WIN32 +# define strdup _strdup +#endif + /* * Declares the structures needed to register each test case function. */ |