diff --git a/pjlib-util/src/pjlib-util/resolver.c b/pjlib-util/src/pjlib-util/resolver.c index 20c7e733b..dea15e7c3 100644 --- a/pjlib-util/src/pjlib-util/resolver.c +++ b/pjlib-util/src/pjlib-util/resolver.c @@ -1905,7 +1905,7 @@ PJ_DEF(void) pj_dns_resolver_dump(pj_dns_resolver *resolver, struct nameserver *ns = &resolver->ns[i]; PJ_LOG(3,(resolver->name.ptr, - " NS %d: %s:%d (state=%s until %ds, rtt=%ld ms)", + " NS %d: %s:%d (state=%s until %lds, rtt=%ld ms)", i, pj_sockaddr_print(&ns->addr, addr, sizeof(addr), 2), pj_sockaddr_get_port(&ns->addr), @@ -1945,11 +1945,11 @@ PJ_DEF(void) pj_dns_resolver_dump(pj_dns_resolver *resolver, it = pj_hash_next(resolver->hquerybyid, it); } } - PJ_LOG(3,(resolver->name.ptr, " Nb. of pending query free nodes: %u", + PJ_LOG(3,(resolver->name.ptr, " Nb. of pending query free nodes: %lu", pj_list_size(&resolver->query_free_nodes))); - PJ_LOG(3,(resolver->name.ptr, " Nb. of timer entries: %u", + PJ_LOG(3,(resolver->name.ptr, " Nb. of timer entries: %lu", pj_timer_heap_count(resolver->timer))); - PJ_LOG(3,(resolver->name.ptr, " Pool capacity: %d, used size: %d", + 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))); diff --git a/pjlib-util/src/pjlib-util/stun_simple.c b/pjlib-util/src/pjlib-util/stun_simple.c index aff052026..d4233c9d4 100644 --- a/pjlib-util/src/pjlib-util/stun_simple.c +++ b/pjlib-util/src/pjlib-util/stun_simple.c @@ -75,7 +75,7 @@ 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 %d)", + PJ_LOG(4,(THIS_FILE, "Error: invalid msg_len %d (expecting %lu)", msg_len, buf_len - sizeof(pjstun_msg_hdr))); return PJLIB_UTIL_ESTUNINMSGLEN; } diff --git a/pjlib/include/pj/errno.h b/pjlib/include/pj/errno.h index e10612103..00cb4505b 100644 --- a/pjlib/include/pj/errno.h +++ b/pjlib/include/pj/errno.h @@ -497,7 +497,8 @@ void pj_errno_clear_handlers(void); #define pj_perror_wrapper_1(arg) pj_perror_1 arg /** Internal function. */ PJ_DECL(void) pj_perror_1(const char *sender, pj_status_t status, - const char *title_fmt, ...); + const char *title_fmt, ...) + PJ_PRINT_FUNC_DECOR(3); #else #define pj_perror_wrapper_1(arg) #endif @@ -512,7 +513,8 @@ void pj_errno_clear_handlers(void); #define pj_perror_wrapper_2(arg) pj_perror_2 arg /** Internal function. */ PJ_DECL(void) pj_perror_2(const char *sender, pj_status_t status, - const char *title_fmt, ...); + const char *title_fmt, ...) + PJ_PRINT_FUNC_DECOR(3); #else #define pj_perror_wrapper_2(arg) #endif @@ -527,7 +529,8 @@ void pj_errno_clear_handlers(void); #define pj_perror_wrapper_3(arg) pj_perror_3 arg /** Internal function. */ PJ_DECL(void) pj_perror_3(const char *sender, pj_status_t status, - const char *title_fmt, ...); + const char *title_fmt, ...) + PJ_PRINT_FUNC_DECOR(3); #else #define pj_perror_wrapper_3(arg) #endif @@ -542,7 +545,8 @@ void pj_errno_clear_handlers(void); #define pj_perror_wrapper_4(arg) pj_perror_4 arg /** Internal function. */ PJ_DECL(void) pj_perror_4(const char *sender, pj_status_t status, - const char *title_fmt, ...); + const char *title_fmt, ...) + PJ_PRINT_FUNC_DECOR(3); #else #define pj_perror_wrapper_4(arg) #endif @@ -557,7 +561,8 @@ void pj_errno_clear_handlers(void); #define pj_perror_wrapper_5(arg) pj_perror_5 arg /** Internal function. */ PJ_DECL(void) pj_perror_5(const char *sender, pj_status_t status, - const char *title_fmt, ...); + const char *title_fmt, ...) + PJ_PRINT_FUNC_DECOR(3); #else #define pj_perror_wrapper_5(arg) #endif @@ -572,7 +577,8 @@ void pj_errno_clear_handlers(void); #define pj_perror_wrapper_6(arg) pj_perror_6 arg /** Internal function. */ PJ_DECL(void) pj_perror_6(const char *sender, pj_status_t status, - const char *title_fmt, ...); + const char *title_fmt, ...) + PJ_PRINT_FUNC_DECOR(3); #else #define pj_perror_wrapper_6(arg) #endif diff --git a/pjlib/include/pj/log.h b/pjlib/include/pj/log.h index c89f2b566..c7154f4f5 100644 --- a/pjlib/include/pj/log.h +++ b/pjlib/include/pj/log.h @@ -399,7 +399,8 @@ pj_status_t pj_log_init(void); #if PJ_LOG_MAX_LEVEL >= 1 #define pj_log_wrapper_1(arg) pj_log_1 arg /** Internal function. */ - PJ_DECL(void) pj_log_1(const char *src, const char *format, ...); + PJ_DECL(void) pj_log_1(const char *src, const char *format, ...) + PJ_PRINT_FUNC_DECOR(2); #else #define pj_log_wrapper_1(arg) #endif @@ -413,7 +414,8 @@ pj_status_t pj_log_init(void); #if PJ_LOG_MAX_LEVEL >= 2 #define pj_log_wrapper_2(arg) pj_log_2 arg /** Internal function. */ - PJ_DECL(void) pj_log_2(const char *src, const char *format, ...); + PJ_DECL(void) pj_log_2(const char *src, const char *format, ...) + PJ_PRINT_FUNC_DECOR(2); #else #define pj_log_wrapper_2(arg) #endif @@ -427,7 +429,8 @@ pj_status_t pj_log_init(void); #if PJ_LOG_MAX_LEVEL >= 3 #define pj_log_wrapper_3(arg) pj_log_3 arg /** Internal function. */ - PJ_DECL(void) pj_log_3(const char *src, const char *format, ...); + PJ_DECL(void) pj_log_3(const char *src, const char *format, ...) + PJ_PRINT_FUNC_DECOR(2); #else #define pj_log_wrapper_3(arg) #endif @@ -441,7 +444,8 @@ pj_status_t pj_log_init(void); #if PJ_LOG_MAX_LEVEL >= 4 #define pj_log_wrapper_4(arg) pj_log_4 arg /** Internal function. */ - PJ_DECL(void) pj_log_4(const char *src, const char *format, ...); + PJ_DECL(void) pj_log_4(const char *src, const char *format, ...) + PJ_PRINT_FUNC_DECOR(2); #else #define pj_log_wrapper_4(arg) #endif @@ -455,7 +459,8 @@ pj_status_t pj_log_init(void); #if PJ_LOG_MAX_LEVEL >= 5 #define pj_log_wrapper_5(arg) pj_log_5 arg /** Internal function. */ - PJ_DECL(void) pj_log_5(const char *src, const char *format, ...); + PJ_DECL(void) pj_log_5(const char *src, const char *format, ...) + PJ_PRINT_FUNC_DECOR(2); #else #define pj_log_wrapper_5(arg) #endif @@ -469,7 +474,8 @@ pj_status_t pj_log_init(void); #if PJ_LOG_MAX_LEVEL >= 6 #define pj_log_wrapper_6(arg) pj_log_6 arg /** Internal function. */ - PJ_DECL(void) pj_log_6(const char *src, const char *format, ...); + PJ_DECL(void) pj_log_6(const char *src, const char *format, ...) + PJ_PRINT_FUNC_DECOR(2); #else #define pj_log_wrapper_6(arg) #endif diff --git a/pjlib/include/pj/types.h b/pjlib/include/pj/types.h index 236917dda..d364b8f59 100644 --- a/pjlib/include/pj/types.h +++ b/pjlib/include/pj/types.h @@ -285,6 +285,17 @@ typedef int pj_exception_id_t; */ #define PJ_MAX_OBJ_NAME 32 +/** + * We need to tell the compiler that the function takes printf style + * arguments, so the compiler can check the code more carefully and + * generate the appropriate warnings, if necessary. + */ +#if defined(__GNUC__) || defined(__clang__) +# define PJ_PRINT_FUNC_DECOR(idx) __attribute__((format (printf, idx, idx+1))) +#else +# define PJ_PRINT_FUNC_DECOR() +#endif + /* ************************************************************************* */ /* * General. diff --git a/pjlib/src/pj/ioqueue_select.c b/pjlib/src/pj/ioqueue_select.c index c89b0a0b6..f616e3983 100644 --- a/pjlib/src/pj/ioqueue_select.c +++ b/pjlib/src/pj/ioqueue_select.c @@ -363,7 +363,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_register_sock2(pj_pool_t *pool, */ if (sizeof(fd_set) < FD_SETSIZE && sock >= FD_SETSIZE) { PJ_LOG(4, ("pjlib", "Failed to register socket to ioqueue because " - "socket fd is too big (fd=%d/FD_SETSIZE=%d)", + "socket fd is too big (fd=%ld/FD_SETSIZE=%d)", sock, FD_SETSIZE)); return PJ_ETOOBIG; } diff --git a/pjlib/src/pj/pool_caching.c b/pjlib/src/pj/pool_caching.c index 9d3abdf95..0d55e1dfb 100644 --- a/pjlib/src/pj/pool_caching.c +++ b/pjlib/src/pj/pool_caching.c @@ -279,7 +279,7 @@ 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=%u, max_capacity=%u, used_cnt=%u", \ + PJ_LOG(3,("cachpool", " Capacity=%lu, max_capacity=%lu, used_cnt=%lu", \ cp->capacity, cp->max_capacity, cp->used_count)); if (detail) { pj_pool_t *pool = (pj_pool_t*) cp->used_list.next; @@ -300,7 +300,7 @@ static void cpool_dump_status(pj_pool_factory *factory, pj_bool_t detail ) block = block->next; } - PJ_LOG(3,("cachpool", " %16s: %8d of %8d (%d%%) used, " + PJ_LOG(3,("cachpool", " %16s: %8lu of %8lu (%lu%%) used, " "nblocks: %d", pj_pool_getobjname(pool), pj_pool_get_used_size(pool), @@ -322,7 +322,7 @@ static void cpool_dump_status(pj_pool_factory *factory, pj_bool_t detail ) pool = pool->next; } if (total_capacity) { - PJ_LOG(3,("cachpool", " Total %9d of %9d (%d %%) used!", + PJ_LOG(3,("cachpool", " Total %9lu of %9lu (%lu %%) used!", total_used, total_capacity, total_used * 100 / total_capacity)); } diff --git a/pjlib/src/pj/ssl_sock_imp_common.c b/pjlib/src/pj/ssl_sock_imp_common.c index d742580f0..25ba83b5d 100644 --- a/pjlib/src/pj/ssl_sock_imp_common.c +++ b/pjlib/src/pj/ssl_sock_imp_common.c @@ -640,7 +640,7 @@ static void on_timer(pj_timer_heap_t *th, struct pj_timer_entry *te) switch (timer_id) { case TIMER_HANDSHAKE_TIMEOUT: - PJ_LOG(1,(ssock->pool->obj_name, "SSL timeout after %d.%ds", + PJ_LOG(1,(ssock->pool->obj_name, "SSL timeout after %ld.%lds", ssock->param.timeout.sec, ssock->param.timeout.msec)); on_handshake_complete(ssock, PJ_ETIMEDOUT); diff --git a/pjlib/src/pj/ssl_sock_ossl.c b/pjlib/src/pj/ssl_sock_ossl.c index de500883f..4bbcc6dfa 100644 --- a/pjlib/src/pj/ssl_sock_ossl.c +++ b/pjlib/src/pj/ssl_sock_ossl.c @@ -345,7 +345,7 @@ static void SSLLogErrors(char * action, int ret, int ssl_err, int len, break; } default: - PJ_LOG(2,("SSL", "%lu [%s] (%s) ret: %d len: %d", + PJ_LOG(2,("SSL", "%d [%s] (%s) ret: %d len: %d", ssl_err, ssl_err_str, action, ret, len)); break; } @@ -678,7 +678,7 @@ static pj_status_t init_openssl(void) openssl_init_count = 1; - PJ_LOG(4, (THIS_FILE, "OpenSSL version : %x", OPENSSL_VERSION_NUMBER)); + PJ_LOG(4, (THIS_FILE, "OpenSSL version : %ld", OPENSSL_VERSION_NUMBER)); /* Register error subsystem */ status = pj_register_strerror(PJ_SSL_ERRNO_START, PJ_SSL_ERRNO_SPACE_SIZE, @@ -2365,13 +2365,13 @@ static pj_status_t ssl_do_handshake(pj_ssl_sock_t *ssock) #if OPENSSL_VERSION_NUMBER >= 0x1010100fL PJ_LOG(5, (THIS_FILE, "Session info: reused=%d, resumable=%d, " - "timeout=%d", + "timeout=%ld", SSL_session_reused(ossock->ossl_ssl), SSL_SESSION_is_resumable(sess), SSL_SESSION_get_timeout(sess))); #else PJ_LOG(5, (THIS_FILE, "Session info: reused=%d, resumable=%d, " - "timeout=%d", + "timeout=%ld", SSL_session_reused(ossock->ossl_ssl), -1, SSL_SESSION_get_timeout(sess))); diff --git a/pjlib/src/pjlib-test/file.c b/pjlib/src/pjlib-test/file.c index 6a5546a9f..ed34d5621 100644 --- a/pjlib/src/pjlib-test/file.c +++ b/pjlib/src/pjlib-test/file.c @@ -130,8 +130,8 @@ static int file_test_internal(void) read = 1; status = pj_file_read(fd, &readbuf[size], &read); if (status != PJ_SUCCESS) { - PJ_LOG(3,("", "...error reading file after %d bytes (error follows)", - size)); + PJ_LOG(3,("", "...error reading file after %ld bytes " + "(error follows)", size)); app_perror("...error", status); return -110; } diff --git a/pjlib/src/pjlib-test/ioq_perf.c b/pjlib/src/pjlib-test/ioq_perf.c index 87615fe28..a1b8cc629 100644 --- a/pjlib/src/pjlib-test/ioq_perf.c +++ b/pjlib/src/pjlib-test/ioq_perf.c @@ -116,11 +116,11 @@ static void on_read_complete(pj_ioqueue_key_t *key, */ if (!IS_ERROR_SILENCED(rc)) { pj_strerror(rc, errmsg, sizeof(errmsg)); - PJ_LOG(3,(THIS_FILE,"...error: read error, bytes_read=%d (%s)", + PJ_LOG(3,(THIS_FILE,"...error: read error, bytes_read=%ld (%s)", bytes_read, errmsg)); PJ_LOG(3,(THIS_FILE, - ".....additional info: type=%s, total read=%u, " - "total sent=%u", + ".....additional info: type=%s, total read=%lu, " + "total sent=%lu", item->type_name, item->bytes_recv, item->bytes_sent)); } @@ -192,7 +192,7 @@ static void on_write_complete(pj_ioqueue_key_t *key, if (bytes_sent <= 0) { if (!IS_ERROR_SILENCED(-bytes_sent)) { PJ_PERROR(3, (THIS_FILE, (pj_status_t)-bytes_sent, - "...error: sending stopped. bytes_sent=%d", + "...error: sending stopped. bytes_sent=%ld", -bytes_sent)); } item->has_pending_send = 0; @@ -479,8 +479,8 @@ 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 : %u msec", total_elapsed_usec/1000)); - PJ_LOG(3,(THIS_FILE, " Bandwidth: %d KB/s", *p_bandwidth)); + 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, " Threads statistics:")); PJ_LOG(3,(THIS_FILE, " =============================")); PJ_LOG(3,(THIS_FILE, " Thread Loops Events Errors")); @@ -503,7 +503,7 @@ static int perform_test(const pj_ioqueue_cfg *cfg, item->bytes_recv*100.0/total_received)); } } else { - PJ_LOG(3,(THIS_FILE, " %.4s %2d %2d %8d KB/s", + PJ_LOG(3,(THIS_FILE, " %.4s %2d %2d %8lu KB/s", type_name, thread_cnt, sockpair_cnt, *p_bandwidth)); } @@ -573,7 +573,7 @@ static int ioqueue_perf_test_imp(const pj_ioqueue_cfg *cfg) } PJ_LOG(3,(THIS_FILE, - " Best: Type=%s Threads=%d, Skt.Pairs=%d, Bandwidth=%u KB/s", + " Best: Type=%s Threads=%d, Skt.Pairs=%d, Bandwidth=%lu KB/s", test_param[best_index].type_name, test_param[best_index].thread_cnt, test_param[best_index].sockpair_cnt, diff --git a/pjlib/src/pjlib-test/ioq_stress_test.c b/pjlib/src/pjlib-test/ioq_stress_test.c index 0eae04b25..2dbe70da1 100644 --- a/pjlib/src/pjlib-test/ioq_stress_test.c +++ b/pjlib/src/pjlib-test/ioq_stress_test.c @@ -162,9 +162,9 @@ static void on_read_complete(pj_ioqueue_key_t *key, }); if (bytes_read != -12345 && bytes_read <= 0 && !IGNORE_ERROR(-bytes_read)) { - TRACE((THIS_FILE, "op_key:%p: stopping due to read=%d", + TRACE((THIS_FILE, "op_key:%p: stopping due to read=%ld", op_key, bytes_read)); - PJ_PERROR(1,(THIS_FILE, (pj_status_t)-bytes_read, "%d is", -bytes_read)); + PJ_PERROR(1,(THIS_FILE, (pj_status_t)-bytes_read, "%ld is", -bytes_read)); okud->server.status = (bytes_read == 0)? PJ_RETURN_OS_ERROR(OSERR_ENOTCONN) : (pj_status_t)-bytes_read; break; @@ -182,7 +182,7 @@ static void on_read_complete(pj_ioqueue_key_t *key, for (p=start; p!=end; ++p) { counter = test->state.cnt[SERVER]++; if (*p != counter && test->cfg.sock_type==pj_SOCK_STREAM()) { - PJ_LOG(3,(THIS_FILE, " Error: TCP RX sequence mismatch at idx=%d. Expecting %d, got %d", + PJ_LOG(3,(THIS_FILE, " Error: TCP RX sequence mismatch at idx=%ld. Expecting %d, got %d", p-start, counter, *p)); test->state.retcode = 412; okud->server.status = PJ_EBUG; @@ -196,7 +196,7 @@ static void on_read_complete(pj_ioqueue_key_t *key, * order? (tested on Linux epoll). Or could there be * bug somewhere? */ - PJ_LOG(3,(THIS_FILE, " UDP RX sequence mismatch at idx=%d. Expecting %d, got %d", + PJ_LOG(3,(THIS_FILE, " UDP RX sequence mismatch at idx=%ld. Expecting %d, got %d", p-start, counter, *p)); //test->state.retcode = 413; //okud->server.status = PJ_EBUG; @@ -256,7 +256,7 @@ static void on_write_complete(pj_ioqueue_key_t *key, }); if (bytes_sent != -12345 && bytes_sent <= 0 && !IGNORE_ERROR(-bytes_sent)) { - TRACE((THIS_FILE, "op_key:%p: stopping due to sent=%d", + TRACE((THIS_FILE, "op_key:%p: stopping due to sent=%ld", op_key, bytes_sent)); okud->client.status = (bytes_sent == 0)? PJ_RETURN_OS_ERROR(OSERR_ENOTCONN) : (pj_status_t)-bytes_sent; diff --git a/pjlib/src/pjlib-test/ioq_udp.c b/pjlib/src/pjlib-test/ioq_udp.c index 7c0e81a61..d5a8e3cc1 100644 --- a/pjlib/src/pjlib-test/ioq_udp.c +++ b/pjlib/src/pjlib-test/ioq_udp.c @@ -1151,8 +1151,8 @@ static int bench_test(const pj_ioqueue_cfg *cfg, int bufsize, return rc; on_error: - PJ_LOG(1,(THIS_FILE, "...ERROR: %s", - pj_strerror(pj_get_netos_error(), errbuf, sizeof(errbuf)))); + pj_strerror(pj_get_netos_error(), errbuf, sizeof(errbuf)); + PJ_LOG(1,(THIS_FILE, "...ERROR: %s", errbuf)); if (ssock >= 0) pj_sock_close(ssock); if (csock >= 0) diff --git a/pjlib/src/pjlib-test/ioq_unreg.c b/pjlib/src/pjlib-test/ioq_unreg.c index 4e556823e..e0e55c0bd 100644 --- a/pjlib/src/pjlib-test/ioq_unreg.c +++ b/pjlib/src/pjlib-test/ioq_unreg.c @@ -296,7 +296,7 @@ static int perform_unreg_test(pj_ioqueue_t *ioqueue, pj_sock_close(sock_data.csock); - PJ_LOG(3,(THIS_FILE, "....%s: done (%d KB/s)", + PJ_LOG(3,(THIS_FILE, "....%s: done (%ld KB/s)", title, sock_data.received * 1000 / MSEC / 1000)); return 0; } diff --git a/pjlib/src/pjlib-test/pool.c b/pjlib/src/pjlib-test/pool.c index 4375cc695..897d7ee2f 100644 --- a/pjlib/src/pjlib-test/pool.c +++ b/pjlib/src/pjlib-test/pool.c @@ -68,7 +68,7 @@ static int capacity_test(void) freesize = GET_FREE(pool); if (pj_pool_alloc(pool, freesize) == NULL) { - PJ_LOG(3,("test", "...error: wrong freesize %u reported", + PJ_LOG(3,("test", "...error: wrong freesize %lu reported", freesize)); pj_pool_release(pool); return -210; @@ -175,7 +175,7 @@ static int drain_test(pj_size_t size, pj_size_t increment) void *p; int status = 0; - PJ_LOG(3,("test", "...drain_test(%d,%d)", size, increment)); + PJ_LOG(3,("test", "...drain_test(%lu,%lu)", size, increment)); if (!pool) return -10; @@ -207,7 +207,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=%u (expecting 0)", + PJ_LOG(3,("test", "....error: returned free=%lu (expecting 0)", GET_FREE(pool))); status=-30; goto on_error; } diff --git a/pjlib/src/pjlib-test/sleep.c b/pjlib/src/pjlib-test/sleep.c index 792e06bbe..59023f11b 100644 --- a/pjlib/src/pjlib-test/sleep.c +++ b/pjlib/src/pjlib-test/sleep.c @@ -202,7 +202,7 @@ static int sleep_duration_test(void) PJ_TIME_VAL_SUB(t2, t1); PJ_LOG(3,(THIS_FILE, "...info: gettimeofday() reported duration is " - "%d msec", + "%ld msec", PJ_TIME_VAL_MSEC(t2))); } } diff --git a/pjlib/src/pjlib-test/sock.c b/pjlib/src/pjlib-test/sock.c index 1064ab44a..b23c5ab3c 100644 --- a/pjlib/src/pjlib-test/sock.c +++ b/pjlib/src/pjlib-test/sock.c @@ -541,13 +541,13 @@ static int send_recv_test(int sock_type, rc = -155; goto on_error; } if (received <= 0) { - PJ_LOG(3,("", "...error: socket has closed! (received=%d)", + PJ_LOG(3,("", "...error: socket has closed! (received=%ld)", received)); rc = -156; goto on_error; } if (received != DATA_LEN-total_received) { if (sock_type != pj_SOCK_STREAM()) { - PJ_LOG(3,("", "...error: expecting %u bytes, got %u bytes", + PJ_LOG(3,("", "...error: expecting %lu bytes, got %lu bytes", DATA_LEN-total_received, received)); rc = -157; goto on_error; } @@ -599,13 +599,13 @@ static int send_recv_test(int sock_type, rc = -170; goto on_error; } if (received <= 0) { - PJ_LOG(3,("", "...error: socket has closed! (received=%d)", + PJ_LOG(3,("", "...error: socket has closed! (received=%ld)", received)); rc = -173; goto on_error; } if (received != BIG_DATA_LEN-total_received) { if (sock_type != pj_SOCK_STREAM()) { - PJ_LOG(3,("", "...error: expecting %u bytes, got %u bytes", + PJ_LOG(3,("", "...error: expecting %lu bytes, got %lu bytes", BIG_DATA_LEN-total_received, received)); rc = -176; goto on_error; } diff --git a/pjlib/src/pjlib-test/sock_perf.c b/pjlib/src/pjlib-test/sock_perf.c index d192f1db1..6949722dd 100644 --- a/pjlib/src/pjlib-test/sock_perf.c +++ b/pjlib/src/pjlib-test/sock_perf.c @@ -100,13 +100,13 @@ static int sock_producer_consumer(int sock_type, return -70; } if (part_received <= 0) { - PJ_LOG(3,("", "...error: socket has closed (part_received=%d)!", + PJ_LOG(3,("", "...error: socket has closed (part_received=%ld)!", part_received)); return -73; } if ((pj_size_t)part_received != buf_size-received) { if (sock_type != pj_SOCK_STREAM()) { - PJ_LOG(3,("", "...error: expecting %u bytes, got %u bytes", + PJ_LOG(3,("", "...error: expecting %lu bytes, got %lu bytes", buf_size-received, part_received)); return -76; } diff --git a/pjlib/src/pjlib-test/ssl_sock.c b/pjlib/src/pjlib-test/ssl_sock.c index 3cd68c142..bece11179 100644 --- a/pjlib/src/pjlib-test/ssl_sock.c +++ b/pjlib/src/pjlib-test/ssl_sock.c @@ -350,7 +350,7 @@ 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 %d bytes echo", buf, st->recv)); + PJ_LOG(3, ("", "...%s successfully recv %lu bytes echo", buf, st->recv)); st->done = PJ_TRUE; } } @@ -501,7 +501,7 @@ static int https_client_test(unsigned ms_timeout) } PJ_LOG(3, ("", "...Done!")); - PJ_LOG(3, ("", ".....Sent/recv: %d/%d bytes", state.sent, state.recv)); + PJ_LOG(3, ("", ".....Sent/recv: %lu/%lu bytes", state.sent, state.recv)); on_return: if (ssock && !state.err && !state.done) @@ -755,7 +755,7 @@ 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: %d/%d bytes", state_cli.sent, state_cli.recv)); + PJ_LOG(3, ("", ".....Sent/recv: %lu/%lu bytes", state_cli.sent, state_cli.recv)); on_return: #if (PJ_SSL_SOCK_IMP == PJ_SSL_SOCK_IMP_DARWIN) || \ @@ -1451,7 +1451,7 @@ static int perf_test(unsigned clients, unsigned ms_handshake_timeout) pj_gettimeofday(&stop); PJ_TIME_VAL_SUB(stop, start); - PJ_LOG(3, ("", ".....Setup & data transfer duration: %d.%03ds", stop.sec, stop.msec)); + PJ_LOG(3, ("", ".....Setup & data transfer duration: %ld.%03lds", stop.sec, stop.msec)); } /* Check clients status */ @@ -1464,7 +1464,7 @@ 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: %d/%d bytes", tot_sent, tot_recv)); + PJ_LOG(3, ("", ".....Total sent/recv: %lu/%lu bytes", tot_sent, tot_recv)); on_return: if (ssock_serv) diff --git a/pjlib/src/pjlib-test/timer.c b/pjlib/src/pjlib-test/timer.c index e307ca1fc..7a4a9d44a 100644 --- a/pjlib/src/pjlib-test/timer.c +++ b/pjlib/src/pjlib-test/timer.c @@ -67,7 +67,7 @@ static int test_timer_heap(void) size = pj_timer_heap_mem_size(MAX_COUNT)+MAX_COUNT*sizeof(pj_timer_entry); pool = pj_pool_create( mem, NULL, size, 4000, NULL); if (!pool) { - PJ_LOG(3,("test", "...error: unable to create pool of %u bytes", + PJ_LOG(3,("test", "...error: unable to create pool of %lu bytes", size)); return -10; } @@ -161,7 +161,7 @@ static int test_timer_heap(void) } while (PJ_TIME_VAL_LTE(now, expire)&&pj_timer_heap_count(timer) > 0); if (pj_timer_heap_count(timer)) { - PJ_LOG(3, (THIS_FILE, "ERROR: %d timers left", + PJ_LOG(3, (THIS_FILE, "ERROR: %ld timers left", pj_timer_heap_count(timer))); ++err; } @@ -715,7 +715,7 @@ on_return: if (timer) pj_timer_heap_destroy(timer); - PJ_LOG(3,("test", "Total memory of timer heap: %d", + PJ_LOG(3,("test", "Total memory of timer heap: %ld", pj_timer_heap_mem_size(ST_ENTRY_COUNT))); if (tparam.idx) diff --git a/pjlib/src/pjlib-test/timestamp.c b/pjlib/src/pjlib-test/timestamp.c index b07024072..e40fcb16c 100644 --- a/pjlib/src/pjlib-test/timestamp.c +++ b/pjlib/src/pjlib-test/timestamp.c @@ -90,7 +90,7 @@ static int timestamp_accuracy() PJ_LOG(3,(THIS_FILE, "....error: timestamp drifted by %d usec after " "%d msec", (pj_uint32_t)(diff * 1000000 / freq.u64), - msec)); + (int)msec)); return -2000; /* Otherwise just print warning if timestamp drifted by >1 usec */ @@ -98,7 +98,7 @@ static int timestamp_accuracy() PJ_LOG(3,(THIS_FILE, "....warning: timestamp drifted by %d usec after " "%d msec", (pj_uint32_t)(diff * 1000000 / freq.u64), - msec)); + (int)msec)); } else { PJ_LOG(3,(THIS_FILE, "....good. Timestamp is accurate down to" " nearest usec.")); @@ -125,7 +125,7 @@ int timestamp_test(void) return -1000; } - PJ_LOG(3,(THIS_FILE, "....frequency: hiword=%lu loword=%lu", + PJ_LOG(3,(THIS_FILE, "....frequency: hiword=%u loword=%u", freq.u32.hi, freq.u32.lo)); PJ_LOG(3,(THIS_FILE, "...checking if time can run backwards (pls wait)..")); diff --git a/pjsip/include/pjsip/sip_endpoint.h b/pjsip/include/pjsip/sip_endpoint.h index 620b23ee8..4a6228233 100644 --- a/pjsip/include/pjsip/sip_endpoint.h +++ b/pjsip/include/pjsip/sip_endpoint.h @@ -686,7 +686,8 @@ PJ_DECL(void) pjsip_endpt_log_error( pjsip_endpoint *endpt, const char *sender, pj_status_t error_code, const char *format, - ... ); + ... ) + PJ_PRINT_FUNC_DECOR(4); /** Internal */ #define PJSIP_ENDPT_LOG_ERROR(expr) \