Skip to content

Commit

Permalink
Miscellaneous fixes (compile warnings, pool '%p' naming in pool debug…
Browse files Browse the repository at this point in the history
…). (#4191)
  • Loading branch information
nanangizz authored Dec 2, 2024
1 parent 21804cd commit d935711
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
20 changes: 14 additions & 6 deletions pjlib/src/pj/pool_dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
Expand All @@ -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);
}


Expand Down
12 changes: 7 additions & 5 deletions pjlib/src/pj/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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;

Expand Down
5 changes: 3 additions & 2 deletions pjsip/src/pjsip/sip_auth_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion pjsip/src/pjsua-lib/pjsua_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions pjsip/src/pjsua2/media.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit d935711

Please sign in to comment.