Skip to content

Commit

Permalink
Fixed printf format warnings (#3813)
Browse files Browse the repository at this point in the history
  • Loading branch information
sauwming authored Dec 27, 2023
1 parent 5601a20 commit 033e4d7
Show file tree
Hide file tree
Showing 30 changed files with 135 additions and 97 deletions.
9 changes: 5 additions & 4 deletions pjlib-util/src/pjlib-util-test/http_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static void on_data_read(pj_http_req *hreq, void *data, pj_size_t size)
PJ_UNUSED_ARG(hreq);
PJ_UNUSED_ARG(data);

PJ_LOG(5, (THIS_FILE, "\nData received: %ld bytes", size));
PJ_LOG(5, (THIS_FILE, "\nData received: %lu bytes", (unsigned long)size));
if (size > 0) {
#ifdef VERBOSE
printf("%.*s\n", (int)size, (char *)data);
Expand All @@ -190,8 +190,8 @@ static void on_send_data(pj_http_req *hreq,
*data = sdata;
*size = sendsz;

PJ_LOG(5, (THIS_FILE, "\nSending data progress: %ld out of %ld bytes",
send_size, total_size));
PJ_LOG(5, (THIS_FILE, "\nSending data progress: %lu out of %lu bytes",
(unsigned long)send_size, (unsigned long)total_size));
}


Expand All @@ -210,7 +210,8 @@ static void on_complete(pj_http_req *hreq, pj_status_t status,
PJ_LOG(3, (THIS_FILE, "Error %d", status));
return;
}
PJ_LOG(5, (THIS_FILE, "\nData completed: %ld bytes", resp->size));
PJ_LOG(5, (THIS_FILE, "\nData completed: %lu bytes",
(unsigned long)resp->size));
if (resp->size > 0 && resp->data) {
#ifdef VERBOSE
printf("%.*s\n", (int)resp->size, (char *)resp->data);
Expand Down
8 changes: 4 additions & 4 deletions pjlib-util/src/pjlib-util/resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1942,12 +1942,12 @@ PJ_DEF(void) pj_dns_resolver_dump(pj_dns_resolver *resolver,
}
}
PJ_LOG(3,(resolver->name.ptr, " Nb. of pending query free nodes: %lu",
pj_list_size(&resolver->query_free_nodes)));
(unsigned long)pj_list_size(&resolver->query_free_nodes)));
PJ_LOG(3,(resolver->name.ptr, " Nb. of timer entries: %lu",
pj_timer_heap_count(resolver->timer)));
(unsigned long)pj_timer_heap_count(resolver->timer)));
PJ_LOG(3,(resolver->name.ptr, " Pool capacity: %lu, used size: %lu",
pj_pool_get_capacity(resolver->pool),
pj_pool_get_used_size(resolver->pool)));
(unsigned long)pj_pool_get_capacity(resolver->pool),
(unsigned long)pj_pool_get_used_size(resolver->pool)));

pj_grp_lock_release(resolver->grp_lock);
#endif
Expand Down
3 changes: 2 additions & 1 deletion pjlib-util/src/pjlib-util/stun_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ PJ_DEF(pj_status_t) pjstun_parse_msg( void *buf, pj_size_t buf_len,
msg_len = pj_ntohs(msg->hdr->length);
if (msg_len != buf_len - sizeof(pjstun_msg_hdr)) {
PJ_LOG(4,(THIS_FILE, "Error: invalid msg_len %d (expecting %lu)",
msg_len, buf_len - sizeof(pjstun_msg_hdr)));
msg_len, (unsigned long)
(buf_len - sizeof(pjstun_msg_hdr))));
return PJLIB_UTIL_ESTUNINMSGLEN;
}

Expand Down
5 changes: 3 additions & 2 deletions pjlib-util/src/pjlib-util/stun_simple_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,9 @@ PJ_DEF(pj_status_t) pjstun_get_mapped_addr2(pj_pool_factory *pf,
}
}

