Skip to content

Commit

Permalink
cast type based on Windows API status
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruby Martin committed Jan 22, 2025
1 parent 04d342e commit 88bddb8
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tests/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,11 @@ int test_memio_setup(struct test_memio_ctx *ctx,
}
#endif

#ifdef USE_WINDOWS_API
#define MESSAGE_TYPE_CAST char*
#else
#define MESSAGE_TYPE_CAST void*

/*----------------------------------------------------------------------------*
| BIO with fixed read/write size
*----------------------------------------------------------------------------*/
Expand Down Expand Up @@ -8389,7 +8394,7 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_loop(void* args)
if (!sharedCtx)
wolfSSL_CTX_free(ctx);

if (clientfd >= 0)
if (clientfd != SOCKET_INVALID)
CloseSocket(clientfd);

#ifdef WOLFSSL_TIRTOS
Expand Down Expand Up @@ -76214,7 +76219,7 @@ static int test_wolfSSL_TXT_DB(void)

/* Test index */
ExpectIntEQ(TXT_DB_create_index(db, 3, NULL,
(wolf_sk_hash_cb)(long unsigned int)TXT_DB_hash,
(wolf_sk_hash_cb)TXT_DB_hash,
(wolf_lh_compare_cb)TXT_DB_cmp), 1);
ExpectNotNull(TXT_DB_get_by_index(db, 3, (WOLFSSL_STRING*)fields));
fields[3] = "12DA";
Expand Down Expand Up @@ -90343,7 +90348,7 @@ static void test_wolfSSL_dtls_plaintext_client(WOLFSSL* ssl)
AssertIntGE(fd, 0);
generateDTLSMsg(ch, sizeof(ch), 20, client_hello, 0);
/* Server should ignore this datagram */
AssertIntEQ(send(fd, ch, sizeof(ch), 0), sizeof(ch));
AssertIntEQ(send(fd, (MESSAGE_TYPE_CAST)ch, sizeof(ch), 0), sizeof(ch));
generateDTLSMsg(ch, sizeof(ch), 20, client_hello, 10000);
/* Server should ignore this datagram */
AssertIntEQ(send(fd, ch, sizeof(ch), 0), sizeof(ch));
Expand Down Expand Up @@ -90457,7 +90462,7 @@ static void test_wolfSSL_dtls12_fragments_spammer(WOLFSSL* ssl)
delay.tv_nsec = 10000000; /* wait 0.01 seconds */
c32toa(seq_number, b + seq_offset);
c16toa(msg_number, b + msg_offset);
ret = (int)send(fd, b, 55, 0);
ret = (int)send(fd, (MESSAGE_TYPE_CAST)b, 55, 0);
nanosleep(&delay, NULL);
}
}
Expand Down Expand Up @@ -90576,7 +90581,7 @@ static void test_wolfSSL_dtls_send_alert(WOLFSSL* ssl)

fd = wolfSSL_get_wfd(ssl);
AssertIntGE(fd, 0);
ret = (int)send(fd, alert_msg, sizeof(alert_msg), 0);
ret = (int)send(fd, (MESSAGE_TYPE_CAST)alert_msg, sizeof(alert_msg), 0);
AssertIntGT(ret, 0);
}

Expand Down Expand Up @@ -90647,7 +90652,7 @@ static void test_wolfSSL_send_bad_record(WOLFSSL* ssl)

fd = wolfSSL_get_wfd(ssl);
AssertIntGE(fd, 0);
ret = (int)send(fd, bad_msg, sizeof(bad_msg), 0);
ret = (int)send(fd, (MESSAGE_TYPE_CAST)bad_msg, sizeof(bad_msg), 0);
AssertIntEQ(ret, sizeof(bad_msg));
ret = wolfSSL_write(ssl, "badrecordtest", sizeof("badrecordtest"));
AssertIntEQ(ret, sizeof("badrecordtest"));
Expand Down Expand Up @@ -90974,10 +90979,10 @@ static void test_wolfSSL_dtls_send_ch(WOLFSSL* ssl)

fd = wolfSSL_get_wfd(ssl);
AssertIntGE(fd, 0);
ret = (int)send(fd, ch_msg, sizeof(ch_msg), 0);
ret = (int)send(fd, (MESSAGE_TYPE_CAST)ch_msg, sizeof(ch_msg), 0);
AssertIntGT(ret, 0);
/* consume the HRR otherwise handshake will fail */
ret = (int)recv(fd, ch_msg, sizeof(ch_msg), 0);
ret = (int)recv(fd, (MESSAGE_TYPE_CAST)ch_msg, sizeof(ch_msg), 0);
AssertIntGT(ret, 0);
}

Expand Down

0 comments on commit 88bddb8

Please sign in to comment.