Skip to content

Commit

Permalink
Fix various compile errors & warnings in MSVC2005 (#4268)
Browse files Browse the repository at this point in the history
  • Loading branch information
nanangizz authored Jan 24, 2025
1 parent de3f2e1 commit 377a80c
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 32 deletions.
2 changes: 1 addition & 1 deletion pjlib-util/src/pjlib-util-test/resolver_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ static int simple_test(void)
NULL, return -300);

pj_sem_wait(sem);
pj_thread_sleep(set.qretr_delay * 1.2);
pj_thread_sleep((unsigned)(set.qretr_delay * 1.2));


/* Both servers must get packet */
Expand Down
6 changes: 4 additions & 2 deletions pjlib-util/src/pjlib-util-test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@

pj_pool_factory *mem;
struct test_app_t test_app = {
.param_log_decor = PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_TIME |
PJ_LOG_HAS_MICRO_SEC | PJ_LOG_HAS_INDENT,
{0}, /* ut_app */
PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_TIME |
PJ_LOG_HAS_MICRO_SEC | PJ_LOG_HAS_INDENT,
/* param_log_decor */
};

void app_perror(const char *msg, pj_status_t rc)
Expand Down
2 changes: 2 additions & 0 deletions pjlib/src/pj/ioqueue_winnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
# include <mswsock.h>
#endif

/* For GetAcceptExSockaddrs() on MSVC2005 */
#pragma comment(lib, "mswsock.lib")

/* The address specified in AcceptEx() must be 16 more than the size of
* SOCKADDR (source: MSDN).
Expand Down
2 changes: 1 addition & 1 deletion pjlib/src/pjlib-test/fifobuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static int fifobuf_rolling_test()

/* Free cunks, leave some chunks for the next repeat */
n = N/4 + (pj_rand() % (N/4));
while (pj_list_size(&chunks) > n) {
while ((int)pj_list_size(&chunks) > n) {
chunk = chunks.next;
pj_list_erase(chunk);
pj_fifobuf_free(&fifo, chunk);
Expand Down
16 changes: 9 additions & 7 deletions pjlib/src/pjlib-test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@
pj_pool_factory *mem;

struct test_app_t test_app = {
.param_echo_sock_type = 0,
.param_echo_server = ECHO_SERVER_ADDRESS,
.param_echo_port = ECHO_SERVER_START_PORT,
.param_log_decor = PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_TIME |
PJ_LOG_HAS_MICRO_SEC | PJ_LOG_HAS_INDENT,
.param_ci_mode = PJ_FALSE,
{0}, /* .ut_app */
0, /* .param_echo_sock_type */
ECHO_SERVER_ADDRESS, /* .param_echo_server */
ECHO_SERVER_START_PORT, /* .param_echo_port */
PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_TIME |
PJ_LOG_HAS_MICRO_SEC | PJ_LOG_HAS_INDENT,
/* .param_log_decor */
PJ_FALSE, /* .param_ci_mode */
};

int null_func()
Expand Down Expand Up @@ -387,7 +389,7 @@ int test_inner(int argc, char *argv[])
}
}

