Skip to content

Commit bf92797

Browse files
author
Andras Fekete
committed
Fix conversion error in client.c
1 parent 0bf69e2 commit bf92797

2 files changed

Lines changed: 26 additions & 26 deletions

File tree

examples/client/client.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ static void EarlyData(WOLFSSL_CTX* ctx, WOLFSSL* ssl, const char* msg,
461461
} while (err == WC_PENDING_E);
462462
if (ret != msgSz) {
463463
LOG_ERROR("SSL_write_early_data msg error %d, %s\n", err,
464-
wolfSSL_ERR_error_string(err, buffer));
464+
wolfSSL_ERR_error_string((unsigned long)err, buffer));
465465
wolfSSL_free(ssl); ssl = NULL;
466466
wolfSSL_CTX_free(ctx); ctx = NULL;
467467
err_sys("SSL_write_early_data failed");
@@ -683,8 +683,8 @@ static int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
683683
conn_time = current_time(0) - start;
684684

685685
/* Allocate TX/RX buffers */
686-
tx_buffer = (char*)XMALLOC(block, NULL, DYNAMIC_TYPE_TMP_BUFFER);
687-
rx_buffer = (char*)XMALLOC(block, NULL, DYNAMIC_TYPE_TMP_BUFFER);
686+
tx_buffer = (char*)XMALLOC((size_t)block, NULL, DYNAMIC_TYPE_TMP_BUFFER);
687+
rx_buffer = (char*)XMALLOC((size_t)block, NULL, DYNAMIC_TYPE_TMP_BUFFER);
688688
if (tx_buffer && rx_buffer) {
689689
WC_RNG rng;
690690

@@ -698,7 +698,7 @@ static int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
698698
size_t xfer_bytes;
699699

700700
/* Generate random data to send */
701-
ret = wc_RNG_GenerateBlock(&rng, (byte*)tx_buffer, block);
701+
ret = wc_RNG_GenerateBlock(&rng, (byte*)tx_buffer, (word32)block);
702702
wc_FreeRng(&rng);
703703
if(ret != 0) {
704704
err_sys("wc_RNG_GenerateBlock failed");
@@ -710,7 +710,7 @@ static int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
710710
int len, rx_pos, select_ret;
711711

712712
/* Determine packet size */
713-
len = min(block, (int)(throughput - xfer_bytes));
713+
len = (int)min((word32)block, (word32)(throughput - xfer_bytes));
714714

715715
/* Perform TX */
716716
start = current_time(1);
@@ -766,7 +766,7 @@ static int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
766766
}
767767

768768
/* Compare TX and RX buffers */
769-
if (XMEMCMP(tx_buffer, rx_buffer, len) != 0) {
769+
if (XMEMCMP(tx_buffer, rx_buffer, (size_t)len) != 0) {
770770
free(tx_buffer);
771771
tx_buffer = NULL;
772772
free(rx_buffer);
@@ -775,7 +775,7 @@ static int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
775775
}
776776

777777
/* Update overall position */
778-
xfer_bytes += len;
778+
xfer_bytes += (size_t)len;
779779
}
780780
}
781781
else {
@@ -815,8 +815,8 @@ static int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
815815
"\tRX %8.3f ms (%8.3f MBps)\n",
816816
(SIZE_TYPE)throughput,
817817
conn_time * 1000,
818-
tx_time * 1000, throughput / tx_time / 1024 / 1024,
819-
rx_time * 1000, throughput / rx_time / 1024 / 1024
818+
(double)tx_time * 1000, (double)throughput / tx_time / 1024 / 1024,
819+
(double)rx_time * 1000, (double)throughput / rx_time / 1024 / 1024
820820
);
821821

822822
return EXIT_SUCCESS;
@@ -852,7 +852,7 @@ static int StartTLS_Init(SOCKET_T* sockfd)
852852
}
853853

854854
/* C: EHLO mail.example.com */
855-
if (send(*sockfd, starttlsCmd[1], (int)XSTRLEN(starttlsCmd[1]), 0) !=
855+
if (send(*sockfd, starttlsCmd[1], XSTRLEN(starttlsCmd[1]), 0) !=
856856
(int)XSTRLEN(starttlsCmd[1]))
857857
err_sys("failed to send STARTTLS EHLO command\n");
858858

@@ -869,7 +869,7 @@ static int StartTLS_Init(SOCKET_T* sockfd)
869869
}
870870

