From c01469cd6c52091620b5f2e0ed89a692d7b32112 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Mon, 2 Dec 2024 14:14:16 +0700 Subject: [PATCH] Miscellaneous fixes (compile warnings, pool '%p' naming in pool debug). --- pjlib/src/pj/pool_dbg.c | 20 ++++++++++++++------ pjlib/src/pj/timer.c | 12 +++++++----- pjsip/src/pjsip/sip_auth_client.c | 5 +++-- pjsip/src/pjsua-lib/pjsua_core.c | 2 +- pjsip/src/pjsua2/media.cpp | 7 +++++++ 5 files changed, 32 insertions(+), 14 deletions(-) diff --git a/pjlib/src/pj/pool_dbg.c b/pjlib/src/pj/pool_dbg.c index 380ba02730..5bc22c04cc 100644 --- a/pjlib/src/pj/pool_dbg.c +++ b/pjlib/src/pj/pool_dbg.c @@ -72,7 +72,14 @@ PJ_DEF(pj_pool_t*) pj_pool_create_imp( const char *file, int line, return NULL; if (name) { - pj_ansi_strxcpy(pool->obj_name, name, sizeof(pool->obj_name)); + char *p = pj_ansi_strchr(name, '%'); + if (p && *(p+1)=='p' && *(p+2)=='\0') { + /* Special name with "%p" suffix */ + pj_ansi_snprintf(pool->obj_name, sizeof(pool->obj_name), + name, pool); + } else { + pj_ansi_strxcpy(pool->obj_name, name, PJ_MAX_OBJ_NAME); + } } else { pj_ansi_strxcpy(pool->obj_name, "altpool", sizeof(pool->obj_name)); } @@ -171,8 +178,9 @@ PJ_DEF(void*) pj_pool_alloc_imp( const char *file, int line, { char msg[120]; pj_ansi_snprintf(msg, sizeof(msg), - "Mem %X (%d+%d bytes) allocated by %s:%d\r\n", - mem, sz, sizeof(struct pj_pool_mem), + "Mem %X (%u+%u bytes) allocated by %s:%d\r\n", + (unsigned)(intptr_t)mem, (unsigned)sz, + (unsigned)sizeof(struct pj_pool_mem), file, line); TRACE_(msg); } @@ -182,8 +190,8 @@ PJ_DEF(void*) pj_pool_alloc_imp( const char *file, int line, } /* Allocate memory from the pool and zero the memory */ -PJ_DEF(void*) pj_pool_calloc_imp( const char *file, int line, - pj_pool_t *pool, unsigned cnt, +PJ_DEF(void*) pj_pool_calloc_imp( const char *file, int line, + pj_pool_t *pool, unsigned cnt, unsigned elemsz) { void *mem; @@ -200,7 +208,7 @@ PJ_DEF(void*) pj_pool_calloc_imp( const char *file, int line, PJ_DEF(void*) pj_pool_zalloc_imp( const char *file, int line, pj_pool_t *pool, pj_size_t sz) { - return pj_pool_calloc_imp(file, line, pool, 1, sz); + return pj_pool_calloc_imp(file, line, pool, 1, (unsigned)sz); } diff --git a/pjlib/src/pj/timer.c b/pjlib/src/pj/timer.c index bbbaf91d59..86766ddfb4 100644 --- a/pjlib/src/pj/timer.c +++ b/pjlib/src/pj/timer.c @@ -368,7 +368,7 @@ static pj_timer_entry_dup * remove_node( pj_timer_heap_t *ht, size_t slot) static pj_status_t grow_heap(pj_timer_heap_t *ht) { // All the containers will double in size from max_size_ - size_t new_size = ht->max_size * 2; + pj_size_t new_size = ht->max_size * 2; #if PJ_TIMER_USE_COPY pj_timer_entry_dup *new_timer_dups = 0; #endif @@ -386,15 +386,16 @@ static pj_status_t grow_heap(pj_timer_heap_t *ht) (unsigned long)new_size)); // First grow the heap itself. - new_heap = (pj_timer_entry_dup**) - pj_pool_calloc(ht->pool, new_size, sizeof(pj_timer_entry_dup*)); + new_heap = (pj_timer_entry_dup**) + pj_pool_calloc(ht->pool, (unsigned)new_size, + sizeof(pj_timer_entry_dup*)); if (!new_heap) return PJ_ENOMEM; #if PJ_TIMER_USE_COPY // Grow the array of timer copies. - new_timer_dups = (pj_timer_entry_dup*) + new_timer_dups = (pj_timer_entry_dup*) pj_pool_alloc(ht->pool, sizeof(pj_timer_entry_dup) * new_size); if (!new_timer_dups) @@ -616,7 +617,8 @@ PJ_DEF(pj_status_t) pj_timer_heap_create( pj_pool_t *pool, // Create the heap array. ht->heap = (pj_timer_entry_dup**) - pj_pool_calloc(pool, size, sizeof(pj_timer_entry_dup*)); + pj_pool_calloc(pool, (unsigned)size, + sizeof(pj_timer_entry_dup*)); if (!ht->heap) return PJ_ENOMEM; diff --git a/pjsip/src/pjsip/sip_auth_client.c b/pjsip/src/pjsip/sip_auth_client.c index 4c5d7b4606..01563e4b75 100644 --- a/pjsip/src/pjsip/sip_auth_client.c +++ b/pjsip/src/pjsip/sip_auth_client.c @@ -246,7 +246,7 @@ PJ_DEF(pj_status_t) pjsip_auth_create_digest2( pj_str_t *result, digest_strlen = algorithm->digest_str_length; dig_len = digest_len; - if (result->slen < digest_strlen) { + if (result->slen < (pj_ssize_t)digest_strlen) { PJ_LOG(4, (THIS_FILE, "The length of the result buffer must be at least %d bytes " "for algorithm %.*s", digest_strlen, @@ -273,7 +273,8 @@ PJ_DEF(pj_status_t) pjsip_auth_create_digest2( pj_str_t *result, pjsip_auth_algorithms[algorithm_type].iana_name.ptr)); return PJ_EINVAL; } - PJ_ASSERT_RETURN(cred_info->data.slen >= digest_strlen, PJ_EINVAL); + PJ_ASSERT_RETURN(cred_info->data.slen >= (pj_ssize_t)digest_strlen, + PJ_EINVAL); } md = EVP_get_digestbyname(algorithm->openssl_name); diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c index cc6976adbc..a29b5cdd6c 100644 --- a/pjsip/src/pjsua-lib/pjsua_core.c +++ b/pjsip/src/pjsua-lib/pjsua_core.c @@ -3376,7 +3376,7 @@ PJ_DEF(pj_status_t) pjsua_verify_sip_url(const char *c_url) pool = pj_pool_create(&pjsua_var.cp.factory, "check%p", 1024, 0, NULL); if (!pool) return PJ_ENOMEM; - url = (char*) pj_pool_calloc(pool, 1, len+1); + url = (char*) pj_pool_calloc(pool, 1, (unsigned)len+1); pj_ansi_strxcpy(url, c_url, len+1); p = pjsip_parse_uri(pool, url, len, 0); diff --git a/pjsip/src/pjsua2/media.cpp b/pjsip/src/pjsua2/media.cpp index 3b6667644c..cefa7b3716 100644 --- a/pjsip/src/pjsua2/media.cpp +++ b/pjsip/src/pjsua2/media.cpp @@ -1591,6 +1591,13 @@ void MediaFormatVideo::init(pj_uint32_t formatId, this->avgBps = avgBps_; this->maxBps = maxBps_; #else + PJ_UNUSED_ARG(formatId); + PJ_UNUSED_ARG(width_); + PJ_UNUSED_ARG(height_); + PJ_UNUSED_ARG(fpsNum_); + PJ_UNUSED_ARG(fpsDenum_); + PJ_UNUSED_ARG(avgBps_); + PJ_UNUSED_ARG(maxBps_); type = PJMEDIA_TYPE_UNKNOWN; #endif }