if (argc-1 > 0 && stat.nruns==argc-1) {
if (argc-1 > 0 && (int)stat.nruns==argc-1) {
/* cmdline specifies test(s) to run, and the number of runs
* matches that. That means all requested tests have been run.
*/
Expand Down
5 changes: 3 additions & 2 deletions pjlib/src/pjlib-test/test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,12 @@ PJ_INLINE(void) ut_list_tests(ut_app_t *ut_app, const char *title)
PJ_INLINE(pj_status_t) ut_run_tests(ut_app_t *ut_app, const char *title,
int argc, char *argv[])
{
pj_test_runner_param runner_prm;
pj_test_runner_param_default(&runner_prm);
pj_test_runner *runner;
pj_test_stat stat;
pj_status_t status;
pj_test_runner_param runner_prm;

pj_test_runner_param_default(&runner_prm);

if (ut_app->prm_shuffle) {
PJ_LOG(3,(THIS_FILE, "Shuffling tests, random seed=%d",
Expand Down
6 changes: 4 additions & 2 deletions pjnath/src/pjnath-test/ice_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1119,11 +1119,13 @@ int ice_test(void *p)

rc = 0;
if (test_id >= ICE_TEST_START_ARRAY) {
i = test_id - ICE_TEST_START_ARRAY;
struct sess_cfg_t *cfg = &sess_cfg[i];
struct sess_cfg_t *cfg;
unsigned delay[] = { 50, 2000 };
unsigned d;

i = test_id - ICE_TEST_START_ARRAY;
cfg = &sess_cfg[i];

PJ_LOG(3,(THIS_FILE, " %s", cfg->title));

/* For each test item, test with various answer delay */
Expand Down
2 changes: 1 addition & 1 deletion pjsip-apps/src/samples/pcaputil.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ static void pcap2wav(const struct args *args)
ts_gap = pj_ntohl(pkt1.rtp->ts) - pj_ntohl(pkt0.rtp->ts) -
samples_cnt;

if (ts_gap <= param.info.clock_rate * GAP_IGNORE_SECONDS) { /* Ignore gap >30s */
if (ts_gap <= (long)param.info.clock_rate * GAP_IGNORE_SECONDS) { /* Ignore gap >30s */
while (ts_gap >= (long)samples_per_frame) {
pcm_frame.buf = pcm;
pcm_frame.size = samples_per_frame * 2;
Expand Down
24 changes: 12 additions & 12 deletions pjsip/src/pjsip-ua/sip_siprec.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ PJ_DEF(pj_status_t) pjsip_siprec_init_module(pjsip_endpoint *endpt)
*/
PJ_DEF(pj_status_t) pjsip_siprec_verify_require_hdr(pjsip_require_hdr *req_hdr)
{
for (int i=0; i<req_hdr->count; ++i) {
unsigned i;
for (i=0; i<req_hdr->count; ++i) {
/* Check request has the siprec value in the Require header.*/
if (pj_stricmp(&req_hdr->values[i], &STR_SIPREC)==0)
{
Expand All @@ -140,6 +141,7 @@ PJ_DEF(pj_status_t) pjsip_siprec_verify_request(pjsip_rx_data *rdata,
pj_status_t status = PJ_SUCCESS;
const char *warn_text = NULL;
pjsip_hdr res_hdr_list;
unsigned mi;

/* Init return arguments. */
if (p_tdata) *p_tdata = NULL;
Expand Down Expand Up @@ -180,7 +182,7 @@ PJ_DEF(pj_status_t) pjsip_siprec_verify_request(pjsip_rx_data *rdata,
}

/* Check that the media attribute label exist in the SDP */
for (unsigned mi=0; mi<sdp_offer->media_count; ++mi) {
for (mi=0; mi<sdp_offer->media_count; ++mi) {
if (!pjmedia_sdp_media_find_attr(sdp_offer->media[mi],
&STR_LABEL, NULL)){
code = PJSIP_SC_BAD_REQUEST;
Expand Down Expand Up @@ -263,22 +265,20 @@ PJ_DEF(pj_status_t) pjsip_siprec_verify_request(pjsip_rx_data *rdata,
* Find siprec metadata from the message body
*/
PJ_DEF(pj_status_t) pjsip_siprec_get_metadata(pj_pool_t *pool,
pjsip_msg_body *body,
pj_str_t* metadata)
pjsip_msg_body *body,
pj_str_t* metadata)
{
pjsip_media_type application_metadata;

pjsip_media_type_init2(&application_metadata,
"application", "rs-metadata");

pjsip_media_type app_metadata;
pjsip_multipart_part *metadata_part;
metadata_part = pjsip_multipart_find_part(body,
&application_metadata, NULL);

PJ_UNUSED_ARG(pool);
pjsip_media_type_init2(&app_metadata, "application", "rs-metadata");
metadata_part = pjsip_multipart_find_part(body, &app_metadata, NULL);

if(!metadata_part)
return PJ_ENOTFOUND;

metadata->ptr = (char*)metadata_part->body->data;
metadata->ptr = (char*)metadata_part->body->data;
metadata->slen = metadata_part->body->len;

return PJ_SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion pjsip/src/pjsip/sip_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ PJ_DEF(pj_status_t) pjsip_process_route_set(pjsip_tx_data *tdata,
tdata->tp_sel.type == PJSIP_TPSELECTOR_LISTENER) &&
tdata->tp_sel.u.ptr)
{
pjsip_transport_type_e tp_type;
pjsip_transport_type_e tp_type = PJSIP_TRANSPORT_UNSPECIFIED;

if (tdata->tp_sel.type == PJSIP_TPSELECTOR_TRANSPORT)
tp_type = tdata->tp_sel.u.transport->key.type;
Expand Down
3 changes: 2 additions & 1 deletion pjsip/src/test/transport_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,10 +707,11 @@ int transport_rt_test( pjsip_transport_type_e tp_type,

/* Start threads! */
for (i=0; i<THREADS; ++i) {
pj_time_val delay = {0, i*10};
pj_time_val delay = {0, 0};
pj_thread_resume(g_rt[tid].rt_test_data[i].thread);

/* Schedule first message transmissions. */
delay.msec = i*10;
g_rt[tid].rt_test_data[i].tx_timer.user_data = (void*)(pj_ssize_t)1;
pjsip_endpt_schedule_timer(endpt, &g_rt[tid].rt_test_data[i].tx_timer, &delay);
}
Expand Down
2 changes: 1 addition & 1 deletion pjsip/src/test/transport_udp_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static pj_status_t multi_transport_test(pjsip_transport *tp[], unsigned max_tp)
int rc;
unsigned i, num_tp=0;
pj_str_t s;
pjsip_transport *other_udp_tp = NULL, *udp_tp;
pjsip_transport *other_udp_tp = NULL, *udp_tp = NULL;
pj_sockaddr_in rem_addr;
pjsip_tpselector tp_sel;

Expand Down
2 changes: 1 addition & 1 deletion pjsip/src/test/tsx_uac_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ static int tsx_resolve_error_test(unsigned tid)
*/
static int tsx_terminate_resolving_test(unsigned tid)
{
unsigned prev_delay;
unsigned prev_delay = 0;
pj_status_t status;

PJ_LOG(3,(THIS_FILE, " test3: terminate while resolving test"));
Expand Down

0 comments on commit 377a80c

Please sign in to comment.