871871
/* C: STARTTLS */
872-
if (send(*sockfd, starttlsCmd[3], (int)XSTRLEN(starttlsCmd[3]), 0) !=
872+
if (send(*sockfd, starttlsCmd[3], XSTRLEN(starttlsCmd[3]), 0) !=
873873
(int)XSTRLEN(starttlsCmd[3])) {
874874
err_sys("failed to send STARTTLS command\n");
875875
}
@@ -980,7 +980,7 @@ static int ClientWrite(WOLFSSL* ssl, const char* msg, int msgSz, const char* str
980980
if (ret != msgSz) {
981981
char buffer[WOLFSSL_MAX_ERROR_SZ];
982982
LOG_ERROR("SSL_write%s msg error %d, %s\n", str, err,
983-
wolfSSL_ERR_error_string(err, buffer));
983+
wolfSSL_ERR_error_string((unsigned long)err, buffer));
984984
if (!exitWithRet) {
985985
err_sys("SSL_write failed");
986986
}
@@ -1011,7 +1011,7 @@ static int ClientRead(WOLFSSL* ssl, char* reply, int replyLen, int mustRead,
10111011
if (err != WOLFSSL_ERROR_WANT_READ &&
10121012
err != WOLFSSL_ERROR_WANT_WRITE && err != APP_DATA_READY) {
10131013
LOG_ERROR("SSL_read reply error %d, %s\n", err,
1014-
wolfSSL_ERR_error_string(err, buffer));
1014+
wolfSSL_ERR_error_string((unsigned long)err, buffer));
10151015
if (!exitWithRet) {
10161016
err_sys("SSL_read failed");
10171017
}
@@ -1090,7 +1090,7 @@ static int ClientWriteRead(WOLFSSL* ssl, const char* msg, int msgSz,
10901090
if (ret != 0) {
10911091
char buffer[WOLFSSL_MAX_ERROR_SZ];
10921092
LOG_ERROR("SSL_write%s msg error %d, %s\n", str, ret,
1093-
wolfSSL_ERR_error_string(ret, buffer));
1093+
wolfSSL_ERR_error_string((unsigned long)ret, buffer));
10941094
}
10951095

10961096
return ret;
@@ -2426,7 +2426,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
24262426
break;
24272427

24282428
case 'B' :
2429-
throughput = atol(myoptarg);
2429+
throughput = (size_t)atol(myoptarg);
24302430
for (; *myoptarg != '\0'; myoptarg++) {
24312431
if (*myoptarg == ',') {
24322432
block = atoi(myoptarg + 1);
@@ -2489,7 +2489,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
24892489

24902490
case 'F' :
24912491
#ifdef HAVE_MAX_FRAGMENT
2492-
maxFragment = atoi(myoptarg);
2492+
maxFragment = (byte)atoi(myoptarg);
24932493
if (maxFragment < WOLFSSL_MFL_MIN ||
24942494
maxFragment > WOLFSSL_MFL_MAX) {
24952495
Usage();
@@ -2516,7 +2516,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
25162516
{
25172517
word32 myoptargSz;
25182518

2519-
statusRequest = atoi(myoptarg);
2519+
statusRequest = (byte)atoi(myoptarg);
25202520
if (statusRequest > OCSP_STAPLING_OPT_MAX) {
25212521
Usage();
25222522
XEXIT_T(MY_EX_USAGE);
@@ -3929,7 +3929,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
39293929
if (ret != WOLFSSL_SUCCESS) {
39303930
err = wolfSSL_get_error(ssl, 0);
39313931
LOG_ERROR("wolfSSL_connect error %d, %s\n", err,
3932-
wolfSSL_ERR_error_string(err, buffer));
3932+
wolfSSL_ERR_error_string((unsigned long)err, buffer));
39333933

39343934
/* cleanup */
39353935
wolfSSL_free(ssl); ssl = NULL;
@@ -4270,11 +4270,11 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
42704270
printf("SSL connect ok, sending GET...\n");
42714271

42724272
msgSz = (int)XSTRLEN(kHttpGetMsg);
4273-
XMEMCPY(msg, kHttpGetMsg, msgSz);
4273+
XMEMCPY(msg, kHttpGetMsg, (size_t)msgSz);
42744274
}
42754275
else {
42764276
msgSz = (int)XSTRLEN(kHelloMsg);
4277-
XMEMCPY(msg, kHelloMsg, msgSz);
4277+
XMEMCPY(msg, kHelloMsg, (size_t)msgSz);
42784278
}
42794279

42804280
/* allow some time for exporting the session */
@@ -4521,7 +4521,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
45214521
#endif
45224522
if (ret != WOLFSSL_SUCCESS) {
45234523
LOG_ERROR("wolfSSL_connect resume error %d, %s\n", err,
4524-
wolfSSL_ERR_error_string(err, buffer));
4524+
wolfSSL_ERR_error_string((unsigned long)err, buffer));
45254525
wolfSSL_free(sslResume); sslResume = NULL;
45264526
CloseSocket(sockfd);
45274527
wolfSSL_CTX_free(ctx); ctx = NULL;
@@ -4602,11 +4602,11 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
46024602
XMEMSET(msg, 0, sizeof(msg));
46034603
if (sendGET) {
46044604
msgSz = (int)XSTRLEN(kHttpGetMsg);
4605-
XMEMCPY(msg, kHttpGetMsg, msgSz);
4605+
XMEMCPY(msg, kHttpGetMsg, (size_t)msgSz);
46064606
}
46074607
else {
46084608
msgSz = (int)XSTRLEN(kResumeMsg);
4609-
XMEMCPY(msg, kResumeMsg, msgSz);
4609+
XMEMCPY(msg, kResumeMsg, (size_t)msgSz);
46104610
}
46114611

46124612
(void)ClientWriteRead(sslResume, msg, msgSz, reply, sizeof(reply)-1,

examples/server/server.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ int ServerEchoData(SSL* ssl, int clientfd, int echoData, int block,
420420
size_t xfer_bytes = 0;
421421
char* buffer;
422422

423-
buffer = (char*)malloc(block);
423+
buffer = (char*)malloc((size_t)block);
424424
if (!buffer) {
425425
err_sys_ex(runWithErrors, "Server buffer malloc failed");
426426
}
@@ -520,8 +520,8 @@ int ServerEchoData(SSL* ssl, int clientfd, int echoData, int block,
520520
"\tRX %8.3f ms (%8.3f MBps)\n"
521521
"\tTX %8.3f ms (%8.3f MBps)\n",
522522
(SIZE_TYPE)throughput,
523-
(double)rx_time * 1000, throughput / rx_time / 1024 / 1024,
524-
(double)tx_time * 1000, throughput / tx_time / 1024 / 1024
523+
(double)rx_time * 1000, (double)throughput / rx_time / 1024 / 1024,
524+
(double)tx_time * 1000, (double)throughput / tx_time / 1024 / 1024
525525
);
526526
}
527527
else {

0 commit comments

Comments
 (0)