From a3194c43beea2a9881fc3578908b9397f9ab9ab2 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Fri, 29 Sep 2023 08:47:02 +0700 Subject: [PATCH] Fix build errors & warnings on MSVC2005 --- pjlib/src/pj/string.c | 4 ++-- pjlib/src/pjlib-test/sleep.c | 6 +++--- pjmedia/src/pjmedia/codec.c | 7 ++++--- pjmedia/src/pjmedia/sdp_neg.c | 16 +++++++++------- pjmedia/src/pjmedia/stream.c | 4 ++-- pjmedia/src/pjmedia/vid_codec.c | 7 ++++--- pjmedia/src/test/mips_test.c | 9 ++++++--- pjsip-apps/src/pjsua/pjsua_app_cli.c | 4 ++-- pjsip-apps/src/pjsua/pjsua_app_legacy.c | 2 +- pjsip/src/pjsip/sip_transport_tls.c | 9 ++++++--- pjsip/src/pjsua2/media.cpp | 4 ++-- 11 files changed, 41 insertions(+), 31 deletions(-) diff --git a/pjlib/src/pj/string.c b/pjlib/src/pj/string.c index 23796a0b54..1e9785c1f1 100644 --- a/pjlib/src/pj/string.c +++ b/pjlib/src/pj/string.c @@ -259,7 +259,7 @@ PJ_DEF(long) pj_strtol(const pj_str_t *str) uval = pj_strtoul(str); if (is_negative) - val = uval > PJ_MAXLONG ? PJ_MINLONG : -uval; + val = uval > PJ_MAXLONG ? PJ_MINLONG : -(long)uval; else val = uval > PJ_MAXLONG ? PJ_MAXLONG : uval; @@ -310,7 +310,7 @@ PJ_DEF(pj_status_t) pj_strtol2(const pj_str_t *str, long *value) return PJ_ETOOSMALL; } - *value = is_negative ? -retval : retval; + *value = is_negative ? -(long)retval : retval; return PJ_SUCCESS; } diff --git a/pjlib/src/pjlib-test/sleep.c b/pjlib/src/pjlib-test/sleep.c index 59023f11b7..e8edb134ae 100644 --- a/pjlib/src/pjlib-test/sleep.c +++ b/pjlib/src/pjlib-test/sleep.c @@ -93,7 +93,7 @@ static int simple_sleep_test(void) static int sleep_duration_test(void) { const unsigned MAX_SLIP = param_ci_mode? 200 : 20; - unsigned duration[] = { 2000, 1000, 500, 200, 100 }; + long duration[] = { 2000, 1000, 500, 200, 100 }; unsigned i; unsigned avg_diff, max_diff; pj_status_t rc; @@ -103,7 +103,7 @@ static int sleep_duration_test(void) /* Test pj_thread_sleep() and pj_gettimeofday() */ for (i=0, avg_diff=0, max_diff=0; icodec_desc[i].id); - codec_idx = pjmedia_codec_mgr_find_codec(mgr->dyn_codecs, + codec_idx = (pj_int8_t)pjmedia_codec_mgr_find_codec( + mgr->dyn_codecs, mgr->dyn_codecs_cnt, &codec_str, &found); @@ -815,8 +816,8 @@ pj_status_t pjmedia_codec_mgr_get_dyn_codecs(pjmedia_codec_mgr* mgr, pj_mutex_lock(mgr->mutex); - if (mgr->dyn_codecs_cnt < *count) - *count = mgr->dyn_codecs_cnt; + if (mgr->dyn_codecs_cnt < (unsigned)*count) + *count = (pj_int8_t)mgr->dyn_codecs_cnt; pj_memcpy(dyn_codecs, mgr->dyn_codecs, *count * sizeof(pj_str_t)); diff --git a/pjmedia/src/pjmedia/sdp_neg.c b/pjmedia/src/pjmedia/sdp_neg.c index e306c4cdc1..ee66f5a42f 100644 --- a/pjmedia/src/pjmedia/sdp_neg.c +++ b/pjmedia/src/pjmedia/sdp_neg.c @@ -1705,6 +1705,8 @@ static pj_status_t assign_pt_and_update_map(pj_pool_t *pool, { unsigned i, j; + PJ_UNUSED_ARG(pool); + for (i = 0; i < sess->media_count; ++i) { pjmedia_type med_type; unsigned count; @@ -1785,8 +1787,8 @@ static pj_status_t assign_pt_and_update_map(pj_pool_t *pool, codec = rtpmap.enc_name; } - codec_idx = pjmedia_codec_mgr_find_codec(dyn_codecs, count, - &codec, NULL); + codec_idx = (pj_int8_t)pjmedia_codec_mgr_find_codec(dyn_codecs, + count, &codec, NULL); if (codec_idx < 0) { /* This typically happens when remote offers unknown * codec. @@ -1798,7 +1800,7 @@ static pj_status_t assign_pt_and_update_map(pj_pool_t *pool, /* Update the mapping. */ neg->pt_to_codec[i][pt - START_DYNAMIC_PT] = codec_idx; if (codec_idx != UNKNOWN_CODEC) - neg->codec_to_pt[i][codec_idx] = pt; + neg->codec_to_pt[i][codec_idx] = (pj_int8_t)pt; continue; } @@ -1841,15 +1843,15 @@ static pj_status_t assign_pt_and_update_map(pj_pool_t *pool, * find the first unused one. */ if (need_new_pt && new_pt == 0) { - new_pt = find_new_pt(&neg->pt_to_codec[i], pt_used, - &codec, codec_idx); + new_pt = (pj_int8_t)find_new_pt(&neg->pt_to_codec[i], pt_used, + &codec, codec_idx); } - if (new_pt != 0 && new_pt != pt) { + if (new_pt != 0 && new_pt != (pj_int8_t)pt) { rewrite_pt2(neg->pool_active, (pj_str_t *)&attr->value, pt, new_pt); } else { - new_pt = pt; + new_pt = (pj_int8_t)pt; } /* Mark the PT number as used and keep track of the change diff --git a/pjmedia/src/pjmedia/stream.c b/pjmedia/src/pjmedia/stream.c index 6f8f5e1823..ce4df6b292 100644 --- a/pjmedia/src/pjmedia/stream.c +++ b/pjmedia/src/pjmedia/stream.c @@ -2656,14 +2656,14 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt, ptime = afd->frame_time_usec; - if (stream->codec_param.info.enc_ptime * 1000 > + if (stream->codec_param.info.enc_ptime * (unsigned)1000 > ptime * stream->codec_param.info.enc_ptime_denum) { ptime = stream->codec_param.info.enc_ptime * 1000 / stream->codec_param.info.enc_ptime_denum; } - if (stream->codec_param.info.frm_ptime * 1000 > + if (stream->codec_param.info.frm_ptime * (unsigned)1000 > ptime * stream->codec_param.info.frm_ptime_denum) { ptime = stream->codec_param.info.frm_ptime * 1000 / diff --git a/pjmedia/src/pjmedia/vid_codec.c b/pjmedia/src/pjmedia/vid_codec.c index 2ced646c04..da08385b4b 100644 --- a/pjmedia/src/pjmedia/vid_codec.c +++ b/pjmedia/src/pjmedia/vid_codec.c @@ -299,7 +299,8 @@ PJ_DEF(pj_status_t) pjmedia_vid_codec_mgr_unregister_factory( pj_bool_t found; pj_str_t codec_str = pj_str(mgr->codec_desc[i].id); - codec_idx = pjmedia_codec_mgr_find_codec(mgr->dyn_codecs, + codec_idx = (pj_int8_t)pjmedia_codec_mgr_find_codec( + mgr->dyn_codecs, mgr->dyn_codecs_cnt, &codec_str, &found); @@ -823,8 +824,8 @@ pj_status_t pjmedia_vid_codec_mgr_get_dyn_codecs(pjmedia_vid_codec_mgr* mgr, pj_mutex_lock(mgr->mutex); - if (mgr->dyn_codecs_cnt < *count) - *count = mgr->dyn_codecs_cnt; + if (mgr->dyn_codecs_cnt < (unsigned)*count) + *count = (pj_int8_t)mgr->dyn_codecs_cnt; pj_memcpy(dyn_codecs, mgr->dyn_codecs, *count * sizeof(pj_str_t)); diff --git a/pjmedia/src/test/mips_test.c b/pjmedia/src/test/mips_test.c index 212b2c8713..d1518fc41d 100644 --- a/pjmedia/src/test/mips_test.c +++ b/pjmedia/src/test/mips_test.c @@ -1717,9 +1717,6 @@ static pjmedia_port* create_stream( pj_pool_t *pool, unsigned flags, struct test_entry *te) { - PJ_UNUSED_ARG(srtp_enabled); - PJ_UNUSED_ARG(srtp_80); - PJ_UNUSED_ARG(srtp_auth); struct stream_port *sp; pj_str_t codec_id; pjmedia_port *port; @@ -1729,6 +1726,12 @@ static pjmedia_port* create_stream( pj_pool_t *pool, pjmedia_stream_info si; pj_status_t status; +#if !PJMEDIA_HAS_SRTP + PJ_UNUSED_ARG(srtp_enabled); + PJ_UNUSED_ARG(srtp_80); + PJ_UNUSED_ARG(srtp_auth); +#endif + PJ_UNUSED_ARG(flags); codec_id = pj_str((char*)codec); diff --git a/pjsip-apps/src/pjsua/pjsua_app_cli.c b/pjsip-apps/src/pjsua/pjsua_app_cli.c index e2d1ad27dd..bf2237eda6 100644 --- a/pjsip-apps/src/pjsua/pjsua_app_cli.c +++ b/pjsip-apps/src/pjsua/pjsua_app_cli.c @@ -629,7 +629,7 @@ static void get_video_codec_id(pj_cli_dyn_choice_param *param) pjsua_vid_enum_codecs(ci, &count); for (i = 0; i <= count; ++i) { pjmedia_vid_codec_param cp; - pjmedia_video_format_detail *vfd; + pjmedia_video_format_detail *vfd = NULL; pj_status_t status = PJ_SUCCESS; pj_str_t cur_ci; @@ -1519,7 +1519,7 @@ static pj_status_t cmd_make_single_call(pj_cli_cmd_val *cval) loop = PJ_TRUE; result.nb_result = 1; } - if (result.nb_result > pjsua_get_buddy_count()) break; + if (result.nb_result > (int)pjsua_get_buddy_count()) break; if (result.nb_result == 0) { const pj_str_t err_msg = diff --git a/pjsip-apps/src/pjsua/pjsua_app_legacy.c b/pjsip-apps/src/pjsua/pjsua_app_legacy.c index 0b62c4ccf6..0559827007 100644 --- a/pjsip-apps/src/pjsua/pjsua_app_legacy.c +++ b/pjsip-apps/src/pjsua/pjsua_app_legacy.c @@ -712,7 +712,7 @@ static void ui_make_new_call() loop = PJ_TRUE; result.nb_result = 1; } - if (result.nb_result > pjsua_get_buddy_count()) break; + if (result.nb_result > (int)pjsua_get_buddy_count()) break; if (result.nb_result == 0) { puts("You can't do that with make call!"); diff --git a/pjsip/src/pjsip/sip_transport_tls.c b/pjsip/src/pjsip/sip_transport_tls.c index a84b76ab3b..fd213eff52 100644 --- a/pjsip/src/pjsip/sip_transport_tls.c +++ b/pjsip/src/pjsip/sip_transport_tls.c @@ -378,18 +378,21 @@ static pj_status_t update_factory_addr(struct tls_listener *listener, if (addr_name && addr_name->host.slen) { pj_sockaddr tmp; - int af = pjsip_transport_type_get_af(listener->factory.type); + pj_uint16_t af = (pj_uint16_t) + pjsip_transport_type_get_af(listener->factory.type); tmp.addr.sa_family = af; /* Validate IP address only */ - if (pj_inet_pton(af, &addr_name->host, pj_sockaddr_get_addr(&tmp)) == PJ_SUCCESS) + if (pj_inet_pton(af, &addr_name->host, pj_sockaddr_get_addr(&tmp)) == + PJ_SUCCESS) { /* Verify that address given in a_name (if any) is valid */ status = pj_sockaddr_init(af, &tmp, &addr_name->host, (pj_uint16_t)addr_name->port); if (status != PJ_SUCCESS || !pj_sockaddr_has_addr(&tmp) || - (af == pj_AF_INET() && tmp.ipv4.sin_addr.s_addr == PJ_INADDR_NONE)) + (af == pj_AF_INET() && + tmp.ipv4.sin_addr.s_addr == PJ_INADDR_NONE)) { /* Invalid address */ return PJ_EINVAL; diff --git a/pjsip/src/pjsua2/media.cpp b/pjsip/src/pjsua2/media.cpp index 9f25e1a767..f83d122e79 100644 --- a/pjsip/src/pjsua2/media.cpp +++ b/pjsip/src/pjsua2/media.cpp @@ -1945,9 +1945,9 @@ pjmedia_codec_param CodecParam::toPj() const param.info.max_bps= (pj_uint32_t)info.maxBps; param.info.max_rx_frame_size = info.maxRxFrameSize; param.info.frm_ptime = (pj_uint16_t)info.frameLen; - param.info.frm_ptime_denum = (pj_uint16_t)info.frameLenDenum; + param.info.frm_ptime_denum = (pj_uint8_t)info.frameLenDenum; param.info.enc_ptime = (pj_uint16_t)info.encFrameLen; - param.info.enc_ptime_denum = (pj_uint16_t)info.encFrameLenDenum; + param.info.enc_ptime_denum = (pj_uint8_t)info.encFrameLenDenum; param.info.pcm_bits_per_sample = (pj_uint8_t)info.pcmBitsPerSample; param.info.pt = (pj_uint8_t)info.pt; param.info.fmt_id = info.fmtId;