Skip to content

Commit 28bd4eb

Browse files
authored
Merge pull request #7520 from bandi13/fixConversion
Fix conversion
2 parents 7526f52 + a1797f0 commit 28bd4eb

34 files changed

Lines changed: 1250 additions & 1247 deletions

File tree

examples/benchmark/tls_bench.c

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ static int ServerMemSend(info_t* info, char* buf, int sz)
412412
}
413413
#endif
414414

415-
XMEMCPY(&info->to_client.buf[info->to_client.write_idx], buf, sz);
415+
XMEMCPY(&info->to_client.buf[info->to_client.write_idx], buf, (size_t)sz);
416416
info->to_client.write_idx += sz;
417417
info->to_client.write_bytes += sz;
418418

@@ -443,7 +443,7 @@ static int ServerMemRecv(info_t* info, char* buf, int sz)
443443
}
444444
#endif
445445

446-
XMEMCPY(buf, &info->to_server.buf[info->to_server.read_idx], sz);
446+
XMEMCPY(buf, &info->to_server.buf[info->to_server.read_idx], (size_t)sz);
447447
info->to_server.read_idx += sz;
448448
info->to_server.read_bytes += sz;
449449

@@ -486,7 +486,7 @@ static int ClientMemSend(info_t* info, char* buf, int sz)
486486
}
487487
#endif
488488

489-
XMEMCPY(&info->to_server.buf[info->to_server.write_idx], buf, sz);
489+
XMEMCPY(&info->to_server.buf[info->to_server.write_idx], buf, (size_t)sz);
490490
info->to_server.write_idx += sz;
491491
info->to_server.write_bytes += sz;
492492

@@ -517,7 +517,7 @@ static int ClientMemRecv(info_t* info, char* buf, int sz)
517517
}
518518
#endif
519519

520-
XMEMCPY(buf, &info->to_client.buf[info->to_client.read_idx], sz);
520+
XMEMCPY(buf, &info->to_client.buf[info->to_client.read_idx], (size_t)sz);
521521
info->to_client.read_idx += sz;
522522
info->to_client.read_bytes += sz;
523523

@@ -544,7 +544,7 @@ static int ClientMemRecv(info_t* info, char* buf, int sz)
544544