TRACE_((THIS_FILE, " Pool usage=%ld of %ld", pj_pool_get_used_size(pool),
pj_pool_get_capacity(pool)));
TRACE_((THIS_FILE, " Pool usage=%lu of %lu",
(unsigned long)pj_pool_get_used_size(pool),
(unsigned long)pj_pool_get_capacity(pool)));

pj_pool_release(pool);

Expand Down
4 changes: 2 additions & 2 deletions pjlib/src/pj/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ static pj_hash_entry **find_entry( pj_pool_t *pool, pj_hash_table_t *ht,
entry = PJ_POOL_ALLOC_T(pool, pj_hash_entry);
PJ_LOG(6, ("hashtbl",
"%p: New p_entry %p created, pool used=%lu, cap=%lu",
ht, entry, pj_pool_get_used_size(pool),
pj_pool_get_capacity(pool)));
ht, entry, (unsigned long)pj_pool_get_used_size(pool),
(unsigned long)pj_pool_get_capacity(pool)));
}
entry->next = NULL;
entry->hash = hash;
Expand Down
27 changes: 17 additions & 10 deletions pjlib/src/pj/pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ static pj_pool_block *pj_pool_create_block( pj_pool_t *pool, pj_size_t size)
pj_assert(size >= sizeof(pj_pool_block));

LOG((pool->obj_name, "create_block(sz=%lu), cur.cap=%lu, cur.used=%lu",
size, pool->capacity, pj_pool_get_used_size(pool)));
(unsigned long)size, (unsigned long)pool->capacity,
(unsigned long)pj_pool_get_used_size(pool)));

/* Request memory from allocator. */
block = (pj_pool_block*)
Expand Down Expand Up @@ -118,7 +119,8 @@ PJ_DEF(void*) pj_pool_allocate_find(pj_pool_t *pool, pj_size_t size)
if (pool->increment_size == 0) {
LOG((pool->obj_name, "Can't expand pool to allocate %lu bytes "
"(used=%lu, cap=%lu)",
size, pj_pool_get_used_size(pool), pool->capacity));
(unsigned long)size, (unsigned long)pj_pool_get_used_size(pool),
(unsigned long)pool->capacity));
(*pool->callback)(pool, size);
return NULL;
}
Expand All @@ -143,7 +145,9 @@ PJ_DEF(void*) pj_pool_allocate_find(pj_pool_t *pool, pj_size_t size)

LOG((pool->obj_name,
"%lu bytes requested, resizing pool by %lu bytes (used=%lu, cap=%lu)",
size, block_size, pj_pool_get_used_size(pool), pool->capacity));
(unsigned long)size, (unsigned long)block_size,
(unsigned long)pj_pool_get_used_size(pool),
(unsigned long)pool->capacity));

block = pj_pool_create_block(pool, block_size);
if (!block)
Expand Down Expand Up @@ -233,7 +237,8 @@ PJ_DEF(pj_pool_t*) pj_pool_create_int( pj_pool_factory *f, const char *name,
/* Pool initial capacity and used size */
pool->capacity = initial_size;

LOG((pool->obj_name, "pool created, size=%lu", pool->capacity));
LOG((pool->obj_name, "pool created, size=%lu",
(unsigned long)pool->capacity));
return pool;
}

