Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3a63c0e

Browse files
author
Andy Polyakov
committed
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 <[email protected]> (Merged from openssl#4721)
1 parent 802127e commit 3a63c0e

24 files changed

+182
-162
lines changed

apps/apps.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1926,7 +1926,7 @@ unsigned char *next_protos_parse(size_t *outlen, const char *in)
19261926
OPENSSL_free(out);
19271927
return NULL;
19281928
}
1929-
out[start] = i - start;
1929+
out[start] = (unsigned char)(i - start);
19301930
start = i + 1;
19311931
} else {
19321932
out[i + 1] = in[i];

apps/s_client.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,10 +417,11 @@ static int serverinfo_cli_parse_cb(SSL *s, unsigned int ext_type,
417417
unsigned char ext_buf[4 + 65536];
418418

419419
/* Reconstruct the type/len fields prior to extension data */
420-
ext_buf[0] = ext_type >> 8;
421-
ext_buf[1] = ext_type & 0xFF;
422-
ext_buf[2] = inlen >> 8;
423-
ext_buf[3] = inlen & 0xFF;
420+
inlen &= 0xffff; /* for formal memcmpy correctness */
421+
ext_buf[0] = (unsigned char)(ext_type >> 8);
422+
ext_buf[1] = (unsigned char)(ext_type);
423+
ext_buf[2] = (unsigned char)(inlen >> 8);
424+
ext_buf[3] = (unsigned char)(inlen);
424425
memcpy(ext_buf + 4, in, inlen);
425426

426427
BIO_snprintf(pem_name, sizeof(pem_name), "SERVERINFO FOR EXTENSION %d",

apps/speed.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3198,8 +3198,8 @@ static void multiblock_speed(const EVP_CIPHER *evp_cipher)
31983198

31993199
RAND_bytes(out, 16);
32003200
len += 16;
3201-
aad[11] = len >> 8;
3202-
aad[12] = len;
3201+
aad[11] = (unsigned char)(len >> 8);
3202+
aad[12] = (unsigned char)(len);
32033203
pad = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_TLS1_AAD,
32043204
EVP_AEAD_TLS1_AAD_LEN, aad);
32053205
EVP_Cipher(ctx, out, inp, len + pad);

crypto/bio/b_addr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
821821

822822
if (endp != service && *endp == '\0'
823823
&& portnum > 0 && portnum < 65536) {
824-
se_fallback.s_port = htons(portnum);
824+
se_fallback.s_port = htons((unsigned short)portnum);
825825
se_fallback.s_proto = proto;
826826
se = &se_fallback;
827827
} else if (endp == service) {

crypto/bio/b_print.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
#include <stdio.h>
1111
#include <string.h>
12+
#include "internal/cryptlib.h"
1213
#include "internal/ctype.h"
1314
#include "internal/numbers.h"
14-
#include "internal/cryptlib.h"
1515
#include <openssl/bio.h>
1616

1717
/*

crypto/bio/b_sock2.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ int BIO_socket(int domain, int socktype, int protocol, int options)
7676
*/
7777
int BIO_connect(int sock, const BIO_ADDR *addr, int options)
7878
{
79-
int on = 1;
79+
const int on = 1;
8080

8181
if (sock == -1) {
8282
BIOerr(BIO_F_BIO_CONNECT, BIO_R_INVALID_SOCKET);
@@ -87,15 +87,17 @@ int BIO_connect(int sock, const BIO_ADDR *addr, int options)
8787
return 0;
8888

8989
if (options & BIO_SOCK_KEEPALIVE) {
90-
if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)) != 0) {
90+
if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
91+
(const void *)&on, sizeof(on)) != 0) {
9192
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
9293
BIOerr(BIO_F_BIO_CONNECT, BIO_R_UNABLE_TO_KEEPALIVE);
9394
return 0;
9495
}
9596
}
9697

9798
if (options & BIO_SOCK_NODELAY) {
98-
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)) != 0) {
99+
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
100+
(const void *)&on, sizeof(on)) != 0) {
99101
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
100102
BIOerr(BIO_F_BIO_CONNECT, BIO_R_UNABLE_TO_NODELAY);
101103
return 0;
@@ -161,7 +163,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
161163
return 0;
162164
}
163165

164-
if (getsockopt(sock, SOL_SOCKET, SO_TYPE, &socktype, &socktype_len) != 0
166+
if (getsockopt(sock, SOL_SOCKET, SO_TYPE,
167+
(void *)&socktype, &socktype_len) != 0
165168
|| socktype_len != sizeof(socktype)) {
166169
SYSerr(SYS_F_GETSOCKOPT, get_last_socket_error());
167170
BIOerr(BIO_F_BIO_LISTEN, BIO_R_GETTING_SOCKTYPE);
@@ -175,7 +178,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
175178
/* SO_REUSEADDR has different behavior on Windows than on
176179
* other operating systems, don't set it there. */
177180
if (options & BIO_SOCK_REUSEADDR) {
178-
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) != 0) {
181+
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
182+
(const void *)&on, sizeof(on)) != 0) {
179183
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
180184
BIOerr(BIO_F_BIO_LISTEN, BIO_R_UNABLE_TO_REUSEADDR);
181185
return 0;
@@ -184,15 +188,17 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
184188
# endif
185189

186190
if (options & BIO_SOCK_KEEPALIVE) {
187-
if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)) != 0) {
191+
if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
192+
(const void *)&on, sizeof(on)) != 0) {
188193
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
189194
BIOerr(BIO_F_BIO_LISTEN, BIO_R_UNABLE_TO_KEEPALIVE);
190195
return 0;
191196
}
192197
}
193198

194199
if (options & BIO_SOCK_NODELAY) {
195-
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)) != 0) {
200+
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
201+
(const void *)&on, sizeof(on)) != 0) {
196202
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
197203
BIOerr(BIO_F_BIO_LISTEN, BIO_R_UNABLE_TO_NODELAY);
198204
return 0;
@@ -201,7 +207,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
201207

202208
# ifdef IPV6_V6ONLY
203209
if ((options & BIO_SOCK_V6_ONLY) && BIO_ADDR_family(addr) == AF_INET6) {
204-
if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) != 0) {
210+
if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
211+
(const void *)&on, sizeof(on)) != 0) {
205212
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
206213
BIOerr(BIO_F_BIO_LISTEN, BIO_R_LISTEN_V6_ONLY);
207214
return 0;

crypto/conf/conf_sap.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
#include <openssl/asn1.h>
1616
#include <openssl/engine.h>
1717

18+
#ifdef _WIN32
19+
# define strdup _strdup
20+
#endif
21+
1822
/*
1923
* This is the automatic configuration loader: it is called automatically by
2024
* OpenSSL when any of a number of standard initialisation functions are

0 commit comments

Comments
 (0)