545545
static int SocketRecv(int sockFd, char* buf, int sz)
546546
{
547-
int recvd = (int)recv(sockFd, buf, sz, 0);
547+
int recvd = (int)recv(sockFd, buf, (size_t)sz, 0);
548548
if (recvd == -1) {
549549
switch (errno) {
550550
#if EAGAIN != SOCKET_EWOULDBLOCK
@@ -572,7 +572,7 @@ static int SocketRecv(int sockFd, char* buf, int sz)
572572

573573
static int SocketSend(int sockFd, char* buf, int sz)
574574
{
575-
int sent = (int)send(sockFd, buf, sz, 0);
575+
int sent = (int)send(sockFd, buf, (size_t)sz, 0);
576576
if (sent == -1) {
577577
switch (errno) {
578578
#if EAGAIN != SOCKET_EWOULDBLOCK
@@ -618,7 +618,7 @@ static int ReceiveFrom(WOLFSSL *ssl, int sd, char *buf, int sz)
618618
}
619619
}
620620

621-
recvd = (int)recvfrom(sd, buf, sz, 0, (SOCKADDR*)&peer, &peerSz);
621+
recvd = (int)recvfrom(sd, buf, (size_t)sz, 0, (SOCKADDR*)&peer, &peerSz);
622622

623623
if (recvd < 0) {
624624
if (errno == SOCKET_EWOULDBLOCK || errno == SOCKET_EAGAIN) {
@@ -658,7 +658,7 @@ static int SendTo(int sd, char *buf, int sz, const struct sockaddr *peer,
658658
{
659659
int sent;
660660

661-
sent = (int)sendto(sd, buf, sz, 0, peer, peerSz);
661+
sent = (int)sendto(sd, buf, (size_t)sz, 0, peer, peerSz);
662662

663663
if (sent < 0) {
664664
if (errno == SOCKET_EWOULDBLOCK || errno == SOCKET_EAGAIN) {
@@ -813,13 +813,13 @@ static int SetupSocketAndConnect(info_t* info, const char* host,
813813
/* Setup server address */
814814
XMEMSET(&servAddr, 0, sizeof(servAddr));
815815
servAddr.sin_family = AF_INET;
816-
servAddr.sin_port = htons(port);
816+
servAddr.sin_port = htons((u_int16_t)port);
817817

818818
/* Resolve host */
819819
entry = gethostbyname(host);
820820
if (entry) {
821821
XMEMCPY(&servAddr.sin_addr.s_addr, entry->h_addr_list[0],
822-
entry->h_length);
822+
(size_t)entry->h_length);
823823
}
824824
else {
825825
servAddr.sin_addr.s_addr = inet_addr(host);
@@ -981,7 +981,7 @@ static int bench_tls_client(info_t* info)
981981

982982

983983
/* Allocate and initialize a packet sized buffer */
984-
writeBuf = (unsigned char*)XMALLOC(info->packetSize, NULL,
984+
writeBuf = (unsigned char*)XMALLOC((size_t)info->packetSize, NULL,
985985
DYNAMIC_TYPE_TMP_BUFFER);
986986
if (writeBuf == NULL) {
987987
fprintf(stderr, "failed to allocate write memory\n");
@@ -990,7 +990,7 @@ static int bench_tls_client(info_t* info)
990990

991991
/* Allocate read buffer */
992992
readBufSz = info->packetSize;
993-
readBuf = (unsigned char*)XMALLOC(readBufSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
993+
readBuf = (unsigned char*)XMALLOC((size_t)readBufSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
994994
if (readBuf == NULL) {
995995
fprintf(stderr, "failed to allocate read memory\n");
996996
ret = MEMORY_E; goto exit;
@@ -1089,7 +1089,7 @@ static int bench_tls_client(info_t* info)
10891089
info->client.shutdown = 1;
10901090

10911091
writeSz = (int)XSTRLEN(kShutdown) + 1;
1092-
XMEMCPY(writeBuf, kShutdown, writeSz); /* include null term */
1092+
XMEMCPY(writeBuf, kShutdown, (size_t)writeSz); /* include null term */
10931093
if (info->showVerbose) {
10941094
fprintf(stderr, "Sending shutdown\n");
10951095
}
@@ -1102,8 +1102,8 @@ static int bench_tls_client(info_t* info)
11021102
}
11031103
}
11041104
else {
1105-
XMEMSET(writeBuf, 0, info->packetSize);
1106-
XSTRNCPY((char*)writeBuf, kTestStr, info->packetSize);
1105+
XMEMSET(writeBuf, 0, (size_t)info->packetSize);
1106+
XSTRNCPY((char*)writeBuf, kTestStr, (size_t)info->packetSize);
11071107
}
11081108

11091109
/* write / read echo loop */
@@ -1131,7 +1131,7 @@ static int bench_tls_client(info_t* info)
11311131
total_sz += ret;
11321132

11331133
/* read echo of message from server */
1134-
XMEMSET(readBuf, 0, readBufSz);
1134+
XMEMSET(readBuf, 0, (size_t)readBufSz);
11351135
start = gettime_secs(1);
11361136
#ifndef BENCH_USE_NONBLOCK
11371137
ret = wolfSSL_read(cli_ssl, readBuf, readBufSz);
@@ -1152,7 +1152,7 @@ static int bench_tls_client(info_t* info)
11521152
ret = 0; /* reset return code */
11531153

11541154
/* validate echo */
1155-
if (XMEMCMP((char*)writeBuf, (char*)readBuf, writeSz) != 0) {
1155+
if (XMEMCMP((char*)writeBuf, (char*)readBuf, (size_t)writeSz) != 0) {
11561156
fprintf(stderr, "echo check failed!\n");
11571157
ret = wolfSSL_get_error(cli_ssl, ret);
11581158
goto exit;
@@ -1169,7 +1169,7 @@ static int bench_tls_client(info_t* info)
11691169

11701170
if (ret != 0 && ret != WOLFSSL_SUCCESS) {
11711171
fprintf(stderr, "Client Error: %d (%s)\n", ret,
1172-
wolfSSL_ERR_reason_error_string(ret));
1172+
wolfSSL_ERR_reason_error_string((unsigned long)ret));
11731173
}
11741174

11751175
/* clean up */
@@ -1224,7 +1224,7 @@ static int SetupSocketAndListen(int* listenFd, word32 port, int doDTLS)
12241224
/* Setup server address */
12251225
XMEMSET(&servAddr, 0, sizeof(servAddr));
12261226
servAddr.sin_family = AF_INET;
1227-
servAddr.sin_port = htons(port);
1227+
servAddr.sin_port = htons((u_int16_t)port);
12281228
servAddr.sin_addr.s_addr = INADDR_ANY;
12291229

12301230
#ifdef WOLFSSL_DTLS
@@ -1440,7 +1440,7 @@ static int bench_tls_server(info_t* info)
14401440

14411441
/* Allocate read buffer */
14421442
readBufSz = info->packetSize;
1443-
readBuf = (unsigned char*)XMALLOC(readBufSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
1443+
readBuf = (unsigned char*)XMALLOC((size_t)readBufSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
14441444
if (readBuf == NULL) {
14451445
fprintf(stderr, "failed to allocate read memory\n");
14461446
ret = MEMORY_E; goto exit;
@@ -1538,7 +1538,7 @@ static int bench_tls_server(info_t* info)
15381538
double rxTime;
15391539

15401540
/* read message from client */
1541-
XMEMSET(readBuf, 0, readBufSz);
1541+
XMEMSET(readBuf, 0, (size_t)readBufSz);
15421542
start = gettime_secs(1);
15431543
#ifndef BENCH_USE_NONBLOCK
15441544
ret = wolfSSL_read(srv_ssl, readBuf, readBufSz);
@@ -1615,7 +1615,7 @@ static int bench_tls_server(info_t* info)
16151615

16161616
if (ret != 0 && ret != WOLFSSL_SUCCESS) {
16171617
fprintf(stderr, "Server Error: %d (%s)\n", ret,
1618-
wolfSSL_ERR_reason_error_string(ret));
1618+
wolfSSL_ERR_reason_error_string((unsigned long)ret));
16191619
}
16201620

16211621
/* clean up */
@@ -1834,7 +1834,7 @@ int bench_tls(void* args)
18341834
int argClientOnly = 0;
18351835
int argServerOnly = 0;
18361836
const char* argHost = BENCH_DEFAULT_HOST;
1837-
int argPort = BENCH_DEFAULT_PORT;
1837+
word32 argPort = BENCH_DEFAULT_PORT;
18381838
int argShowPeerInfo = 0;
18391839
#ifndef SINGLE_THREADED
18401840
int doShutdown;
@@ -1883,7 +1883,7 @@ int bench_tls(void* args)
18831883
break;
18841884

18851885
case 'P':
1886-
argPort = atoi(myoptarg);
1886+
argPort = (word32)atoi(myoptarg);
18871887
break;
18881888

18891889
case 'd' :
@@ -2003,12 +2003,12 @@ int bench_tls(void* args)
20032003
#endif
20042004

20052005
/* Allocate test info array */
2006-
theadInfo = (info_t*)XMALLOC(sizeof(info_t) * argThreadPairs, NULL,
2006+
theadInfo = (info_t*)XMALLOC(sizeof(info_t) * (size_t)argThreadPairs, NULL,
20072007
DYNAMIC_TYPE_TMP_BUFFER);
20082008
if (theadInfo == NULL) {
20092009
ret = MEMORY_E; goto exit;
20102010
}
2011-
XMEMSET(theadInfo, 0, sizeof(info_t) * argThreadPairs);
2011+
XMEMSET(theadInfo, 0, sizeof(info_t) * (size_t)argThreadPairs);
20122012

20132013
#ifndef NO_WOLFSSL_SERVER
20142014
/* Use same listen socket to avoid timing issues between client and server */
@@ -2073,7 +2073,7 @@ int bench_tls(void* args)
20732073
XMEMSET(info, 0, sizeof(info_t));
20742074

20752075
info->host = argHost;
2076-
info->port = argPort + i; /* threads must have separate ports */
2076+
info->port = argPort + (word32)i; /* threads must have separate ports */
20772077
info->cipher = cipher;
20782078

20792079
#if defined(WOLFSSL_TLS13) && defined(HAVE_SUPPORTED_CURVES)

0 commit comments

Comments
 (0)