Expand Down Expand Up @@ -278,9 +283,10 @@ static void reset_pool(pj_pool_t *pool)
*/
PJ_DEF(void) pj_pool_reset(pj_pool_t *pool)
{
LOG((pool->obj_name, "reset(): cap=%ld, used=%ld(%ld%%)",
pool->capacity, pj_pool_get_used_size(pool),
pj_pool_get_used_size(pool)*100/pool->capacity));
LOG((pool->obj_name, "reset(): cap=%lu, used=%lu(%lu%%)",
(unsigned long)pool->capacity,
(unsigned long)pj_pool_get_used_size(pool),
(unsigned long)(pj_pool_get_used_size(pool)*100/pool->capacity)));

reset_pool(pool);
}
Expand All @@ -292,9 +298,10 @@ PJ_DEF(void) pj_pool_destroy_int(pj_pool_t *pool)
{
pj_size_t initial_size;

LOG((pool->obj_name, "destroy(): cap=%ld, used=%ld(%ld%%), block0=%p-%p",
pool->capacity, pj_pool_get_used_size(pool),
pj_pool_get_used_size(pool)*100/pool->capacity,
LOG((pool->obj_name, "destroy(): cap=%lu, used=%lu(%lu%%), block0=%p-%p",
(unsigned long)pool->capacity,
(unsigned long)pj_pool_get_used_size(pool),
(unsigned long)(pj_pool_get_used_size(pool)*100/pool->capacity),
((pj_pool_block*)pool->block_list.next)->buf,
((pj_pool_block*)pool->block_list.next)->end));

Expand Down
31 changes: 19 additions & 12 deletions pjlib/src/pj/pool_caching.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ static pj_pool_t* cpool_create_pool(pj_pool_factory *pf,
cp->capacity = 0;
}

PJ_LOG(6, (pool->obj_name, "pool reused, size=%lu", pool->capacity));
PJ_LOG(6, (pool->obj_name, "pool reused, size=%lu",
(unsigned long)pool->capacity));
}

/* Put in used list. */
Expand Down Expand Up @@ -245,9 +246,11 @@ static void cpool_release_pool( pj_pool_factory *pf, pj_pool_t *pool)
}

/* Reset pool. */
PJ_LOG(6, (pool->obj_name, "recycle(): cap=%ld, used=%ld(%ld%%)",
pool_capacity, pj_pool_get_used_size(pool),
pj_pool_get_used_size(pool)*100/pool_capacity));
PJ_LOG(6, (pool->obj_name, "recycle(): cap=%lu, used=%lu(%lu%%)",
(unsigned long)pool_capacity,
(unsigned long)pj_pool_get_used_size(pool),
(unsigned long)(pj_pool_get_used_size(pool)*100/
pool_capacity)));
pj_pool_reset(pool);

pool_capacity = pj_pool_get_capacity(pool);
Expand Down Expand Up @@ -279,8 +282,9 @@ static void cpool_dump_status(pj_pool_factory *factory, pj_bool_t detail )
pj_lock_acquire(cp->lock);

PJ_LOG(3,("cachpool", " Dumping caching pool:"));
PJ_LOG(3,("cachpool", " Capacity=%lu, max_capacity=%lu, used_cnt=%lu", \
cp->capacity, cp->max_capacity, cp->used_count));
PJ_LOG(3,("cachpool", " Capacity=%lu, max_capacity=%lu, used_cnt=%lu",
(unsigned long)cp->capacity, (unsigned long)cp->max_capacity,
(unsigned long)cp->used_count));
if (detail) {
pj_pool_t *pool = (pj_pool_t*) cp->used_list.next;
pj_size_t total_used = 0, total_capacity = 0;
Expand All @@ -294,7 +298,7 @@ static void cpool_dump_status(pj_pool_factory *factory, pj_bool_t detail )
#if 0
PJ_LOG(6, ("cachpool", " %16s block %u, size %ld",
pj_pool_getobjname(pool), nblocks,
block->end - block->buf + 1));
(long)(block->end - block->buf + 1)));
#endif
nblocks++;
block = block->next;
Expand All @@ -303,9 +307,10 @@ static void cpool_dump_status(pj_pool_factory *factory, pj_bool_t detail )
PJ_LOG(3,("cachpool", " %16s: %8lu of %8lu (%lu%%) used, "
"nblocks: %d",
pj_pool_getobjname(pool),
pj_pool_get_used_size(pool),
pool_capacity,
pj_pool_get_used_size(pool)*100/pool_capacity,
(unsigned long)pj_pool_get_used_size(pool),
(unsigned long)pool_capacity,
(unsigned long)(pj_pool_get_used_size(pool)*
100/pool_capacity),
nblocks));

#if PJ_POOL_MAX_SEARCH_BLOCK_COUNT == 0
Expand All @@ -323,8 +328,10 @@ static void cpool_dump_status(pj_pool_factory *factory, pj_bool_t detail )
}
if (total_capacity) {
PJ_LOG(3,("cachpool", " Total %9lu of %9lu (%lu %%) used!",
total_used, total_capacity,
total_used * 100 / total_capacity));
(unsigned long)total_used,
(unsigned long)total_capacity,
(unsigned long)(total_used * 100 /
total_capacity)));
}
}

