Skip to content

Commit 5410a92

Browse files
authored
Fix compile warnings on VS2022 (#4673)
1 parent e69191e commit 5410a92

File tree

20 files changed

+76
-49
lines changed

20 files changed

+76
-49
lines changed

pjlib/src/pj/os_core_win32.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,8 @@ static void set_thread_display_name(const char *name)
551551
if (pSetThreadDescription) {
552552
wchar_t wname[PJ_MAX_OBJ_NAME];
553553
HRESULT hr;
554-
pj_ansi_to_unicode(name, pj_ansi_strlen(name), wname, PJ_MAX_OBJ_NAME);
554+
pj_ansi_to_unicode(name, (int)pj_ansi_strlen(name), wname,
555+
PJ_MAX_OBJ_NAME);
555556

556557
/* Set thread name by SetThreadDescription (if support) */
557558
hr = pSetThreadDescription(GetCurrentThread(), wname);
@@ -732,7 +733,7 @@ static pj_status_t create_thread(const char *thread_name,
732733

733734
#ifdef _MSC_VER
734735
rec->idthread = 0;
735-
rec->hthread = (HANDLE)_beginthreadex(NULL, stack_size,
736+
rec->hthread = (HANDLE)_beginthreadex(NULL, (unsigned)stack_size,
736737
thread_main, rec,
737738
dwflags, (unsigned*)&rec->idthread);
738739
#elif defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8

pjlib/src/pj/ssl_sock_ossl.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ static pj_status_t init_openssl(void)
785785
#if !USING_LIBRESSL && !defined(OPENSSL_NO_EC) \
786786
&& OPENSSL_VERSION_NUMBER >= 0x1000200fL
787787
#if OPENSSL_VERSION_NUMBER >= 0x1010100fL
788-
ssl_curves_num = EC_get_builtin_curves(NULL, 0);
788+
ssl_curves_num = (unsigned)EC_get_builtin_curves(NULL, 0);
789789
#else
790790

791791
#if USING_BORINGSSL
@@ -1076,7 +1076,13 @@ static int xname_cmp(const X509_NAME **a, const X509_NAME **b) {
10761076
#if !defined(OPENSSL_NO_DH)
10771077

10781078
static void set_option(const pj_ssl_sock_t* ssock, SSL_CTX* ctx) {
1079-
unsigned long options = SSL_OP_CIPHER_SERVER_PREFERENCE |
1079+
#if OPENSSL_VERSION_NUMBER >= 0x30000000L && PJ_HAS_INT64
1080+
uint64_t options;
1081+
#else
1082+
unsigned long options;
1083+
#endif
1084+
1085+
options = SSL_OP_CIPHER_SERVER_PREFERENCE |
10801086
#if !defined(OPENSSL_NO_ECDH) && OPENSSL_VERSION_NUMBER >= 0x10000000L
10811087
SSL_OP_SINGLE_ECDH_USE |
10821088
#endif
@@ -1343,7 +1349,7 @@ static pj_status_t init_ossl_ctx(pj_ssl_sock_t *ssock)
13431349
X509 *xcert = NULL;
13441350

13451351
cbio = BIO_new_mem_buf((void*)cert->cert_buf.ptr,
1346-
cert->cert_buf.slen);
1352+
(int)cert->cert_buf.slen);
13471353
if (cbio != NULL) {
13481354
xcert = PEM_read_bio_X509(cbio, NULL, 0, NULL);
13491355
if (xcert != NULL) {
@@ -1370,7 +1376,7 @@ static pj_status_t init_ossl_ctx(pj_ssl_sock_t *ssock)
13701376

13711377
if (cert->CA_buf.slen && !CA_loaded) {
13721378
BIO *cbio = BIO_new_mem_buf((void*)cert->CA_buf.ptr,
1373-
cert->CA_buf.slen);
1379+
(int)cert->CA_buf.slen);
13741380
X509_STORE *cts = SSL_CTX_get_cert_store(ctx);
13751381

13761382
if (cbio && cts) {
@@ -1413,7 +1419,7 @@ static pj_status_t init_ossl_ctx(pj_ssl_sock_t *ssock)
14131419
EVP_PKEY *pkey = NULL;
14141420

14151421
kbio = BIO_new_mem_buf((void*)cert->privkey_buf.ptr,
1416-
cert->privkey_buf.slen);
1422+
(int)cert->privkey_buf.slen);
14171423
if (kbio != NULL) {
14181424
pkey = PEM_read_bio_PrivateKey(kbio, NULL, &password_cb,
14191425
cert);
@@ -1581,7 +1587,7 @@ static pj_status_t init_ossl_ctx(pj_ssl_sock_t *ssock)
15811587
X509_NAME *xn = NULL;
15821588
STACK_OF(X509_NAME) *sk = NULL;
15831589
BIO *new_bio = BIO_new_mem_buf((void*)cert->CA_buf.ptr,
1584-
cert->CA_buf.slen);
1590+
(int)cert->CA_buf.slen);
15851591

15861592
sk = sk_X509_NAME_new(xname_cmp);
15871593

@@ -2586,7 +2592,7 @@ static pj_status_t ssl_write(pj_ssl_sock_t *ssock, const void *data,
25862592
} else {
25872593
/* Some problem occurred */
25882594
status = STATUS_FROM_SSL_ERR2("Write", ssock, *nwritten,
2589-
err, size);
2595+
err, (int)size);
25902596
}
25912597
} else if (*nwritten < size) {
25922598
/* nwritten < size, shouldn't happen, unless write BIO cannot hold

pjlib/src/pjlib-test/atomic_slist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ static int worker_thread(void* p) {
336336
break;
337337
});
338338
slot->owner = pj_thread_this(); /* slot reserved successfully */
339-
slot_id = slot - test->state.slots;
339+
slot_id = (unsigned)(slot - test->state.slots);
340340
reserved_slots[reserved_count++] = slot_id;
341341
++n_events;
342342
}

pjlib/src/pjlib-test/pool.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ static int pool_alignment_test(void)
131131
ptr = pj_pool_aligned_alloc(pool, alignment, 0);
132132
pj_ansi_snprintf(msg, sizeof(msg),
133133
"alignment=%ld, capacity=%lu, block->buf=%p, ptr==block->cur=%p, block->end=%p",
134-
alignment, capacity, pool->block_list.next->buf,pool->block_list.next->cur,pool->block_list.next->end);
134+
(long)alignment, (unsigned long)capacity, pool->block_list.next->buf,
135+
pool->block_list.next->cur,pool->block_list.next->end);
135136
PJ_TEST_EQ(ptr, NULL, msg, { rc=-304; goto on_return; });
136137

137138
pj_pool_release(pool);

pjmedia/src/pjmedia-codec/vpx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ static pj_status_t vpx_codec_encode_begin(pjmedia_vid_codec *codec,
600600
if (pkt->kind == VPX_CODEC_CX_FRAME_PKT) {
601601
/* We have a valid frame packet */
602602
vpx_data->enc_frame_whole = pkt->data.frame.buf;
603-
vpx_data->enc_frame_size = pkt->data.frame.sz;
603+
vpx_data->enc_frame_size = (unsigned)pkt->data.frame.sz;
604604
vpx_data->enc_processed = 0;
605605
if (pkt->data.frame.flags & VPX_FRAME_IS_KEY)
606606
vpx_data->enc_frame_is_keyframe = PJ_TRUE;
@@ -686,7 +686,7 @@ static pj_status_t vpx_codec_encode_more(pjmedia_vid_codec *codec,
686686
if (vpx_data->enc_frame_is_keyframe) {
687687
output->bit_info |= PJMEDIA_VID_FRM_KEYFRAME;
688688
}
689-
vpx_data->enc_processed += payload_len;
689+
vpx_data->enc_processed += (unsigned)payload_len;
690690
*has_more = (vpx_data->enc_processed < vpx_data->enc_frame_size);
691691
}
692692

@@ -728,13 +728,13 @@ static pj_status_t vpx_codec_decode_(pjmedia_vid_codec *codec,
728728
pj_memcpy( vpx_data->dec_buf + whole_len,
729729
(pj_uint8_t*)packets[i].buf,
730730
packets[i].size);
731-
whole_len += packets[i].size;
731+
whole_len += (unsigned)packets[i].size;
732732
}
733733

734734
} else {
735735
for (i = 0; i < count; ++i) {
736736
unsigned desc_len;
737-
unsigned packet_size = packets[i].size;
737+
unsigned packet_size = (unsigned)packets[i].size;
738738
pj_status_t status;
739739

740740
status = pjmedia_vpx_unpacketize(vpx_data->pktz, packets[i].buf,

pjmedia/src/pjmedia/conf_thread.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ static SLOT_TYPE conf_reserve_port(pjmedia_conf *conf)
15221522
if (!pslot)
15231523
return INVALID_SLOT;
15241524

1525-
SLOT_TYPE slot = pslot - conf->free_port_slots;
1525+
SLOT_TYPE slot = (SLOT_TYPE)(pslot - conf->free_port_slots);
15261526
pj_assert( slot < conf->max_ports && conf->ports[slot] == NULL );
15271527
return slot;
15281528
}

pjmedia/src/pjmedia/txt_stream.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ pjmedia_txt_stream_send_text(pjmedia_txt_stream *stream, const pj_str_t *text)
879879
pj_memcpy(stream->tx_buf[stream->tx_buf_idx].buf +
880880
stream->tx_buf[stream->tx_buf_idx].length,
881881
text->ptr, text->slen);
882-
stream->tx_buf[stream->tx_buf_idx].length += text->slen;
882+
stream->tx_buf[stream->tx_buf_idx].length += (unsigned)text->slen;
883883

884884
/* Decide if we should send the text immediately or just buffer it. */
885885
pj_get_timestamp(&now);

pjnath/src/pjnath-test/ice_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ static int perform_test(const char *title,
905905

906906
int ice_test(void *p)
907907
{
908-
unsigned test_id = (unsigned)(long)p;
908+
unsigned test_id = (unsigned)(uintptr_t)p;
909909
app_sess_t app_sess;
910910
unsigned i;
911911
int rc;

pjnath/src/pjnath-test/test.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,17 +240,17 @@ static int test_inner(int argc, char *argv[])
240240

241241
#if INCLUDE_ICE_TEST
242242
for (i=0; i<ICE_TEST_START_ARRAY+ICE_TEST_ARRAY_COUNT; ++i)
243-
UT_ADD_TEST1(&test_app.ut_app, ice_test, (void*)(long)i, 0);
243+
UT_ADD_TEST1(&test_app.ut_app, ice_test, (void*)(intptr_t)i, 0);
244244
#endif
245245

246246
#if INCLUDE_TRICKLE_ICE_TEST
247247
UT_ADD_TEST(&test_app.ut_app, trickle_ice_test, 0);
248248
#endif
249249

250250
#if INCLUDE_TURN_SOCK_TEST
251-
UT_ADD_TEST1(&test_app.ut_app, turn_sock_test, (void*)(long)0, 0);
252-
UT_ADD_TEST1(&test_app.ut_app, turn_sock_test, (void*)(long)1, 0);
253-
UT_ADD_TEST1(&test_app.ut_app, turn_sock_test, (void*)(long)2, 0);
251+
UT_ADD_TEST1(&test_app.ut_app, turn_sock_test, (void*)(intptr_t)0, 0);
252+
UT_ADD_TEST1(&test_app.ut_app, turn_sock_test, (void*)(intptr_t)1, 0);
253+
UT_ADD_TEST1(&test_app.ut_app, turn_sock_test, (void*)(intptr_t)2, 0);
254254
#endif
255255

256256
#if INCLUDE_CONCUR_TEST

pjnath/src/pjnath-test/turn_sock_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ static int destroy_test(pj_stun_config *stun_cfg,
536536

537537
int turn_sock_test(void *p)
538538
{
539-
unsigned n = (int)(long)p;
539+
unsigned n = (int)(intptr_t)p;
540540
app_sess_t app_sess;
541541
pj_turn_tp_type tp_type = PJ_TURN_TP_UDP;
542542
int i, rc = 0;

0 commit comments

Comments
 (0)