Expand Down
5 changes: 3 additions & 2 deletions pjlib/src/pj/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,9 @@ static pj_status_t grow_heap(pj_timer_heap_t *ht)
pj_timer_entry_dup *new_dup;
#endif

PJ_LOG(6,(THIS_FILE, "Growing heap size from %ld to %ld",
ht->max_size, new_size));
PJ_LOG(6,(THIS_FILE, "Growing heap size from %lu to %lu",
(unsigned long)ht->max_size,
(unsigned long)new_size));

// First grow the heap itself.
new_heap = (pj_timer_entry_dup**)
Expand Down
14 changes: 8 additions & 6 deletions pjlib/src/pjlib-test/ioq_perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ static void on_read_complete(pj_ioqueue_key_t *key,
PJ_LOG(3,(THIS_FILE,
".....additional info: type=%s, total read=%lu, "
"total sent=%lu",
item->type_name, item->bytes_recv,
item->bytes_sent));
item->type_name, (unsigned long)item->bytes_recv,
(unsigned long)item->bytes_sent));
}
} else {
last_error_counter++;
Expand Down Expand Up @@ -480,8 +480,10 @@ static int perform_test(const pj_ioqueue_cfg *cfg,
if (display_report) {
PJ_LOG(3,(THIS_FILE, " %s %d threads, %d pairs", type_name,
thread_cnt, sockpair_cnt));
PJ_LOG(3,(THIS_FILE, " Elapsed : %lu msec", total_elapsed_usec/1000));
PJ_LOG(3,(THIS_FILE, " Bandwidth: %lu KB/s", *p_bandwidth));
PJ_LOG(3,(THIS_FILE, " Elapsed : %lu msec",
(unsigned long)(total_elapsed_usec/1000)));
PJ_LOG(3,(THIS_FILE, " Bandwidth: %lu KB/s",
(unsigned long)*p_bandwidth));
PJ_LOG(3,(THIS_FILE, " Threads statistics:"));
PJ_LOG(3,(THIS_FILE, " ============================="));
PJ_LOG(3,(THIS_FILE, " Thread Loops Events Errors"));
Expand All @@ -506,7 +508,7 @@ static int perform_test(const pj_ioqueue_cfg *cfg,
} else {
PJ_LOG(3,(THIS_FILE, " %.4s %2d %2d %8lu KB/s",
type_name, thread_cnt, sockpair_cnt,
*p_bandwidth));
(unsigned long)*p_bandwidth));
}

/* Done. */
Expand Down Expand Up @@ -578,7 +580,7 @@ static int ioqueue_perf_test_imp(const pj_ioqueue_cfg *cfg)
test_param[best_index].type_name,
test_param[best_index].thread_cnt,
test_param[best_index].sockpair_cnt,
best_bandwidth));
(unsigned long)best_bandwidth));
PJ_LOG(3,(THIS_FILE, " (Note: packet size=%d, total errors=%u)",
BUF_SIZE, last_error_counter));
return 0;
Expand Down
7 changes: 4 additions & 3 deletions pjlib/src/pjlib-test/pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static int capacity_test(void)

if (pj_pool_alloc(pool, freesize) == NULL) {
PJ_LOG(3,("test", "...error: wrong freesize %lu reported",
freesize));
(unsigned long)freesize));
pj_pool_release(pool);
return -210;
}
Expand Down Expand Up @@ -175,7 +175,8 @@ static int drain_test(pj_size_t size, pj_size_t increment)
void *p;
int status = 0;

PJ_LOG(3,("test", "...drain_test(%lu,%lu)", size, increment));
PJ_LOG(3,("test", "...drain_test(%lu,%lu)", (unsigned long)size,
(unsigned long)increment));

if (!pool)
return -10;
Expand Down Expand Up @@ -208,7 +209,7 @@ static int drain_test(pj_size_t size, pj_size_t increment)
/* Check that capacity is zero. */
if (GET_FREE(pool) != 0) {
PJ_LOG(3,("test", "....error: returned free=%lu (expecting 0)",
GET_FREE(pool)));
(unsigned long)(GET_FREE(pool))));
status=-30; goto on_error;
}

Expand Down
14 changes: 8 additions & 6 deletions pjlib/src/pjlib-test/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,14 +541,15 @@ static int send_recv_test(int sock_type,
rc = -155; goto on_error;
}
if (received <= 0) {
PJ_LOG(3,("", "...error: socket has closed! (received=%ld)",
received));
PJ_LOG(3,("", "...error: socket has closed! (received=%lu)",
(unsigned long)received));
rc = -156; goto on_error;
}
if (received != DATA_LEN-total_received) {
if (sock_type != pj_SOCK_STREAM()) {
PJ_LOG(3,("", "...error: expecting %lu bytes, got %lu bytes",
DATA_LEN-total_received, received));
(unsigned long)(DATA_LEN-total_received),
(unsigned long)received));
rc = -157; goto on_error;
}
}
Expand Down Expand Up @@ -599,14 +600,15 @@ static int send_recv_test(int sock_type,
rc = -170; goto on_error;
}
if (received <= 0) {
PJ_LOG(3,("", "...error: socket has closed! (received=%ld)",
received));
PJ_LOG(3,("", "...error: socket has closed! (received=%lu)",
(unsigned long)received));
rc = -173; goto on_error;
}
if (received != BIG_DATA_LEN-total_received) {
if (sock_type != pj_SOCK_STREAM()) {
PJ_LOG(3,("", "...error: expecting %lu bytes, got %lu bytes",
BIG_DATA_LEN-total_received, received));
(unsigned long)BIG_DATA_LEN-total_received,
(unsigned long)received));
rc = -176; goto on_error;
}
}
Expand Down
12 changes: 8 additions & 4 deletions pjlib/src/pjlib-test/ssl_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ static pj_bool_t ssl_on_data_read(pj_ssl_sock_t *ssock,
}

pj_sockaddr_print((pj_sockaddr_t*)&info.local_addr, buf, sizeof(buf), 1);
PJ_LOG(3, ("", "...%s successfully recv %lu bytes echo", buf, st->recv));
PJ_LOG(3, ("", "...%s successfully recv %lu bytes echo", buf,
(unsigned long)st->recv));
st->done = PJ_TRUE;
}
}
Expand Down Expand Up @@ -501,7 +502,8 @@ static int https_client_test(unsigned ms_timeout)
}

PJ_LOG(3, ("", "...Done!"));
PJ_LOG(3, ("", ".....Sent/recv: %lu/%lu bytes", state.sent, state.recv));
PJ_LOG(3, ("", ".....Sent/recv: %lu/%lu bytes", (unsigned long)state.sent,
(unsigned long)state.recv));

on_return:
if (ssock && !state.err && !state.done)
Expand Down Expand Up @@ -755,7 +757,8 @@ static int echo_test(pj_ssl_sock_proto srv_proto, pj_ssl_sock_proto cli_proto,
}

PJ_LOG(3, ("", "...Done!"));
PJ_LOG(3, ("", ".....Sent/recv: %lu/%lu bytes", state_cli.sent, state_cli.recv));
PJ_LOG(3, ("", ".....Sent/recv: %lu/%lu bytes", (unsigned long)state_cli.sent,
(unsigned long)state_cli.recv));

on_return:
#if (PJ_SSL_SOCK_IMP == PJ_SSL_SOCK_IMP_DARWIN) || \
Expand Down Expand Up @@ -1464,7 +1467,8 @@ static int perf_test(unsigned clients, unsigned ms_handshake_timeout)
}

PJ_LOG(3, ("", ".....Clients: %d (%d errors)", clients, cli_err));
PJ_LOG(3, ("", ".....Total sent/recv: %lu/%lu bytes", tot_sent, tot_recv));
PJ_LOG(3, ("", ".....Total sent/recv: %lu/%lu bytes",
(unsigned long)tot_sent, (unsigned long)tot_recv));

on_return:
if (ssock_serv)
Expand Down
Loading

0 comments on commit 033e4d7

Please sign in to comment.