commit
f29892c470
|
@ -0,0 +1,18 @@
|
|||
# Scheduled scan, only runs on master (see
|
||||
# https://stackoverflow.com/a/58800550)
|
||||
|
||||
name: "Coverity Scan (Daily)"
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 12 * * *' # Daily at 12:00 UTC
|
||||
|
||||
jobs:
|
||||
ubuntu-full-bundle:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: run.sh
|
||||
run: tests/coverity-scan/run.sh
|
||||
env:
|
||||
COV_TOKEN: ${{ secrets.PJSIP_COVERITY_SCAN_TOKEN }}
|
|
@ -0,0 +1,16 @@
|
|||
# This allows running coverity scan at any time and on any branch. Invoke this
|
||||
# action manually from https://github.com/pjsip/pjproject/actions
|
||||
|
||||
name: "Coverity Scan (Manual)"
|
||||
|
||||
on: [workflow_dispatch]
|
||||
|
||||
jobs:
|
||||
ubuntu-full-bundle:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: run.sh
|
||||
run: tests/coverity-scan/run.sh
|
||||
env:
|
||||
COV_TOKEN: ${{ secrets.PJSIP_COVERITY_SCAN_TOKEN }}
|
|
@ -2,6 +2,7 @@ pjlib/include/pj/config_site.h
|
|||
lib/
|
||||
bin/
|
||||
output/
|
||||
tmp/
|
||||
|
||||
# VS stuff
|
||||
*.ncb
|
||||
|
@ -80,3 +81,8 @@ tests/fuzz/*.o
|
|||
*/docs/xml/
|
||||
*/docs/latex/
|
||||
*/docs/*.tag
|
||||
|
||||
# Coverity scan stuff
|
||||
cov-int/
|
||||
getversion.mak
|
||||
configure.out
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
[![CI Windows](https://github.com/pjsip/pjproject/actions/workflows/ci-win.yml/badge.svg)](https://github.com/pjsip/pjproject/actions/workflows/ci-win.yml)
|
||||
<BR>
|
||||
[![OSS-Fuzz](https://oss-fuzz-build-logs.storage.googleapis.com/badges/pjsip.png)](https://oss-fuzz-build-logs.storage.googleapis.com/index.html#pjsip)
|
||||
[![Coverity-Scan](https://scan.coverity.com/projects/905/badge.svg)](https://scan.coverity.com/projects/pjsip)
|
||||
[![CodeQL](https://github.com/pjsip/pjproject/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/pjsip/pjproject/actions/workflows/codeql-analysis.yml)
|
||||
[![docs.pjsip.org](https://readthedocs.org/projects/pjsip/badge/?version=latest)](https://docs.pjsip.org/en/latest/)
|
||||
|
||||
|
|
|
@ -45,18 +45,20 @@ static char *sha1_test_results[] = {
|
|||
|
||||
|
||||
static void digest_to_hex(const pj_uint8_t digest[PJ_SHA1_DIGEST_SIZE],
|
||||
char *output)
|
||||
char *output, int output_size)
|
||||
{
|
||||
int i,j;
|
||||
char *c = output;
|
||||
|
||||
for (i = 0; i < PJ_SHA1_DIGEST_SIZE/4; i++) {
|
||||
for (j = 0; j < 4; j++) {
|
||||
sprintf(c,"%02X", digest[i*4+j] & 0xFF);
|
||||
for (i = 0; i < PJ_SHA1_DIGEST_SIZE/4 && output_size >= 2; i++) {
|
||||
for (j = 0; j < 4 && output_size >= 3; j++) {
|
||||
pj_ansi_snprintf(c, output_size, "%02X", digest[i*4+j] & 0xFF);
|
||||
c += 2;
|
||||
output_size -= 2;
|
||||
}
|
||||
sprintf(c, " ");
|
||||
pj_ansi_snprintf(c, output_size, " ");
|
||||
c += 1;
|
||||
output_size -= 1;
|
||||
}
|
||||
*(c - 1) = '\0';
|
||||
}
|
||||
|
@ -78,7 +80,7 @@ static int sha1_test1(void)
|
|||
pj_sha1_update(&context, (pj_uint8_t*)sha1_test_data[k],
|
||||
pj_ansi_strlen(sha1_test_data[k]));
|
||||
pj_sha1_final(&context, digest);
|
||||
digest_to_hex(digest, output);
|
||||
digest_to_hex(digest, output, sizeof(output));
|
||||
|
||||
if (pj_ansi_strcmp(output, sha1_test_results[k])) {
|
||||
PJ_LOG(3, (THIS_FILE, " incorrect hash result on k=%d", k));
|
||||
|
@ -91,7 +93,7 @@ static int sha1_test1(void)
|
|||
for (k = 0; k < MILLION; k++)
|
||||
pj_sha1_update(&context, (pj_uint8_t*)"a", 1);
|
||||
pj_sha1_final(&context, digest);
|
||||
digest_to_hex(digest, output);
|
||||
digest_to_hex(digest, output, sizeof(output));
|
||||
if (strcmp(output, sha1_test_results[2])) {
|
||||
PJ_LOG(3, (THIS_FILE, " incorrect hash result!"));
|
||||
return -20;
|
||||
|
@ -105,7 +107,7 @@ static int sha1_test1(void)
|
|||
pj_sha1_init(&context);
|
||||
pj_sha1_update(&context, block, MILLION);
|
||||
pj_sha1_final(&context, digest);
|
||||
digest_to_hex(digest, output);
|
||||
digest_to_hex(digest, output, sizeof(output));
|
||||
if (strcmp(output, sha1_test_results[2])) {
|
||||
pj_pool_release(pool);
|
||||
PJ_LOG(3, (THIS_FILE, " incorrect hash result for block update!"));
|
||||
|
@ -182,7 +184,7 @@ static int sha1_test2(void)
|
|||
|
||||
pj_sha1_final(&sha, digest);
|
||||
|
||||
digest_to_hex(digest, char_digest);
|
||||
digest_to_hex(digest, char_digest, sizeof(char_digest));
|
||||
if (pj_ansi_strcmp(char_digest, resultarray[i])) {
|
||||
PJ_LOG(3, (THIS_FILE, " digest mismatch in test %d", i));
|
||||
return -40;
|
||||
|
@ -664,6 +666,15 @@ static void crc32_final(pj_crc32_context *ctx, pj_uint32_t *digest)
|
|||
*digest = pj_crc32_final(ctx);
|
||||
}
|
||||
|
||||
/* pj_md5_update() has len argument in unsigned, while other xxx_update
|
||||
* are in pj_size_t, hence the wrapper
|
||||
*/
|
||||
static void md5_update_wrapper(pj_md5_context *ctx,
|
||||
unsigned char const *buf, pj_size_t len)
|
||||
{
|
||||
pj_md5_update(ctx, buf, len);
|
||||
}
|
||||
|
||||
int encryption_benchmark()
|
||||
{
|
||||
pj_pool_t *pool;
|
||||
|
@ -678,7 +689,7 @@ int encryption_benchmark()
|
|||
{
|
||||
const char *name;
|
||||
void (*init_context)(void*);
|
||||
void (*update)(void*, const pj_uint8_t*, unsigned);
|
||||
void (*update)(void*, const pj_uint8_t*, pj_size_t);
|
||||
void (*final)(void*, void*);
|
||||
pj_uint32_t t;
|
||||
} algorithms[] =
|
||||
|
@ -686,19 +697,19 @@ int encryption_benchmark()
|
|||
{
|
||||
"MD5 ",
|
||||
(void (*)(void*))&pj_md5_init,
|
||||
(void (*)(void*, const pj_uint8_t*, unsigned))&pj_md5_update,
|
||||
(void (*)(void*, const pj_uint8_t*, pj_size_t))&md5_update_wrapper,
|
||||
(void (*)(void*, void*))&pj_md5_final
|
||||
},
|
||||
{
|
||||
"SHA1 ",
|
||||
(void (*)(void*))&pj_sha1_init,
|
||||
(void (*)(void*, const pj_uint8_t*, unsigned))&pj_sha1_update,
|
||||
(void (*)(void*, const pj_uint8_t*, pj_size_t))&pj_sha1_update,
|
||||
(void (*)(void*, void*))&pj_sha1_final
|
||||
},
|
||||
{
|
||||
"CRC32",
|
||||
(void (*)(void*))&pj_crc32_init,
|
||||
(void (*)(void*, const pj_uint8_t*, unsigned))&crc32_update,
|
||||
(void (*)(void*, const pj_uint8_t*, pj_size_t))&crc32_update,
|
||||
(void (*)(void*, void*))&crc32_final
|
||||
}
|
||||
};
|
||||
|
|
|
@ -116,14 +116,24 @@ static int server_thread(void *p)
|
|||
} else if (srv->action == ACTION_REPLY) {
|
||||
pj_size_t send_len = 0;
|
||||
unsigned ctr = 0;
|
||||
pj_ansi_sprintf(pkt, "HTTP/1.0 200 OK\r\n");
|
||||
pkt_len = pj_ansi_snprintf(pkt, srv->buf_size,
|
||||
"HTTP/1.0 200 OK\r\n");
|
||||
PJ_ASSERT_ON_FAIL(pkt_len>0, {
|
||||
PJ_PERROR(2, (THIS_FILE, -pkt_len, "Error creating response"));
|
||||
pj_sock_close(newsock);
|
||||
continue;
|
||||
})
|
||||
if (srv->send_content_length) {
|
||||
pj_ansi_sprintf(pkt + pj_ansi_strlen(pkt),
|
||||
pj_ansi_snprintf(pkt + pkt_len, srv->buf_size - pkt_len,
|
||||
"Content-Length: %d\r\n",
|
||||
srv->data_size);
|
||||
}
|
||||
pj_ansi_sprintf(pkt + pj_ansi_strlen(pkt), "\r\n");
|
||||
pkt_len = pj_ansi_strlen(pkt);
|
||||
pkt_len = pj_ansi_strxcat(pkt, "\r\n", srv->buf_size);
|
||||
if (pkt_len < 0) {
|
||||
PJ_PERROR(2, (THIS_FILE, -pkt_len, "Error creating response"));
|
||||
pj_sock_close(newsock);
|
||||
continue;
|
||||
}
|
||||
rc = pj_sock_send(newsock, pkt, &pkt_len, 0);
|
||||
if (rc != PJ_SUCCESS) {
|
||||
pj_sock_close(newsock);
|
||||
|
@ -135,7 +145,7 @@ static int server_thread(void *p)
|
|||
pkt_len = srv->buf_size;
|
||||
send_len += pkt_len;
|
||||
pj_create_random_string(pkt, pkt_len);
|
||||
pj_ansi_sprintf(pkt, "\nPacket: %d", ++ctr);
|
||||
pj_ansi_snprintf(pkt, srv->buf_size, "\nPacket: %d", ++ctr);
|
||||
pkt[pj_ansi_strlen(pkt)] = '\n';
|
||||
rc = pj_sock_send(newsock, pkt, &pkt_len, 0);
|
||||
if (rc != PJ_SUCCESS)
|
||||
|
@ -153,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: %d bytes", size));
|
||||
PJ_LOG(5, (THIS_FILE, "\nData received: %ld bytes", size));
|
||||
if (size > 0) {
|
||||
#ifdef VERBOSE
|
||||
printf("%.*s\n", (int)size, (char *)data);
|
||||
|
@ -176,11 +186,11 @@ static void on_send_data(pj_http_req *hreq,
|
|||
|
||||
sdata = (char*)pj_pool_alloc(pool, sendsz);
|
||||
pj_create_random_string(sdata, sendsz);
|
||||
pj_ansi_sprintf(sdata, "\nSegment #%d\n", ++counter);
|
||||
pj_ansi_snprintf(sdata, sendsz, "\nSegment #%d\n", ++counter);
|
||||
*data = sdata;
|
||||
*size = sendsz;
|
||||
|
||||
PJ_LOG(5, (THIS_FILE, "\nSending data progress: %d out of %d bytes",
|
||||
PJ_LOG(5, (THIS_FILE, "\nSending data progress: %ld out of %ld bytes",
|
||||
send_size, total_size));
|
||||
}
|
||||
|
||||
|
@ -200,7 +210,7 @@ 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: %d bytes", resp->size));
|
||||
PJ_LOG(5, (THIS_FILE, "\nData completed: %ld bytes", resp->size));
|
||||
if (resp->size > 0 && resp->data) {
|
||||
#ifdef VERBOSE
|
||||
printf("%.*s\n", (int)resp->size, (char *)resp->data);
|
||||
|
@ -688,7 +698,7 @@ int http_client_test_put1()
|
|||
pj_strset2(¶m.method, (char*)"PUT");
|
||||
data = (char*)pj_pool_alloc(pool, length);
|
||||
pj_create_random_string(data, length);
|
||||
pj_ansi_sprintf(data, "PUT test\n");
|
||||
pj_ansi_snprintf(data, length, "PUT test\n");
|
||||
param.reqdata.data = data;
|
||||
param.reqdata.size = length;
|
||||
if (pj_http_req_create(pool, &url, timer_heap, ioqueue,
|
||||
|
|
|
@ -368,7 +368,7 @@ static int server_thread(void *p)
|
|||
continue;
|
||||
}
|
||||
|
||||
PJ_LOG(5,(THIS_FILE, "Server %d processing packet", srv - &g_server[0]));
|
||||
PJ_LOG(5,(THIS_FILE, "Server %ld processing packet", srv - &g_server[0]));
|
||||
srv->pkt_count++;
|
||||
|
||||
rc = pj_dns_parse_packet(pool, pkt, (unsigned)pkt_len, &req);
|
||||
|
@ -1797,7 +1797,7 @@ static void action3_1(const pj_dns_parsed_packet *pkt,
|
|||
res->ans[i].rdata.srv.port = (pj_uint16_t)(PORT3+i);
|
||||
|
||||
target = (char*)pj_pool_alloc(pool, 16);
|
||||
sprintf(target, "sip%02d." DOMAIN3, i);
|
||||
pj_ansi_snprintf(target, 16, "sip%02d." DOMAIN3, i);
|
||||
res->ans[i].rdata.srv.target = pj_str(target);
|
||||
}
|
||||
|
||||
|
|
|
@ -501,7 +501,7 @@ static pj_cli_cmd_spec *get_cmd_name(const pj_cli_t *cli,
|
|||
|
||||
if (group) {
|
||||
char cmd_str[MAX_CMD_ID_LENGTH];
|
||||
pj_ansi_sprintf(cmd_str, "%d", group->id);
|
||||
pj_ansi_snprintf(cmd_str, sizeof(cmd_str), "%d", group->id);
|
||||
pj_strcat2(&cmd_val, cmd_str);
|
||||
}
|
||||
pj_strcat(&cmd_val, cmd);
|
||||
|
@ -522,7 +522,7 @@ static void add_cmd_name(pj_cli_t *cli, pj_cli_cmd_spec *group,
|
|||
|
||||
if (group) {
|
||||
char cmd_str[MAX_CMD_ID_LENGTH];
|
||||
pj_ansi_sprintf(cmd_str, "%d", group->id);
|
||||
pj_ansi_snprintf(cmd_str, sizeof(cmd_str), "%d", group->id);
|
||||
pj_strcat2(&cmd_val, cmd_str);
|
||||
}
|
||||
pj_strcat(&cmd_val, cmd_name);
|
||||
|
|
|
@ -103,8 +103,8 @@ PJ_DEF(void) pj_cli_console_cfg_default(pj_cli_console_cfg *param)
|
|||
pj_assert(param);
|
||||
|
||||
param->log_level = PJ_CLI_CONSOLE_LOG_LEVEL;
|
||||
param->prompt_str.slen = 0;
|
||||
param->quit_command.slen = 0;
|
||||
pj_bzero(¶m->prompt_str, sizeof(pj_str_t));
|
||||
pj_bzero(¶m->quit_command, sizeof(pj_str_t));
|
||||
}
|
||||
|
||||
PJ_DEF(pj_status_t) pj_cli_console_create(pj_cli_t *cli,
|
||||
|
|
|
@ -1169,8 +1169,8 @@ static pj_bool_t handle_up_down(cli_telnet_sess *sess, pj_bool_t is_up)
|
|||
/* Send data */
|
||||
pj_strcat(&send_data, history);
|
||||
telnet_sess_send(sess, &send_data);
|
||||
pj_ansi_strncpy((char*)&sess->rcmd->rbuf, history->ptr, history->slen);
|
||||
sess->rcmd->rbuf[history->slen] = 0;
|
||||
pj_ansi_strxcpy2((char*)sess->rcmd->rbuf, history,
|
||||
sizeof(sess->rcmd->rbuf));
|
||||
sess->rcmd->len = (unsigned)history->slen;
|
||||
sess->rcmd->cur_pos = sess->rcmd->len;
|
||||
return PJ_TRUE;
|
||||
|
@ -1803,6 +1803,7 @@ static pj_status_t telnet_start(cli_telnet_fe *fe)
|
|||
unsigned msec;
|
||||
|
||||
/* Start telnet daemon */
|
||||
fe->asock = NULL;
|
||||
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0, &sock);
|
||||
|
||||
if (status != PJ_SUCCESS)
|
||||
|
|
|
@ -147,7 +147,7 @@ PJ_DEF(void) pj_dns_dump_packet(const pj_dns_parsed_packet *res)
|
|||
PJ_LOG(3,(THIS_FILE, " Nb of answer RR: %d", res->hdr.anscount));
|
||||
PJ_LOG(3,(THIS_FILE, " Nb of authority RR: %d", res->hdr.nscount));
|
||||
PJ_LOG(3,(THIS_FILE, " Nb of additional RR: %d", res->hdr.arcount));
|
||||
PJ_LOG(3,(THIS_FILE, ""));
|
||||
PJ_LOG(3,(THIS_FILE, " "));
|
||||
|
||||
/* Dump queries */
|
||||
if (res->hdr.qdcount) {
|
||||
|
@ -156,7 +156,7 @@ PJ_DEF(void) pj_dns_dump_packet(const pj_dns_parsed_packet *res)
|
|||
for (i=0; i<res->hdr.qdcount; ++i) {
|
||||
dump_query(i, &res->q[i]);
|
||||
}
|
||||
PJ_LOG(3,(THIS_FILE, ""));
|
||||
PJ_LOG(3,(THIS_FILE, " "));
|
||||
}
|
||||
|
||||
/* Dump answers */
|
||||
|
@ -166,7 +166,7 @@ PJ_DEF(void) pj_dns_dump_packet(const pj_dns_parsed_packet *res)
|
|||
for (i=0; i<res->hdr.anscount; ++i) {
|
||||
dump_answer(i, &res->ans[i]);
|
||||
}
|
||||
PJ_LOG(3,(THIS_FILE, ""));
|
||||
PJ_LOG(3,(THIS_FILE, " "));
|
||||
}
|
||||
|
||||
/* Dump NS sections */
|
||||
|
@ -176,7 +176,7 @@ PJ_DEF(void) pj_dns_dump_packet(const pj_dns_parsed_packet *res)
|
|||
for (i=0; i<res->hdr.nscount; ++i) {
|
||||
dump_answer(i, &res->ns[i]);
|
||||
}
|
||||
PJ_LOG(3,(THIS_FILE, ""));
|
||||
PJ_LOG(3,(THIS_FILE, " "));
|
||||
}
|
||||
|
||||
/* Dump Additional info sections */
|
||||
|
@ -186,7 +186,7 @@ PJ_DEF(void) pj_dns_dump_packet(const pj_dns_parsed_packet *res)
|
|||
for (i=0; i<res->hdr.arcount; ++i) {
|
||||
dump_answer(i, &res->arr[i]);
|
||||
}
|
||||
PJ_LOG(3,(THIS_FILE, ""));
|
||||
PJ_LOG(3,(THIS_FILE, " "));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1142,6 +1142,7 @@ static pj_status_t auth_respond_basic(pj_http_req *hreq)
|
|||
*/
|
||||
pj_str_t user_pass;
|
||||
pj_http_header_elmt *phdr;
|
||||
pj_status_t status;
|
||||
int len;
|
||||
|
||||
/* Use send buffer to store userid ":" password */
|
||||
|
@ -1164,8 +1165,10 @@ static pj_status_t auth_respond_basic(pj_http_req *hreq)
|
|||
|
||||
pj_strcpy2(&phdr->value, "Basic ");
|
||||
len -= (int)phdr->value.slen;
|
||||
pj_base64_encode((pj_uint8_t*)user_pass.ptr, (int)user_pass.slen,
|
||||
phdr->value.ptr + phdr->value.slen, &len);
|
||||
status = pj_base64_encode((pj_uint8_t*)user_pass.ptr, (int)user_pass.slen,
|
||||
phdr->value.ptr + phdr->value.slen, &len);
|
||||
if (status != PJ_SUCCESS)
|
||||
return status;
|
||||
phdr->value.slen += len;
|
||||
|
||||
return PJ_SUCCESS;
|
||||
|
|
|
@ -121,7 +121,7 @@ PJ_DEF(pj_status_t) pj_pcap_open(pj_pool_t *pool,
|
|||
|
||||
file = PJ_POOL_ZALLOC_T(pool, pj_pcap_file);
|
||||
|
||||
pj_ansi_strcpy(file->obj_name, "pcap");
|
||||
pj_ansi_strxcpy(file->obj_name, "pcap", sizeof(file->obj_name));
|
||||
|
||||
status = pj_file_open(pool, path, PJ_O_RDONLY, &file->fd);
|
||||
if (status != PJ_SUCCESS)
|
||||
|
|
|
@ -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=%d 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)));
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#endif
|
||||
|
||||
|
||||
/* coverity[+kill] */
|
||||
static void pj_scan_syntax_err(pj_scanner *scanner)
|
||||
{
|
||||
(*scanner->callback)(scanner);
|
||||
|
|
|
@ -456,7 +456,7 @@ static void build_server_entries(pj_dns_srv_async_query *query_job,
|
|||
pj_sockaddr_print(&query_job->srv[i].addr[0],
|
||||
addr, sizeof(addr), 2);
|
||||
} else
|
||||
pj_ansi_strcpy(addr, "-");
|
||||
pj_ansi_strxcpy(addr, "-", sizeof(addr));
|
||||
|
||||
PJ_LOG(5,(query_job->objname,
|
||||
" %d: SRV %d %d %d %.*s (%s)",
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -70,10 +70,10 @@
|
|||
*/
|
||||
//#if defined(PJ_ENABLE_EXTRA_CHECK) && PJ_ENABLE_EXTRA_CHECK != 0
|
||||
#define PJ_ASSERT_ON_FAIL(expr,exec_on_fail) \
|
||||
do { \
|
||||
{ \
|
||||
pj_assert(expr); \
|
||||
if (!(expr)) exec_on_fail; \
|
||||
} while (0)
|
||||
}
|
||||
//#else
|
||||
//# define PJ_ASSERT_ON_FAIL(expr,exec_on_fail) pj_assert(expr)
|
||||
//#endif
|
||||
|
|
|
@ -67,16 +67,40 @@
|
|||
#define pj_ansi_strcmp strcmp
|
||||
#define pj_ansi_strncmp strncmp
|
||||
#define pj_ansi_strlen strlen
|
||||
#define pj_ansi_strcpy strcpy
|
||||
#define pj_ansi_strncpy strncpy
|
||||
#define pj_ansi_strcat strcat
|
||||
#if defined(PJ_BAN_STRCPY) && PJ_BAN_STRCPY
|
||||
/* Use pj_ansi_strxcpy() instead */
|
||||
# define strcpy error__strcpy_is_banned
|
||||
# define pj_ansi_strcpy error__strcpy_is_banned
|
||||
#else
|
||||
# define pj_ansi_strcpy strcpy
|
||||
#endif
|
||||
#if defined(PJ_BAN_STRNCPY) && PJ_BAN_STRNCPY
|
||||
/* Use pj_ansi_strxcpy() instead */
|
||||
# define strncpy error__strncpy_is_banned
|
||||
# define pj_ansi_strncpy error__strncpy_is_banned
|
||||
#else
|
||||
# define pj_ansi_strncpy strncpy
|
||||
#endif
|
||||
#if defined(PJ_BAN_STRCAT) && PJ_BAN_STRCAT
|
||||
/* Use pj_ansi_strxcat() instead */
|
||||
# define strcat error__strcat_is_banned
|
||||
# define pj_ansi_strcat error__strcat_is_banned
|
||||
#else
|
||||
# define pj_ansi_strcat strcat
|
||||
#endif
|
||||
#define pj_ansi_strstr strstr
|
||||
#define pj_ansi_strchr strchr
|
||||
#define pj_ansi_strcasecmp strcasecmp
|
||||
#define pj_ansi_stricmp strcasecmp
|
||||
#define pj_ansi_strncasecmp strncasecmp
|
||||
#define pj_ansi_strnicmp strncasecmp
|
||||
#define pj_ansi_sprintf sprintf
|
||||
#if defined(PJ_BAN_SPRINTF) && PJ_BAN_SPRINTF
|
||||
/* Use pj_ansi_snprintf() instead */
|
||||
# define sprintf error__sprintf_is_banned
|
||||
# define pj_ansi_sprintf error__sprintf_is_banned
|
||||
#else
|
||||
# define pj_ansi_sprintf sprintf
|
||||
#endif
|
||||
|
||||
#if defined(PJ_HAS_NO_SNPRINTF) && PJ_HAS_NO_SNPRINTF != 0
|
||||
# include <pj/types.h>
|
||||
|
@ -88,7 +112,13 @@
|
|||
#endif
|
||||
|
||||
#define pj_ansi_snprintf snprintf
|
||||
#define pj_ansi_vsprintf vsprintf
|
||||
#if defined(PJ_BAN_VSPRINTF) && PJ_BAN_VSPRINTF
|
||||
/* Use pj_ansi_vsnprintf() instead */
|
||||
# define vsprintf error__vsprintf_is_banned
|
||||
# define pj_ansi_vsprintf error__vsprintf_is_banned
|
||||
#else
|
||||
# define pj_ansi_vsprintf vsprintf
|
||||
#endif
|
||||
#define pj_ansi_vsnprintf vsnprintf
|
||||
|
||||
#define pj_unicode_strcmp wcscmp
|
||||
|
|
|
@ -940,6 +940,54 @@
|
|||
# define PJ_HAS_STRICMP_ALNUM 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Prohibit the use of unsafe string functions such as strcpy(), strncpy(),
|
||||
* strcat(), and vsprintf().
|
||||
*/
|
||||
#ifndef PJ_BAN_UNSAFE_STR_FUNCS
|
||||
# define PJ_BAN_UNSAFE_STR_FUNCS 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Prohibit the use of strcpy() and pj_ansi_strcpy(), use pj_ansi_strxcpy()
|
||||
* instead.
|
||||
*/
|
||||
#ifndef PJ_BAN_STRCPY
|
||||
# define PJ_BAN_STRCPY PJ_BAN_UNSAFE_STR_FUNCS
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Prohibit the use of strncpy() and pj_ansi_strncpy(), use pj_ansi_strxcpy()
|
||||
* instead.
|
||||
*/
|
||||
#ifndef PJ_BAN_STRNCPY
|
||||
# define PJ_BAN_STRNCPY PJ_BAN_UNSAFE_STR_FUNCS
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Prohibit the use of strcat() and pj_ansi_strcat(), use pj_ansi_strxcat()
|
||||
* instead.
|
||||
*/
|
||||
#ifndef PJ_BAN_STRCAT
|
||||
# define PJ_BAN_STRCAT PJ_BAN_UNSAFE_STR_FUNCS
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Prohibit the use of sprintf() and pj_ansi_sprintf(),
|
||||
* use pj_ansi_snprintf() instead.
|
||||
*/
|
||||
#ifndef PJ_BAN_SPRINTF
|
||||
# define PJ_BAN_SPRINTF PJ_BAN_UNSAFE_STR_FUNCS
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Prohibit the use of vsprintf() and pj_ansi_vsprintf(),
|
||||
* use pj_ansi_vsnprintf() instead.
|
||||
*/
|
||||
#ifndef PJ_BAN_VSPRINTF
|
||||
# define PJ_BAN_VSPRINTF PJ_BAN_UNSAFE_STR_FUNCS
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Warn about obsolete macros.
|
||||
*
|
||||
|
|
|
@ -199,7 +199,8 @@ PJ_DECL(pj_str_t) pj_strerror( pj_status_t statcode,
|
|||
* @see PJ_PERROR()
|
||||
*/
|
||||
PJ_DECL(void) pj_perror(int log_level, const char *sender, pj_status_t status,
|
||||
const char *title_fmt, ...);
|
||||
const char *title_fmt, ...)
|
||||
PJ_PRINT_FUNC_DECOR(4);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -497,7 +498,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 +514,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 +530,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 +546,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 +562,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 +578,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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -78,7 +78,7 @@ PJ_BEGIN_DECL
|
|||
* @param len The length of the string buffer.
|
||||
*/
|
||||
#define PJ_CHECK_TRUNC_STR(ret, str, len) \
|
||||
if ((int)(ret) >= (int)(len) || (ret) < 0) pj_ansi_strcpy((str) + (len) - 3, "..")
|
||||
if ((int)(ret) >= (int)(len) || (ret) < 0) pj_ansi_strxcpy((str) + (len) - 3, "..", 3)
|
||||
|
||||
/**
|
||||
* Create string initializer from a normal C string.
|
||||
|
@ -840,6 +840,58 @@ PJ_INLINE(void*) pj_memchr(const void *buf, int c, pj_size_t size)
|
|||
return (void*)memchr((void*)buf, c, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the string, or as much of it as fits, into the dest buffer.
|
||||
* Regardless of whether all characters were copied, the destination
|
||||
* buffer will be null terminated, unless dst_size is zero which in
|
||||
* this case nothing will be written to dst and the function will
|
||||
* return -PJ_ETOOBIG.
|
||||
*
|
||||
* @param dst The destination string.
|
||||
* @param src The source string.
|
||||
* @param dst_size The full size of the destination string buffer.
|
||||
*
|
||||
* @return The number of characters copied (not including the trailing NUL) or
|
||||
* -PJ_ETOOBIG if the destination buffer wasn't big enough,
|
||||
* -PJ_EINVAL if the dst or src is NULL.
|
||||
*/
|
||||
PJ_DECL(int) pj_ansi_strxcpy(char *dst, const char *src, pj_size_t dst_size);
|
||||
|
||||
|
||||
/**
|
||||
* Same as pj_ansi_strxcpy() but takes pj_str_t as the source.
|
||||
* If src contains null character, copying will stop at the first null
|
||||
* character in src.
|
||||
*
|
||||
* @param dst The destination string.
|
||||
* @param src The source string.
|
||||
* @param dst_size The full size of the destination string buffer.
|
||||
*
|
||||
* @return The number of characters copied (not including the trailing NUL) or
|
||||
* -PJ_ETOOBIG if the destination buffer wasn't big enough,
|
||||
* -PJ_EINVAL if the dst or src is NULL.
|
||||
*/
|
||||
PJ_DECL(int) pj_ansi_strxcpy2(char *dst, const pj_str_t *src,
|
||||
pj_size_t dst_size);
|
||||
|
||||
|
||||
/**
|
||||
* Concatenate src, or as much of it as fits, into the dest buffer.
|
||||
* Regardless of whether all characters were copied, the destination
|
||||
* buffer will be null terminated, unless dst_size is zero which in
|
||||
* this case nothing will be written to dst and the function will
|
||||
* return -PJ_ETOOBIG.
|
||||
*
|
||||
* @param dst The destination string.
|
||||
* @param src The source string.
|
||||
* @param dst_size The full size of the destination string buffer.
|
||||
*
|
||||
* @return Final length of dst string (not including the trailing NUL) or
|
||||
* -PJ_ETOOBIG if the destination buffer wasn't big enough,
|
||||
* -PJ_EINVAL if the dst or src is NULL.
|
||||
*/
|
||||
PJ_DECL(int) pj_ansi_strxcat(char *dst, const char *src, pj_size_t dst_size);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -146,7 +146,8 @@ PJ_DEF(pj_status_t) pj_getaddrinfo(int af, const pj_str_t *nodename,
|
|||
continue;
|
||||
|
||||
/* Store canonical name */
|
||||
pj_ansi_strcpy(ai[i].ai_canonname, nodecopy);
|
||||
pj_ansi_strxcpy(ai[i].ai_canonname, nodecopy,
|
||||
sizeof(ai[i].ai_canonname));
|
||||
|
||||
/* Store address */
|
||||
addr_size = sizeof(*addr);
|
||||
|
@ -220,11 +221,11 @@ PJ_DEF(pj_status_t) pj_getaddrinfo(int af, const pj_str_t *nodename,
|
|||
|
||||
/* Store canonical name (possibly truncating the name) */
|
||||
if (res->ai_canonname) {
|
||||
pj_ansi_strncpy(ai[i].ai_canonname, res->ai_canonname,
|
||||
pj_ansi_strxcpy(ai[i].ai_canonname, res->ai_canonname,
|
||||
sizeof(ai[i].ai_canonname));
|
||||
ai[i].ai_canonname[sizeof(ai[i].ai_canonname)-1] = '\0';
|
||||
} else {
|
||||
pj_ansi_strcpy(ai[i].ai_canonname, nodecopy);
|
||||
pj_ansi_strxcpy(ai[i].ai_canonname, nodecopy,
|
||||
sizeof(ai[i].ai_canonname));
|
||||
}
|
||||
|
||||
/* Store address */
|
||||
|
@ -303,9 +304,8 @@ PJ_DEF(pj_status_t) pj_getaddrinfo(int af, const pj_str_t *nodename,
|
|||
pj_bzero(ai, max_count * sizeof(pj_addrinfo));
|
||||
|
||||
for (i=0; he.h_addr_list[i] && *count<max_count; ++i) {
|
||||
pj_ansi_strncpy(ai[*count].ai_canonname, he.h_name,
|
||||
pj_ansi_strxcpy(ai[*count].ai_canonname, he.h_name,
|
||||
sizeof(ai[*count].ai_canonname));
|
||||
ai[*count].ai_canonname[sizeof(ai[*count].ai_canonname)-1] = '\0';
|
||||
|
||||
ai[*count].ai_addr.ipv4.sin_family = PJ_AF_INET;
|
||||
pj_memcpy(&ai[*count].ai_addr.ipv4.sin_addr,
|
||||
|
|
|
@ -84,5 +84,7 @@ PJ_DEF(void) pj_dump_config(void)
|
|||
PJ_LOG(3, (id, " PJ_OS_HAS_CHECK_STACK : %d", PJ_OS_HAS_CHECK_STACK));
|
||||
PJ_LOG(3, (id, " PJ_HAS_HIGH_RES_TIMER : %d", PJ_HAS_HIGH_RES_TIMER));
|
||||
PJ_LOG(3, (id, " PJ_HAS_IPV6 : %d", PJ_HAS_IPV6));
|
||||
PJ_LOG(3, (id, " PJ_HAS_SSL_SOCK : %d", PJ_HAS_SSL_SOCK));
|
||||
PJ_LOG(3, (id, " PJ_SSL_SOCK_IMP : %d", PJ_SSL_SOCK_IMP));
|
||||
}
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ static void pj_perror_imp(int log_level, const char *sender,
|
|||
/* Build the title */
|
||||
len = pj_ansi_vsnprintf(titlebuf, sizeof(titlebuf), title_fmt, marker);
|
||||
if (len < 0 || len >= (int)sizeof(titlebuf))
|
||||
pj_ansi_strcpy(titlebuf, "Error");
|
||||
pj_ansi_strxcpy(titlebuf, "Error", sizeof(titlebuf));
|
||||
|
||||
/* Get the error */
|
||||
pj_strerror(status, errmsg, sizeof(errmsg));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -306,7 +306,7 @@ static pj_status_t if_enum_by_af(int af, unsigned *p_cnt, pj_sockaddr ifs[])
|
|||
struct sockaddr *ad;
|
||||
int rc;
|
||||
|
||||
strncpy(ifreq.ifr_name, if_list[i].if_name, IFNAMSIZ);
|
||||
pj_ansi_strxcpy(ifreq.ifr_name, if_list[i].if_name, IFNAMSIZ);
|
||||
|
||||
TRACE_((THIS_FILE, " checking interface %s", ifreq.ifr_name));
|
||||
|
||||
|
@ -480,7 +480,7 @@ static pj_status_t get_ipv6_deprecated(unsigned *count, pj_sockaddr addr[])
|
|||
} netlink_req;
|
||||
|
||||
long pagesize = sysconf(_SC_PAGESIZE);
|
||||
if (!pagesize)
|
||||
if (pagesize <= 0)
|
||||
pagesize = 4096; /* Assume pagesize is 4096 if sysconf() failed */
|
||||
|
||||
int fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
|
||||
|
@ -496,8 +496,10 @@ static pj_status_t get_ipv6_deprecated(unsigned *count, pj_sockaddr addr[])
|
|||
netlink_req.ifaddrmsg_info.ifa_family = AF_INET6;
|
||||
|
||||
int rtn = send(fd, &netlink_req, netlink_req.nlmsg_info.nlmsg_len, 0);
|
||||
if (rtn < 0)
|
||||
if (rtn < 0) {
|
||||
close(fd);
|
||||
return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
|
||||
}
|
||||
|
||||
char read_buffer[pagesize];
|
||||
size_t idx = 0;
|
||||
|
@ -505,14 +507,18 @@ static pj_status_t get_ipv6_deprecated(unsigned *count, pj_sockaddr addr[])
|
|||
while(1) {
|
||||
bzero(read_buffer, pagesize);
|
||||
int read_size = recv(fd, read_buffer, pagesize, 0);
|
||||
if (read_size < 0)
|
||||
if (read_size < 0) {
|
||||
close(fd);
|
||||
return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
|
||||
}
|
||||
|
||||
struct nlmsghdr *nlmsg_ptr = (struct nlmsghdr *) read_buffer;
|
||||
int nlmsg_len = read_size;
|
||||
|
||||
if (nlmsg_len < (int)sizeof(struct nlmsghdr))
|
||||
if (nlmsg_len < (int)sizeof (struct nlmsghdr)) {
|
||||
close(fd);
|
||||
return PJ_ETOOSMALL;
|
||||
}
|
||||
|
||||
if (nlmsg_ptr->nlmsg_type == NLMSG_DONE)
|
||||
break;
|
||||
|
|
|
@ -151,14 +151,17 @@ pj_status_t pj_log_init(void)
|
|||
if (thread_suspended_tls_id == -1) {
|
||||
pj_status_t status;
|
||||
status = pj_thread_local_alloc(&thread_suspended_tls_id);
|
||||
if (status != PJ_SUCCESS)
|
||||
if (status != PJ_SUCCESS) {
|
||||
thread_suspended_tls_id = -1;
|
||||
return status;
|
||||
}
|
||||
|
||||
# if PJ_LOG_ENABLE_INDENT
|
||||
status = pj_thread_local_alloc(&thread_indent_tls_id);
|
||||
if (status != PJ_SUCCESS) {
|
||||
pj_thread_local_free(thread_suspended_tls_id);
|
||||
thread_suspended_tls_id = -1;
|
||||
thread_indent_tls_id = -1;
|
||||
return status;
|
||||
}
|
||||
# endif
|
||||
|
@ -365,13 +368,13 @@ PJ_DEF(void) pj_log( const char *sender, int level,
|
|||
if (log_decor & PJ_LOG_HAS_LEVEL_TEXT) {
|
||||
static const char *ltexts[] = { "FATAL:", "ERROR:", " WARN:",
|
||||
" INFO:", "DEBUG:", "TRACE:", "DETRC:"};
|
||||
pj_ansi_strcpy(pre, ltexts[level]);
|
||||
pj_ansi_strxcpy(pre, ltexts[level], PJ_LOG_MAX_SIZE);
|
||||
pre += 6;
|
||||
}
|
||||
if (log_decor & PJ_LOG_HAS_DAY_NAME) {
|
||||
static const char *wdays[] = { "Sun", "Mon", "Tue", "Wed",
|
||||
"Thu", "Fri", "Sat"};
|
||||
pj_ansi_strcpy(pre, wdays[ptime.wday]);
|
||||
pj_ansi_strxcpy(pre, wdays[ptime.wday], PJ_LOG_MAX_SIZE-6);
|
||||
pre += 3;
|
||||
}
|
||||
if (log_decor & PJ_LOG_HAS_YEAR) {
|
||||
|
|
|
@ -341,7 +341,8 @@ PJ_DEF(pj_status_t) pj_init(void)
|
|||
return PJ_SUCCESS;
|
||||
}
|
||||
|
||||
pj_ansi_strcpy(main_thread.obj_name, "pjthread");
|
||||
pj_ansi_strxcpy(main_thread.obj_name, "pjthread",
|
||||
sizeof(main_thread.obj_name));
|
||||
|
||||
// Init main thread
|
||||
pj_memset(&main_thread, 0, sizeof(main_thread));
|
||||
|
|
|
@ -631,7 +631,8 @@ static void set_thread_display_name(const char *name)
|
|||
char xname[16];
|
||||
// On linux, thread display name length is restricted to 16 (include '\0')
|
||||
if (pj_ansi_strlen(name) >= 16) {
|
||||
pj_ansi_snprintf(xname, 16, "%s", name);
|
||||
pj_memcpy(xname, name, 15);
|
||||
xname[15] = '\0';
|
||||
name = xname;
|
||||
}
|
||||
#endif
|
||||
|
@ -724,8 +725,7 @@ PJ_DEF(pj_status_t) pj_thread_create( pj_pool_t *pool,
|
|||
if (strchr(thread_name, '%')) {
|
||||
pj_ansi_snprintf(rec->obj_name, PJ_MAX_OBJ_NAME, thread_name, rec);
|
||||
} else {
|
||||
strncpy(rec->obj_name, thread_name, PJ_MAX_OBJ_NAME);
|
||||
rec->obj_name[PJ_MAX_OBJ_NAME-1] = '\0';
|
||||
pj_ansi_strxcpy(rec->obj_name, thread_name, PJ_MAX_OBJ_NAME);
|
||||
}
|
||||
|
||||
/* Set default stack size */
|
||||
|
@ -1351,8 +1351,7 @@ static pj_status_t init_mutex(pj_mutex_t *mutex, const char *name, int type)
|
|||
if (strchr(name, '%')) {
|
||||
pj_ansi_snprintf(mutex->obj_name, PJ_MAX_OBJ_NAME, name, mutex);
|
||||
} else {
|
||||
strncpy(mutex->obj_name, name, PJ_MAX_OBJ_NAME);
|
||||
mutex->obj_name[PJ_MAX_OBJ_NAME-1] = '\0';
|
||||
pj_ansi_strxcpy(mutex->obj_name, name, PJ_MAX_OBJ_NAME);
|
||||
}
|
||||
|
||||
PJ_LOG(6, (mutex->obj_name, "Mutex created"));
|
||||
|
@ -1436,7 +1435,8 @@ PJ_DEF(pj_status_t) pj_mutex_lock(pj_mutex_t *mutex)
|
|||
#if PJ_DEBUG
|
||||
if (status == PJ_SUCCESS) {
|
||||
mutex->owner = pj_thread_this();
|
||||
pj_ansi_strcpy(mutex->owner_name, mutex->owner->obj_name);
|
||||
pj_ansi_strxcpy(mutex->owner_name, mutex->owner->obj_name,
|
||||
sizeof(mutex->owner_name));
|
||||
++mutex->nesting_level;
|
||||
}
|
||||
|
||||
|
@ -1519,7 +1519,8 @@ PJ_DEF(pj_status_t) pj_mutex_trylock(pj_mutex_t *mutex)
|
|||
if (status==0) {
|
||||
#if PJ_DEBUG
|
||||
mutex->owner = pj_thread_this();
|
||||
pj_ansi_strcpy(mutex->owner_name, mutex->owner->obj_name);
|
||||
pj_ansi_strxcpy(mutex->owner_name, mutex->owner->obj_name,
|
||||
sizeof(mutex->owner_name));
|
||||
++mutex->nesting_level;
|
||||
|
||||
PJ_LOG(6,(mutex->obj_name, "Mutex acquired by thread %s (level=%d)",
|
||||
|
@ -1771,8 +1772,7 @@ PJ_DEF(pj_status_t) pj_sem_create( pj_pool_t *pool,
|
|||
if (strchr(name, '%')) {
|
||||
pj_ansi_snprintf(sem->obj_name, PJ_MAX_OBJ_NAME, name, sem);
|
||||
} else {
|
||||
strncpy(sem->obj_name, name, PJ_MAX_OBJ_NAME);
|
||||
sem->obj_name[PJ_MAX_OBJ_NAME-1] = '\0';
|
||||
pj_ansi_strxcpy(sem->obj_name, name, PJ_MAX_OBJ_NAME);
|
||||
}
|
||||
|
||||
PJ_LOG(6, (sem->obj_name, "Semaphore created"));
|
||||
|
@ -2082,45 +2082,45 @@ PJ_DEF(pj_status_t) pj_term_set_color(pj_color_t color)
|
|||
if (color & PJ_TERM_COLOR_BRIGHT) {
|
||||
color ^= PJ_TERM_COLOR_BRIGHT;
|
||||
} else {
|
||||
strcpy(ansi_color, "\033[00;3");
|
||||
pj_ansi_strxcpy(ansi_color, "\033[00;3", sizeof(ansi_color));
|
||||
}
|
||||
|
||||
switch (color) {
|
||||
case 0:
|
||||
/* black color */
|
||||
strcat(ansi_color, "0m");
|
||||
pj_ansi_strxcat(ansi_color, "0m", sizeof(ansi_color));
|
||||
break;
|
||||
case PJ_TERM_COLOR_R:
|
||||
/* red color */
|
||||
strcat(ansi_color, "1m");
|
||||
pj_ansi_strxcat(ansi_color, "1m", sizeof(ansi_color));
|
||||
break;
|
||||
case PJ_TERM_COLOR_G:
|
||||
/* green color */
|
||||
strcat(ansi_color, "2m");
|
||||
pj_ansi_strxcat(ansi_color, "2m", sizeof(ansi_color));
|
||||
break;
|
||||
case PJ_TERM_COLOR_B:
|
||||
/* blue color */
|
||||
strcat(ansi_color, "4m");
|
||||
pj_ansi_strxcat(ansi_color, "4m", sizeof(ansi_color));
|
||||
break;
|
||||
case PJ_TERM_COLOR_R | PJ_TERM_COLOR_G:
|
||||
/* yellow color */
|
||||
strcat(ansi_color, "3m");
|
||||
pj_ansi_strxcat(ansi_color, "3m", sizeof(ansi_color));
|
||||
break;
|
||||
case PJ_TERM_COLOR_R | PJ_TERM_COLOR_B:
|
||||
/* magenta color */
|
||||
strcat(ansi_color, "5m");
|
||||
pj_ansi_strxcat(ansi_color, "5m", sizeof(ansi_color));
|
||||
break;
|
||||
case PJ_TERM_COLOR_G | PJ_TERM_COLOR_B:
|
||||
/* cyan color */
|
||||
strcat(ansi_color, "6m");
|
||||
pj_ansi_strxcat(ansi_color, "6m", sizeof(ansi_color));
|
||||
break;
|
||||
case PJ_TERM_COLOR_R | PJ_TERM_COLOR_G | PJ_TERM_COLOR_B:
|
||||
/* white color */
|
||||
strcat(ansi_color, "7m");
|
||||
pj_ansi_strxcat(ansi_color, "7m", sizeof(ansi_color));
|
||||
break;
|
||||
default:
|
||||
/* default console color */
|
||||
strcpy(ansi_color, "\033[00m");
|
||||
pj_ansi_strxcpy(ansi_color, "\033[00m", sizeof(ansi_color));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -581,8 +581,7 @@ PJ_DEF(pj_status_t) pj_thread_create( pj_pool_t *pool,
|
|||
if (strchr(thread_name, '%')) {
|
||||
pj_ansi_snprintf(rec->obj_name, PJ_MAX_OBJ_NAME, thread_name, rec);
|
||||
} else {
|
||||
pj_ansi_strncpy(rec->obj_name, thread_name, PJ_MAX_OBJ_NAME);
|
||||
rec->obj_name[PJ_MAX_OBJ_NAME-1] = '\0';
|
||||
pj_ansi_strxcpy(rec->obj_name, thread_name, PJ_MAX_OBJ_NAME);
|
||||
}
|
||||
|
||||
PJ_LOG(6, (rec->obj_name, "Thread created"));
|
||||
|
@ -919,6 +918,7 @@ PJ_DEF(pj_atomic_value_t) pj_atomic_add_and_get( pj_atomic_t *atomic_var,
|
|||
*/
|
||||
PJ_DEF(pj_status_t) pj_thread_local_alloc(long *index)
|
||||
{
|
||||
DWORD tls_index;
|
||||
PJ_ASSERT_RETURN(index != NULL, PJ_EINVAL);
|
||||
|
||||
//Can't check stack because this function is called in the
|
||||
|
@ -926,15 +926,17 @@ PJ_DEF(pj_status_t) pj_thread_local_alloc(long *index)
|
|||
//PJ_CHECK_STACK();
|
||||
|
||||
#if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8
|
||||
*index = TlsAllocRT();
|
||||
tls_index = TlsAllocRT();
|
||||
#else
|
||||
*index = TlsAlloc();
|
||||
tls_index = TlsAlloc();
|
||||
#endif
|
||||
|
||||
if (*index == TLS_OUT_OF_INDEXES)
|
||||
if (tls_index == TLS_OUT_OF_INDEXES)
|
||||
return PJ_RETURN_OS_ERROR(GetLastError());
|
||||
else
|
||||
else {
|
||||
*index = (long)tls_index;
|
||||
return PJ_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1015,8 +1017,7 @@ static pj_status_t init_mutex(pj_mutex_t *mutex, const char *name)
|
|||
if (strchr(name, '%')) {
|
||||
pj_ansi_snprintf(mutex->obj_name, PJ_MAX_OBJ_NAME, name, mutex);
|
||||
} else {
|
||||
pj_ansi_strncpy(mutex->obj_name, name, PJ_MAX_OBJ_NAME);
|
||||
mutex->obj_name[PJ_MAX_OBJ_NAME-1] = '\0';
|
||||
pj_ansi_strxcpy(mutex->obj_name, name, PJ_MAX_OBJ_NAME);
|
||||
}
|
||||
|
||||
PJ_LOG(6, (mutex->obj_name, "Mutex created"));
|
||||
|
@ -1266,8 +1267,7 @@ PJ_DEF(pj_status_t) pj_sem_create( pj_pool_t *pool,
|
|||
if (strchr(name, '%')) {
|
||||
pj_ansi_snprintf(sem->obj_name, PJ_MAX_OBJ_NAME, name, sem);
|
||||
} else {
|
||||
pj_ansi_strncpy(sem->obj_name, name, PJ_MAX_OBJ_NAME);
|
||||
sem->obj_name[PJ_MAX_OBJ_NAME-1] = '\0';
|
||||
pj_ansi_strxcpy(sem->obj_name, name, PJ_MAX_OBJ_NAME);
|
||||
}
|
||||
|
||||
LOG_MUTEX((sem->obj_name, "Semaphore created"));
|
||||
|
@ -1407,8 +1407,7 @@ PJ_DEF(pj_status_t) pj_event_create( pj_pool_t *pool,
|
|||
if (strchr(name, '%')) {
|
||||
pj_ansi_snprintf(event->obj_name, PJ_MAX_OBJ_NAME, name, event);
|
||||
} else {
|
||||
pj_ansi_strncpy(event->obj_name, name, PJ_MAX_OBJ_NAME);
|
||||
event->obj_name[PJ_MAX_OBJ_NAME-1] = '\0';
|
||||
pj_ansi_strxcpy(event->obj_name, name, PJ_MAX_OBJ_NAME);
|
||||
}
|
||||
|
||||
PJ_LOG(6, (event->obj_name, "Event created"));
|
||||
|
|
|
@ -70,26 +70,26 @@
|
|||
#endif
|
||||
|
||||
|
||||
static char *ver_info(pj_uint32_t ver, char *buf)
|
||||
static char *ver_info(pj_uint32_t ver, char *buf, unsigned buf_size)
|
||||
{
|
||||
pj_size_t len;
|
||||
|
||||
if (ver == 0) {
|
||||
*buf = '\0';
|
||||
return buf;
|
||||
}
|
||||
|
||||
sprintf(buf, "-%u.%u",
|
||||
pj_ansi_snprintf(buf, buf_size, "-%u.%u",
|
||||
(ver & 0xFF000000) >> 24,
|
||||
(ver & 0x00FF0000) >> 16);
|
||||
len = strlen(buf);
|
||||
|
||||
if (ver & 0xFFFF) {
|
||||
sprintf(buf+len, ".%u", (ver & 0xFF00) >> 8);
|
||||
len = strlen(buf);
|
||||
char tmp[20];
|
||||
|
||||
pj_ansi_snprintf(tmp, sizeof(tmp), ".%u", (ver & 0xFF00) >> 8);
|
||||
pj_ansi_strxcat(buf, tmp, buf_size);
|
||||
|
||||
if (ver & 0x00FF) {
|
||||
sprintf(buf+len, ".%u", (ver & 0xFF));
|
||||
pj_ansi_snprintf(tmp, sizeof(tmp), ".%u", (ver & 0xFF));
|
||||
pj_ansi_strxcat(buf, tmp, buf_size);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,12 +330,12 @@ get_sdk_info:
|
|||
cnt = pj_ansi_snprintf(tmp, sizeof(tmp),
|
||||
"%s%s%s%s%s%s%s",
|
||||
si.os_name.ptr,
|
||||
ver_info(si.os_ver, os_ver),
|
||||
ver_info(si.os_ver, os_ver, sizeof(os_ver)),
|
||||
(si.machine.slen ? "/" : ""),
|
||||
si.machine.ptr,
|
||||
(si.sdk_name.slen ? "/" : ""),
|
||||
si.sdk_name.ptr,
|
||||
ver_info(si.sdk_ver, sdk_ver));
|
||||
ver_info(si.sdk_ver, sdk_ver, sizeof(sdk_ver)));
|
||||
if (cnt > 0 && cnt < (int)sizeof(tmp)) {
|
||||
ALLOC_CP_STR(tmp, info);
|
||||
}
|
||||
|
|
|
@ -177,8 +177,7 @@ PJ_DEF(void) pj_pool_init_int( pj_pool_t *pool,
|
|||
pj_ansi_snprintf(pool->obj_name, sizeof(pool->obj_name),
|
||||
name, pool);
|
||||
} else {
|
||||
pj_ansi_strncpy(pool->obj_name, name, PJ_MAX_OBJ_NAME);
|
||||
pool->obj_name[PJ_MAX_OBJ_NAME-1] = '\0';
|
||||
pj_ansi_strxcpy(pool->obj_name, name, PJ_MAX_OBJ_NAME);
|
||||
}
|
||||
} else {
|
||||
pool->obj_name[0] = '\0';
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <pj/pool.h>
|
||||
#include <pj/assert.h>
|
||||
#include <pj/log.h>
|
||||
#include <pj/string.h>
|
||||
#include <pj/assert.h>
|
||||
|
@ -55,6 +56,7 @@ PJ_DEF(void) pj_caching_pool_init( pj_caching_pool *cp,
|
|||
{
|
||||
int i;
|
||||
pj_pool_t *pool;
|
||||
pj_status_t status;
|
||||
|
||||
PJ_CHECK_STACK();
|
||||
|
||||
|
@ -77,7 +79,10 @@ PJ_DEF(void) pj_caching_pool_init( pj_caching_pool *cp,
|
|||
cp->factory.on_block_free = &cpool_on_block_free;
|
||||
|
||||
pool = pj_pool_create_on_buf("cachingpool", cp->pool_buf, sizeof(cp->pool_buf));
|
||||
pj_lock_create_simple_mutex(pool, "cachingpool", &cp->lock);
|
||||
status = pj_lock_create_simple_mutex(pool, "cachingpool", &cp->lock);
|
||||
/* This mostly serves to silent coverity warning about unchecked
|
||||
* return value. There's not much we can do if it fails. */
|
||||
PJ_ASSERT_ON_FAIL(status==PJ_SUCCESS, return);
|
||||
}
|
||||
|
||||
PJ_DEF(void) pj_caching_pool_destroy( pj_caching_pool *cp )
|
||||
|
@ -274,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;
|
||||
|
@ -295,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),
|
||||
|
@ -317,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));
|
||||
}
|
||||
|
|
|
@ -72,10 +72,9 @@ PJ_DEF(pj_pool_t*) pj_pool_create_imp( const char *file, int line,
|
|||
return NULL;
|
||||
|
||||
if (name) {
|
||||
pj_ansi_strncpy(pool->obj_name, name, sizeof(pool->obj_name));
|
||||
pool->obj_name[sizeof(pool->obj_name)-1] = '\0';
|
||||
pj_ansi_strxcpy(pool->obj_name, name, sizeof(pool->obj_name));
|
||||
} else {
|
||||
strcpy(pool->obj_name, "altpool");
|
||||
pj_ansi_strxcpy(pool->obj_name, "altpool", sizeof(pool->obj_name));
|
||||
}
|
||||
|
||||
pool->factory = NULL;
|
||||
|
@ -171,7 +170,8 @@ PJ_DEF(void*) pj_pool_alloc_imp( const char *file, int line,
|
|||
#ifdef TRACE_
|
||||
{
|
||||
char msg[120];
|
||||
pj_ansi_sprintf(msg, "Mem %X (%d+%d bytes) allocated by %s:%d\r\n",
|
||||
pj_ansi_snprintf(msg, sizeof(msg),
|
||||
"Mem %X (%d+%d bytes) allocated by %s:%d\r\n",
|
||||
mem, sz, sizeof(struct pj_pool_mem),
|
||||
file, line);
|
||||
TRACE_(msg);
|
||||
|
|
|
@ -205,7 +205,7 @@ PJ_DEF(pj_status_t) pj_sockaddr_in_init( pj_sockaddr_in *addr,
|
|||
const pj_str_t *str_addr,
|
||||
pj_uint16_t port)
|
||||
{
|
||||
PJ_ASSERT_RETURN(addr, (addr->sin_addr.s_addr=PJ_INADDR_NONE, PJ_EINVAL));
|
||||
PJ_ASSERT_RETURN(addr, PJ_EINVAL);
|
||||
|
||||
PJ_SOCKADDR_RESET_LEN(addr);
|
||||
addr->sin_family = PJ_AF_INET;
|
||||
|
|
|
@ -180,7 +180,7 @@ static pj_str_t tls_strerror(pj_status_t status,
|
|||
|
||||
#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING != 0)
|
||||
if (tmp) {
|
||||
pj_ansi_strncpy(buf, tmp, bufsize);
|
||||
pj_ansi_strxcpy(buf, tmp, bufsize);
|
||||
errstr = pj_str(buf);
|
||||
return errstr;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
@ -736,7 +736,7 @@ static pj_bool_t ssock_on_data_read (pj_ssl_sock_t *ssock,
|
|||
}
|
||||
|
||||
/* See if there is any decrypted data for the application */
|
||||
if (ssock->read_started) {
|
||||
if (data && ssock->read_started) {
|
||||
do {
|
||||
read_data_t *buf = *(OFFSET_OF_READ_DATA_PTR(ssock, data));
|
||||
void *data_ = (pj_int8_t*)buf->data + buf->len;
|
||||
|
@ -745,17 +745,12 @@ static pj_bool_t ssock_on_data_read (pj_ssl_sock_t *ssock,
|
|||
|
||||
status_ = ssl_read(ssock, data_, &size_);
|
||||
|
||||
if (size_ > 0 || status != PJ_SUCCESS) {
|
||||
if (size_ > 0) {
|
||||
if (ssock->param.cb.on_data_read) {
|
||||
pj_bool_t ret;
|
||||
pj_size_t remainder_ = 0;
|
||||
|
||||
if (size_ > 0)
|
||||
buf->len += size_;
|
||||
|
||||
if (status != PJ_SUCCESS) {
|
||||
ssock->ssl_state = SSL_STATE_ERROR;
|
||||
}
|
||||
buf->len += size_;
|
||||
|
||||
ret = (*ssock->param.cb.on_data_read)(ssock, buf->data,
|
||||
buf->len, status,
|
||||
|
@ -775,10 +770,13 @@ static pj_bool_t ssock_on_data_read (pj_ssl_sock_t *ssock,
|
|||
* been signalled to the application along with any remaining
|
||||
* buffer. So, let's just reset SSL socket now.
|
||||
*/
|
||||
/*
|
||||
// This has been handled in on_error
|
||||
if (status != PJ_SUCCESS) {
|
||||
ssl_reset_sock_state(ssock);
|
||||
return PJ_FALSE;
|
||||
}
|
||||
*/
|
||||
|
||||
} else if (status_ == PJ_SUCCESS) {
|
||||
break;
|
||||
|
|
|
@ -191,7 +191,7 @@ static void update_certs_info(pj_ssl_sock_t* ssock,
|
|||
# ifdef _MSC_VER
|
||||
# define strerror_r(err,buf,len) strerror_s(buf,len,err)
|
||||
# else
|
||||
# define strerror_r(err,buf,len) pj_ansi_strncpy(buf,strerror(err),len)
|
||||
# define strerror_r(err,buf,len) pj_ansi_strxcpy(buf,strerror(err),len)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ static pj_str_t ssl_strerror(pj_status_t status,
|
|||
const char *tmp = NULL;
|
||||
tmp = ERR_reason_error_string(ssl_err);
|
||||
if (tmp) {
|
||||
pj_ansi_strncpy(buf, tmp, bufsize);
|
||||
pj_ansi_strxcpy(buf, tmp, bufsize);
|
||||
errstr = pj_str(buf);
|
||||
return errstr;
|
||||
}
|
||||
|
@ -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,14 +2365,14 @@ 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",
|
||||
SSL_session_reused(ossock->ossl_ssl),
|
||||
"timeout=%ld",
|
||||
(int)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",
|
||||
SSL_session_reused(ossock->ossl_ssl),
|
||||
"timeout=%ld",
|
||||
(int)SSL_session_reused(ossock->ossl_ssl),
|
||||
-1,
|
||||
SSL_SESSION_get_timeout(sess)));
|
||||
#endif
|
||||
|
@ -2381,14 +2381,14 @@ static pj_status_t ssl_do_handshake(pj_ssl_sock_t *ssock)
|
|||
len *= 2;
|
||||
if (len >= BUF_SIZE) len = BUF_SIZE;
|
||||
for (i = 0; i < len; i+=2)
|
||||
pj_ansi_sprintf(buf+i, "%02X", sid[i/2]);
|
||||
pj_ansi_snprintf(buf+i, sizeof(buf)-i, "%02X", sid[i/2]);
|
||||
buf[len] = '\0';
|
||||
PJ_LOG(5, (THIS_FILE, "Session id: %s", buf));
|
||||
|
||||
sctx = SSL_SESSION_get0_id_context(sess, &len);
|
||||
if (len >= BUF_SIZE) len = BUF_SIZE;
|
||||
for (i = 0; i < len; i++)
|
||||
pj_ansi_sprintf(buf + i, "%d", sctx[i]);
|
||||
pj_ansi_snprintf(buf + i, sizeof(buf)-i, "%d", sctx[i]);
|
||||
buf[len] = '\0';
|
||||
PJ_LOG(5, (THIS_FILE, "Session id context: %s", buf));
|
||||
}
|
||||
|
|
|
@ -275,11 +275,10 @@ PJ_DEF(pj_status_t) pj_strtol2(const pj_str_t *str, long *value)
|
|||
|
||||
PJ_CHECK_STACK();
|
||||
|
||||
PJ_ASSERT_RETURN(str->slen >= 0, PJ_EINVAL);
|
||||
|
||||
if (!str || !value) {
|
||||
return PJ_EINVAL;
|
||||
}
|
||||
PJ_ASSERT_RETURN(str->slen >= 0, PJ_EINVAL);
|
||||
|
||||
s = *str;
|
||||
pj_strltrim(&s);
|
||||
|
@ -380,12 +379,11 @@ PJ_DEF(pj_status_t) pj_strtoul3(const pj_str_t *str, unsigned long *value,
|
|||
|
||||
PJ_CHECK_STACK();
|
||||
|
||||
PJ_ASSERT_RETURN(str->slen >= 0, PJ_EINVAL);
|
||||
|
||||
if (!str || !value) {
|
||||
return PJ_EINVAL;
|
||||
}
|
||||
|
||||
PJ_ASSERT_RETURN(str->slen >= 0, PJ_EINVAL);
|
||||
|
||||
s = *str;
|
||||
pj_strltrim(&s);
|
||||
|
||||
|
@ -515,3 +513,71 @@ PJ_DEF(int) pj_utoa_pad( unsigned long val, char *buf, int min_dig, int pad)
|
|||
|
||||
return len;
|
||||
}
|
||||
|
||||
PJ_DEF(int) pj_ansi_strxcpy(char *dst, const char *src,
|
||||
pj_size_t dst_size)
|
||||
{
|
||||
char *odst = dst;
|
||||
|
||||
PJ_ASSERT_RETURN(dst && src, -PJ_EINVAL);
|
||||
|
||||
if (dst_size==0)
|
||||
return -PJ_ETOOBIG;
|
||||
|
||||
while (--dst_size && (*dst=*src) != 0) {
|
||||
++dst;
|
||||
++src;
|
||||
}
|
||||
|
||||
if (!*dst && !*src) {
|
||||
return dst-odst;
|
||||
} else {
|
||||
*dst = '\0';
|
||||
return *src? -PJ_ETOOBIG : dst-odst;
|
||||
}
|
||||
}
|
||||
|
||||
PJ_DEF(int) pj_ansi_strxcpy2(char *dst, const pj_str_t *src,
|
||||
pj_size_t dst_size)
|
||||
{
|
||||
char *odst = dst;
|
||||
const char *ssrc, *esrc;
|
||||
|
||||
PJ_ASSERT_RETURN(dst && src && src->slen >= 0, -PJ_EINVAL);
|
||||
if (dst_size==0)
|
||||
return -PJ_ETOOBIG;
|
||||
|
||||
ssrc = src->ptr;
|
||||
esrc = ssrc + src->slen;
|
||||
|
||||
while (ssrc < esrc && --dst_size && (*dst = *ssrc)!= 0) {
|
||||
dst++;
|
||||
ssrc++;
|
||||
}
|
||||
|
||||
*dst = '\0';
|
||||
if (ssrc==esrc || !*ssrc) {
|
||||
return dst-odst;
|
||||
} else {
|
||||
return -PJ_ETOOBIG;
|
||||
}
|
||||
}
|
||||
|
||||
PJ_DEF(int) pj_ansi_strxcat(char *dst, const char *src, pj_size_t dst_size)
|
||||
{
|
||||
pj_size_t dst_len;
|
||||
|
||||
PJ_ASSERT_RETURN(dst && src, -PJ_EINVAL);
|
||||
|
||||
if (dst_size==0)
|
||||
return -PJ_ETOOBIG;
|
||||
|
||||
dst_len = pj_ansi_strlen(dst);
|
||||
if (dst_len < dst_size) {
|
||||
int rc = pj_ansi_strxcpy(dst+dst_len, src, dst_size-dst_len);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
return dst_len + rc;
|
||||
} else
|
||||
return -PJ_ETOOBIG;
|
||||
}
|
||||
|
|
|
@ -327,6 +327,9 @@ PJ_EXPORT_SYMBOL(pj_create_random_string)
|
|||
PJ_EXPORT_SYMBOL(pj_strtoul)
|
||||
PJ_EXPORT_SYMBOL(pj_utoa)
|
||||
PJ_EXPORT_SYMBOL(pj_utoa_pad)
|
||||
PJ_EXPORT_SYMBOL(pj_ansi_strxcpy)
|
||||
PJ_EXPORT_SYMBOL(pj_ansi_strxcpy2)
|
||||
PJ_EXPORT_SYMBOL(pj_ansi_strxcat)
|
||||
|
||||
/*
|
||||
* timer.h
|
||||
|
|
|
@ -98,7 +98,6 @@ static pj_status_t udp_echo_srv_create(pj_pool_t *pool,
|
|||
struct udp_echo_srv **p_srv)
|
||||
{
|
||||
struct udp_echo_srv *srv;
|
||||
pj_sock_t sock_fd = PJ_INVALID_SOCKET;
|
||||
pj_sockaddr addr;
|
||||
pj_activesock_cb activesock_cb;
|
||||
pj_status_t status;
|
||||
|
@ -114,7 +113,6 @@ static pj_status_t udp_echo_srv_create(pj_pool_t *pool,
|
|||
status = pj_activesock_create_udp(pool, &addr, NULL, ioqueue, &activesock_cb,
|
||||
srv, &srv->asock, &addr);
|
||||
if (status != PJ_SUCCESS) {
|
||||
pj_sock_close(sock_fd);
|
||||
udp_echo_err("pj_activesock_create()", status);
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
@ -728,8 +728,10 @@ static int perform_test(test_desc *test)
|
|||
on_return:
|
||||
if (test->state.ioq)
|
||||
pj_ioqueue_destroy(test->state.ioq);
|
||||
pj_grp_lock_dec_ref(test->state.grp_lock);
|
||||
test->state.grp_lock = NULL;
|
||||
if (test->state.grp_lock) {
|
||||
pj_grp_lock_dec_ref(test->state.grp_lock);
|
||||
test->state.grp_lock = NULL;
|
||||
}
|
||||
if (test->state.pool)
|
||||
pj_pool_release(test->state.pool);
|
||||
|
||||
|
|
|
@ -452,7 +452,7 @@ static int unregister_test(const pj_ioqueue_cfg *cfg)
|
|||
addr.sin_addr = pj_inet_addr2("127.0.0.1");
|
||||
|
||||
/* Init buffer to send */
|
||||
pj_ansi_strcpy(sendbuf, "Hello0123");
|
||||
pj_ansi_strxcpy(sendbuf, "Hello0123", sizeof(sendbuf));
|
||||
|
||||
/* Send one packet. */
|
||||
bytes = sizeof(sendbuf);
|
||||
|
@ -1151,11 +1151,11 @@ 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))));
|
||||
if (ssock)
|
||||
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)
|
||||
if (csock >= 0)
|
||||
pj_sock_close(csock);
|
||||
for (i=0; i<inactive_sock_count && inactive_sock &&
|
||||
inactive_sock[i]!=PJ_INVALID_SOCKET; ++i)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ static int udp_ioqueue_unreg_test_imp(pj_bool_t allow_concur)
|
|||
PJ_LOG(3, (THIS_FILE, "...ioqueue unregister stress test 0/3, unregister in app (%s)",
|
||||
pj_ioqueue_name()));
|
||||
for (i=0; i<LOOP; ++i) {
|
||||
pj_ansi_sprintf(title, "repeat %d/%d", i, LOOP);
|
||||
pj_ansi_snprintf(title, sizeof(title), "repeat %d/%d", i, LOOP);
|
||||
rc = perform_unreg_test(ioqueue, test_pool, title, 0);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
@ -340,7 +340,7 @@ static int udp_ioqueue_unreg_test_imp(pj_bool_t allow_concur)
|
|||
PJ_LOG(3, (THIS_FILE, "...ioqueue unregister stress test 1/3, unregister in app (%s)",
|
||||
pj_ioqueue_name()));
|
||||
for (i=0; i<LOOP; ++i) {
|
||||
pj_ansi_sprintf(title, "repeat %d/%d", i, LOOP);
|
||||
pj_ansi_snprintf(title, sizeof(title), "repeat %d/%d", i, LOOP);
|
||||
rc = perform_unreg_test(ioqueue, test_pool, title, 1);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
@ -351,7 +351,7 @@ static int udp_ioqueue_unreg_test_imp(pj_bool_t allow_concur)
|
|||
PJ_LOG(3, (THIS_FILE, "...ioqueue unregister stress test 2/3, unregister in cb (%s)",
|
||||
pj_ioqueue_name()));
|
||||
for (i=0; i<LOOP; ++i) {
|
||||
pj_ansi_sprintf(title, "repeat %d/%d", i, LOOP);
|
||||
pj_ansi_snprintf(title, sizeof(title), "repeat %d/%d", i, LOOP);
|
||||
rc = perform_unreg_test(ioqueue, test_pool, title, 0);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
@ -361,7 +361,7 @@ static int udp_ioqueue_unreg_test_imp(pj_bool_t allow_concur)
|
|||
PJ_LOG(3, (THIS_FILE, "...ioqueue unregister stress test 3/3, unregister in cb (%s)",
|
||||
pj_ioqueue_name()));
|
||||
for (i=0; i<LOOP; ++i) {
|
||||
pj_ansi_sprintf(title, "repeat %d/%d", i, LOOP);
|
||||
pj_ansi_snprintf(title, sizeof(title), "repeat %d/%d", i, LOOP);
|
||||
rc = perform_unreg_test(ioqueue, test_pool, title, 1);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -122,6 +122,10 @@ static int sleep_duration_test(void)
|
|||
|
||||
/* Mark end of test. */
|
||||
rc = pj_gettimeofday(&stop);
|
||||
if (rc != PJ_SUCCESS) {
|
||||
app_perror("...error: pj_gettimeofday()", rc);
|
||||
return -22;
|
||||
}
|
||||
|
||||
/* Calculate duration (store in stop). */
|
||||
PJ_TIME_VAL_SUB(stop, start);
|
||||
|
@ -198,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)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,6 +160,11 @@ static int format_test(void)
|
|||
|
||||
#endif /* PJ_HAS_IPV6 */
|
||||
|
||||
#ifdef NDEBUG
|
||||
/* This should not crash */
|
||||
pj_sockaddr_in_init(NULL, 0, 1000);
|
||||
#endif
|
||||
|
||||
/* Test that pj_sockaddr_in_init() initialize the whole structure,
|
||||
* including sin_zero_pad.
|
||||
*/
|
||||
|
@ -512,8 +517,10 @@ static int send_recv_test(int sock_type,
|
|||
return -151;
|
||||
if (pj_sockaddr_cmp(&addr, srcaddr) != 0) {
|
||||
char srcaddr_str[32], addr_str[32];
|
||||
strcpy(srcaddr_str, pj_inet_ntoa(srcaddr->sin_addr));
|
||||
strcpy(addr_str, pj_inet_ntoa(addr.sin_addr));
|
||||
pj_ansi_strxcpy(srcaddr_str, pj_inet_ntoa(srcaddr->sin_addr),
|
||||
sizeof(srcaddr_str));
|
||||
pj_ansi_strxcpy(addr_str, pj_inet_ntoa(addr.sin_addr),
|
||||
sizeof(addr_str));
|
||||
PJ_LOG(3,("test", "...error: src address mismatch (original=%s, "
|
||||
"recvfrom addr=%s)",
|
||||
srcaddr_str, addr_str));
|
||||
|
@ -534,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;
|
||||
}
|
||||
|
@ -592,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;
|
||||
}
|
||||
|
@ -634,8 +641,9 @@ static int udp_test(void)
|
|||
}
|
||||
|
||||
rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &cs);
|
||||
if (rc != 0)
|
||||
return -110;
|
||||
if (rc != 0) {
|
||||
rc = -110; goto on_error;
|
||||
}
|
||||
|
||||
/* Bind server socket. */
|
||||
pj_bzero(&dstaddr, sizeof(dstaddr));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) || \
|
||||
|
@ -1207,8 +1207,11 @@ static int server_non_ssl(unsigned ms_timeout)
|
|||
PJ_LOG(3, ("", "...Done!"));
|
||||
|
||||
on_return:
|
||||
if (asock_serv)
|
||||
if (asock_serv) {
|
||||
pj_activesock_close(asock_serv);
|
||||
} else if (sock != PJ_INVALID_SOCKET) {
|
||||
pj_sock_close(sock);
|
||||
}
|
||||
if (ssock_cli && !state_cli.err && !state_cli.done)
|
||||
pj_ssl_sock_close(ssock_cli);
|
||||
if (timer)
|
||||
|
@ -1448,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 */
|
||||
|
@ -1461,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)
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <pj/string.h>
|
||||
#include <pj/assert.h>
|
||||
#include <pj/errno.h>
|
||||
#include <pj/pool.h>
|
||||
#include <pj/log.h>
|
||||
#include <pj/os.h>
|
||||
|
@ -289,6 +291,339 @@ static int strcmp_test(void)
|
|||
#undef STR_TEST
|
||||
}
|
||||
|
||||
static int verify_strxcpy(const char *src, int dst_size, int exp_ret,
|
||||
const char *exp_dst)
|
||||
{
|
||||
char dst[6];
|
||||
const char GUARDS[2] = {'@', '\0'};
|
||||
int i, ig, ret;
|
||||
|
||||
PJ_ASSERT_RETURN(src && dst_size <= 5, -700);
|
||||
|
||||
for (ig=0; ig<(int)sizeof(GUARDS); ++ig) {
|
||||
char GUARD = GUARDS[ig];
|
||||
|
||||
memset(dst, GUARD, sizeof(dst));
|
||||
|
||||
ret = pj_ansi_strxcpy(dst, src, dst_size);
|
||||
|
||||
/* verify return value */
|
||||
if (ret != exp_ret) {
|
||||
PJ_LOG(3,("", " strxcpy \"%s\", dst_size=%d: ret %d != %d",
|
||||
src, dst_size, ret, exp_ret));
|
||||
return -704;
|
||||
}
|
||||
|
||||
/* expected dst content */
|
||||
if (exp_dst) {
|
||||
if (strcmp(dst, exp_dst)) {
|
||||
PJ_LOG(3,("", " strxcpy \"%s\", dst_size=%d: "
|
||||
"dst content mismatch: \"%s\"!=\"%s\"",
|
||||
src, dst_size, dst, exp_dst));
|
||||
return -708;
|
||||
}
|
||||
}
|
||||
|
||||
/* verify not writing pass buffer */
|
||||
for (i=exp_dst?strlen(exp_dst)+1:0; i<(int)sizeof(dst); ++i) {
|
||||
if (dst[i] != GUARD) {
|
||||
PJ_LOG(3,("", " strxcpy \"%s\", dst_size=%d: overflow at %d",
|
||||
src, dst_size, i));
|
||||
return -710;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int strxcpy_test(void)
|
||||
{
|
||||
int rc;
|
||||
#define CHECK_(src, dst_size, exp_ret, exp_dst) \
|
||||
rc = verify_strxcpy(src, dst_size, exp_ret, exp_dst); \
|
||||
if (rc) return rc
|
||||
|
||||
CHECK_( "", 0, -PJ_ETOOBIG, NULL);
|
||||
CHECK_( "a", 0, -PJ_ETOOBIG, NULL);
|
||||
|
||||
{
|
||||
/* special test 1 (dst contains null) */
|
||||
char dst[4];
|
||||
pj_bzero(dst, sizeof(dst));
|
||||
rc = pj_ansi_strxcpy(dst, "a", 1);
|
||||
if (rc != -PJ_ETOOBIG) {
|
||||
PJ_LOG(3,("", " pj_ansi_strxcpy special test 1: ret %d!=%d",
|
||||
rc, -PJ_ETOOBIG));
|
||||
return -700;
|
||||
}
|
||||
}
|
||||
|
||||
CHECK_( "", 1, 0, "");
|
||||
CHECK_( "a", 1, -PJ_ETOOBIG, "");
|
||||
CHECK_( "ab", 1, -PJ_ETOOBIG, "");
|
||||
CHECK_( "abcd", 1, -PJ_ETOOBIG, "");
|
||||
|
||||
CHECK_( "abc", 2, -PJ_ETOOBIG, "a");
|
||||
CHECK_( "ab", 2, -PJ_ETOOBIG, "a");
|
||||
CHECK_( "a", 2, 1, "a");
|
||||
CHECK_( "", 2, 0, "");
|
||||
|
||||
CHECK_( "abcd", 3, -PJ_ETOOBIG, "ab");
|
||||
CHECK_( "abc", 3, -PJ_ETOOBIG, "ab");
|
||||
CHECK_( "ab", 3, 2, "ab");
|
||||
CHECK_( "a", 3, 1, "a");
|
||||
CHECK_( "", 3, 0, "");
|
||||
|
||||
CHECK_( "abcde", 4, -PJ_ETOOBIG, "abc");
|
||||
CHECK_( "abcd", 4, -PJ_ETOOBIG, "abc");
|
||||
CHECK_( "abc", 4, 3, "abc");
|
||||
CHECK_( "ab", 4, 2, "ab");
|
||||
CHECK_( "a", 4, 1, "a");
|
||||
CHECK_( "", 4, 0, "");
|
||||
|
||||
CHECK_( "abcdef", 5, -PJ_ETOOBIG, "abcd");
|
||||
CHECK_( "abcde", 5, -PJ_ETOOBIG, "abcd");
|
||||
CHECK_( "abcd", 5, 4, "abcd");
|
||||
CHECK_( "abc", 5, 3, "abc");
|
||||
CHECK_( "ab", 5, 2, "ab");
|
||||
CHECK_( "a", 5, 1, "a");
|
||||
CHECK_( "", 5, 0, "");
|
||||
|
||||
#undef CHECK_
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int verify_strxcpy2(const pj_str_t *src, int dst_size, int exp_ret,
|
||||
const char *exp_dst)
|
||||
{
|
||||
char dst[6];
|
||||
const char GUARDS[2] = {'@', '\0'};
|
||||
int i, ret, ig;
|
||||
|
||||
PJ_ASSERT_RETURN(src && dst_size <= 5, -720);
|
||||
|
||||
for (ig=0; ig<(int)sizeof(GUARDS); ++ig) {
|
||||
char GUARD = GUARDS[ig];
|
||||
|
||||
memset(dst, GUARD, sizeof(dst));
|
||||
|
||||
ret = pj_ansi_strxcpy2(dst, src, dst_size);
|
||||
|
||||
/* verify return value */
|
||||
if (ret != exp_ret) {
|
||||
PJ_LOG(3,("", " strxcpy2 \"%.*s\" slen=%ld, dst_size=%d: "
|
||||
"ret %d!=%d",
|
||||
(int)src->slen, src->ptr, src->slen, dst_size,
|
||||
ret, exp_ret));
|
||||
return -724;
|
||||
}
|
||||
|
||||
/* expected dst content */
|
||||
if (exp_dst) {
|
||||
if (strcmp(dst, exp_dst)) {
|
||||
PJ_LOG(3,("", " strxcpy2 \"%.*s\" slen=%ld, dst_size=%d: "
|
||||
"dst content mismatch: \"%s\"!=\"%s\"",
|
||||
(int)src->slen, src->ptr, src->slen, dst_size, dst,
|
||||
exp_dst));
|
||||
return -726;
|
||||
}
|
||||
}
|
||||
|
||||
/* verify not writing pass buffer */
|
||||
for (i=dst_size; i<(int)sizeof(dst); ++i) {
|
||||
if (dst[i] != GUARD) {
|
||||
PJ_LOG(3,("", " strxcpy2 \"%.*s\" slen=%ld, dst_size=%d: "
|
||||
"overflow at %d (chr %d)",
|
||||
(int)src->slen, src->ptr, src->slen, dst_size, i,
|
||||
(char)(dst[i] & 0xFF)));
|
||||
return -728;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int strxcpy2_test(void)
|
||||
{
|
||||
pj_str_t src;
|
||||
char nulls[6];
|
||||
int rc;
|
||||
|
||||
pj_bzero(nulls, sizeof(nulls));
|
||||
|
||||
#define CHECK2_(s, src_len, dst_size, exp_ret, exp_dst) \
|
||||
src.ptr = s; src.slen = src_len; \
|
||||
rc = verify_strxcpy2(&src, dst_size, exp_ret, exp_dst); \
|
||||
if (rc) return rc
|
||||
|
||||
CHECK2_( NULL, 0, 0, -PJ_ETOOBIG, NULL);
|
||||
CHECK2_( "a!", 1, 0, -PJ_ETOOBIG, NULL);
|
||||
|
||||
CHECK2_( "abc!", 3, 1, -PJ_ETOOBIG, "");
|
||||
CHECK2_( "ab!", 2, 1, -PJ_ETOOBIG, "");
|
||||
|
||||
/* note for test below: although src contains null and the strlen
|
||||
of result (i.e. dst) is zero, strxcpy2 would still return
|
||||
-PJ_ETOOBIG because the required buffer size is assumed to
|
||||
be 2 (one for the src->ptr content (although the content is a
|
||||
null character), one for the null terminator)
|
||||
*/
|
||||
CHECK2_( nulls, 1, 1, 0, "");
|
||||
CHECK2_( "a!", 1, 1, -PJ_ETOOBIG, "");
|
||||
CHECK2_( "a", 1, 1, -PJ_ETOOBIG, "");
|
||||
CHECK2_( "", 0, 1, 0, "");
|
||||
CHECK2_( NULL, 0, 1, 0, "");
|
||||
|
||||
CHECK2_( "abc", 3, 2, -PJ_ETOOBIG, "a");
|
||||
CHECK2_( "ab", 2, 2, -PJ_ETOOBIG, "a");
|
||||
CHECK2_( "a!", 1, 2, 1, "a");
|
||||
CHECK2_( nulls, 1, 2, 0, "");
|
||||
CHECK2_( "!", 0, 2, 0, "");
|
||||
CHECK2_( NULL, 0, 2, 0, "");
|
||||
|
||||
CHECK2_( "abc", 3, 3, -PJ_ETOOBIG, "ab");
|
||||
CHECK2_( "ab", 3, 3, 2, "ab");
|
||||
CHECK2_( nulls, 3, 3, 0, "");
|
||||
CHECK2_( "abc", 2, 3, 2, "ab");
|
||||
CHECK2_( "ab", 2, 3, 2, "ab");
|
||||
CHECK2_( "a", 2, 3, 1, "a");
|
||||
CHECK2_( nulls, 2, 3, 0, "");
|
||||
CHECK2_( "a", 1, 3, 1, "a");
|
||||
CHECK2_( "", 1, 3, 0, "");
|
||||
CHECK2_( "", 0, 3, 0, "");
|
||||
CHECK2_( NULL, 0, 3, 0, "");
|
||||
|
||||
CHECK2_( "abcde",5, 4, -PJ_ETOOBIG, "abc");
|
||||
CHECK2_( "abcd", 4, 4, -PJ_ETOOBIG, "abc");
|
||||
CHECK2_( "abc", 4, 4, 3, "abc");
|
||||
CHECK2_( "ab", 4, 4, 2, "ab");
|
||||
CHECK2_( "a", 4, 4, 1, "a");
|
||||
CHECK2_( nulls, 4, 4, 0, "");
|
||||
CHECK2_( "abc", 3, 4, 3, "abc");
|
||||
CHECK2_( "ab", 3, 4, 2, "ab");
|
||||
CHECK2_( "ab", 2, 4, 2, "ab");
|
||||
CHECK2_( "a", 2, 4, 1, "a");
|
||||
CHECK2_( "", 2, 4, 0, "");
|
||||
CHECK2_( nulls, 2, 4, 0, "");
|
||||
CHECK2_( "a", 1, 4, 1, "a");
|
||||
CHECK2_( nulls, 1, 4, 0, "");
|
||||
CHECK2_( "a", 0, 4, 0, "");
|
||||
CHECK2_( "", 0, 4, 0, "");
|
||||
CHECK2_( NULL, 0, 4, 0, "");
|
||||
|
||||
#undef CHECK2_
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int verify_strxcat(const char *cdst, const char *src, int dst_size,
|
||||
int exp_ret, const char *exp_dst)
|
||||
{
|
||||
char dst[6];
|
||||
const char GUARDS[2] = {'@', '\0'};
|
||||
int i, ret, ig;
|
||||
|
||||
PJ_ASSERT_RETURN(src && strlen(cdst) <= 4, -730);
|
||||
PJ_ASSERT_RETURN((int)strlen(cdst) < dst_size ||
|
||||
(strlen(cdst)==0 && dst_size==0), -731);
|
||||
|
||||
for (ig=0; ig<(int)sizeof(GUARDS); ++ig) {
|
||||
char GUARD = GUARDS[ig];
|
||||
|
||||
memset(dst, GUARD, sizeof(dst));
|
||||
if (dst_size) {
|
||||
ret = pj_ansi_strxcpy(dst, cdst, dst_size);
|
||||
PJ_ASSERT_RETURN(ret==(int)strlen(cdst), -732);
|
||||
}
|
||||
|
||||
ret = pj_ansi_strxcat(dst, src, dst_size);
|
||||
|
||||
/* verify return value */
|
||||
if (ret != exp_ret) {
|
||||
PJ_LOG(3,("", " strxcat \"%s\", \"%s\", dst_size=%d: ret %d!=%d",
|
||||
cdst, src, dst_size, ret, exp_ret));
|
||||
return -734;
|
||||
}
|
||||
|
||||
/* expected dst content */
|
||||
if (exp_dst) {
|
||||
if (strcmp(dst, exp_dst)) {
|
||||
PJ_LOG(3,("", " strxcat \"%s\", \"%s\", dst_size=%d: "
|
||||
"dst content mismatch: \"%s\"!=\"%s\"",
|
||||
cdst, src, dst_size, dst, exp_dst));
|
||||
return -736;
|
||||
}
|
||||
}
|
||||
|
||||
/* verify not writing past buffer */
|
||||
for (i=exp_dst?strlen(exp_dst)+1:0; i<(int)sizeof(dst); ++i) {
|
||||
if (dst[i] != GUARD) {
|
||||
PJ_LOG(3,("", " strxcat \"%s\", \"%s\", dst_size=%d: "
|
||||
"overflow at %d",
|
||||
cdst, src, dst_size, i));
|
||||
return -738;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int strxcat_test(void)
|
||||
{
|
||||
int rc;
|
||||
#define CHECK3_(dst, src, dst_size, exp_ret, exp_dst) \
|
||||
rc = verify_strxcat(dst, src, dst_size, exp_ret, exp_dst); \
|
||||
if (rc) return rc
|
||||
|
||||
CHECK3_( "", "", 0, -PJ_ETOOBIG, NULL);
|
||||
CHECK3_( "", "a", 0, -PJ_ETOOBIG, NULL);
|
||||
|
||||
CHECK3_( "", "", 1, 0, "");
|
||||
CHECK3_( "", "a", 1, -PJ_ETOOBIG, "");
|
||||
|
||||
CHECK3_( "", "a", 2, 1, "a");
|
||||
CHECK3_( "", "ab", 2, -PJ_ETOOBIG, "a");
|
||||
CHECK3_( "0", "", 2, 1, "0");
|
||||
CHECK3_( "0", "a", 2, -PJ_ETOOBIG, "0");
|
||||
|
||||
CHECK3_( "", "a", 3, 1, "a");
|
||||
CHECK3_( "", "ab", 3, 2, "ab");
|
||||
CHECK3_( "", "abc", 3, -PJ_ETOOBIG, "ab");
|
||||
CHECK3_( "0", "", 3, 1, "0");
|
||||
CHECK3_( "0", "a", 3, 2, "0a");
|
||||
CHECK3_( "0", "ab", 3, -PJ_ETOOBIG, "0a");
|
||||
CHECK3_( "01", "", 3, 2, "01");
|
||||
CHECK3_( "01", "a", 3, -PJ_ETOOBIG, "01");
|
||||
CHECK3_( "01", "ab", 3, -PJ_ETOOBIG, "01");
|
||||
|
||||
CHECK3_( "", "a", 4, 1, "a");
|
||||
CHECK3_( "", "ab", 4, 2, "ab");
|
||||
CHECK3_( "", "abc", 4, 3, "abc");
|
||||
CHECK3_( "", "abcd", 4, -PJ_ETOOBIG, "abc");
|
||||
CHECK3_( "0", "", 4, 1, "0");
|
||||
CHECK3_( "0", "a", 4, 2, "0a");
|
||||
CHECK3_( "0", "ab", 4, 3, "0ab");
|
||||
CHECK3_( "0", "abc", 4, -PJ_ETOOBIG, "0ab");
|
||||
CHECK3_( "01", "", 4, 2, "01");
|
||||
CHECK3_( "01", "a", 4, 3, "01a");
|
||||
CHECK3_( "01", "ab", 4, -PJ_ETOOBIG, "01a");
|
||||
CHECK3_( "01", "abc", 4, -PJ_ETOOBIG, "01a");
|
||||
CHECK3_( "012", "", 4, 3, "012");
|
||||
CHECK3_( "012", "a", 4, -PJ_ETOOBIG, "012");
|
||||
CHECK3_( "012", "ab", 4, -PJ_ETOOBIG, "012");
|
||||
CHECK3_( "012", "abc",4, -PJ_ETOOBIG, "012");
|
||||
|
||||
#undef CHECK3_
|
||||
return 0;
|
||||
}
|
||||
|
||||
int string_test(void)
|
||||
{
|
||||
const pj_str_t hello_world = { HELLO_WORLD, HELLO_WORLD_LEN };
|
||||
|
@ -425,6 +760,21 @@ int string_test(void)
|
|||
if (i != 0)
|
||||
return i;
|
||||
|
||||
/* strxcpy test */
|
||||
i = strxcpy_test();
|
||||
if (i != 0)
|
||||
return i;
|
||||
|
||||
/* strxcpy2 test */
|
||||
i = strxcpy2_test();
|
||||
if (i != 0)
|
||||
return i;
|
||||
|
||||
/* strxcat test */
|
||||
i = strxcat_test();
|
||||
if (i != 0)
|
||||
return i;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ int test_inner(void)
|
|||
return rc;
|
||||
}
|
||||
|
||||
//pj_dump_config();
|
||||
pj_dump_config();
|
||||
pj_caching_pool_init( &caching_pool, NULL, 0 );
|
||||
|
||||
if (param_ci_mode)
|
||||
|
@ -212,7 +212,7 @@ on_return:
|
|||
|
||||
pj_caching_pool_destroy( &caching_pool );
|
||||
|
||||
PJ_LOG(3,("test", ""));
|
||||
PJ_LOG(3,("test", " "));
|
||||
|
||||
pj_thread_get_stack_info(pj_thread_this(), &filename, &line);
|
||||
PJ_LOG(3,("test", "Stack max usage: %u, deepest: %s:%u",
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -436,6 +436,7 @@ static int poll_worker(void *arg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if ST_CANCEL_THREAD_COUNT
|
||||
/* Cancel worker thread function. */
|
||||
static int cancel_worker(void *arg)
|
||||
{
|
||||
|
@ -466,6 +467,7 @@ static int cancel_worker(void *arg)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int timer_stress_test(void)
|
||||
{
|
||||
|
@ -627,11 +629,11 @@ static int timer_stress_test(void)
|
|||
}
|
||||
|
||||
/* Start cancel worker threads */
|
||||
if (ST_CANCEL_THREAD_COUNT) {
|
||||
cancel_threads = (pj_thread_t**)
|
||||
pj_pool_calloc(pool, ST_CANCEL_THREAD_COUNT,
|
||||
sizeof(pj_thread_t*));
|
||||
}
|
||||
#if ST_CANCEL_THREAD_COUNT
|
||||
cancel_threads = (pj_thread_t**)
|
||||
pj_pool_calloc(pool, ST_CANCEL_THREAD_COUNT,
|
||||
sizeof(pj_thread_t*));
|
||||
|
||||
for (i=0; i<ST_CANCEL_THREAD_COUNT; ++i) {
|
||||
status = pj_thread_create( pool, "cancel", &cancel_worker, &tparam,
|
||||
0, 0, &cancel_threads[i]);
|
||||
|
@ -641,6 +643,7 @@ static int timer_stress_test(void)
|
|||
goto on_return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SIMULATE_CRASH
|
||||
tmp_pool = pj_pool_create( mem, NULL, 4096, 128, NULL);
|
||||
|
@ -668,7 +671,7 @@ on_return:
|
|||
tparam.stopping = PJ_TRUE;
|
||||
|
||||
for (i=0; i<ST_STRESS_THREAD_COUNT; ++i) {
|
||||
if (!stress_threads[i])
|
||||
if (!stress_threads || !stress_threads[i])
|
||||
continue;
|
||||
pj_thread_join(stress_threads[i]);
|
||||
pj_thread_destroy(stress_threads[i]);
|
||||
|
@ -712,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)
|
||||
|
@ -966,6 +969,9 @@ int timer_test()
|
|||
rc = timer_bench_test();
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
#else
|
||||
/* Avoid unused warning */
|
||||
PJ_UNUSED_ARG(timer_bench_test);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -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).."));
|
||||
|
|
|
@ -49,8 +49,10 @@ pj_status_t app_socket(int family, int type, int proto, int port,
|
|||
addr.sin_family = (pj_uint16_t)family;
|
||||
addr.sin_port = (short)(port!=-1 ? pj_htons((pj_uint16_t)port) : 0);
|
||||
rc = pj_sock_bind(sock, &addr, sizeof(addr));
|
||||
if (rc != PJ_SUCCESS)
|
||||
if (rc != PJ_SUCCESS) {
|
||||
pj_sock_close(sock);
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if PJ_HAS_TCP
|
||||
if (type == pj_SOCK_STREAM()) {
|
||||
|
|
|
@ -109,7 +109,7 @@ PJ_DECL(pj_status_t) pjmedia_h263_packetize(pjmedia_h263_packetizer *pktz,
|
|||
pj_uint8_t *bits,
|
||||
pj_size_t bits_len,
|
||||
unsigned *bits_pos,
|
||||
const pj_uint8_t **payload,
|
||||
pj_uint8_t **payload,
|
||||
pj_size_t *payload_len);
|
||||
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ static void alsa_error_handler (const char *file,
|
|||
}
|
||||
|
||||
va_start (arg, fmt);
|
||||
if (index < sizeof(err_msg)-1) {
|
||||
if (index < (int)sizeof(err_msg)-1) {
|
||||
len = vsnprintf( err_msg+index, sizeof(err_msg)-index, fmt, arg);
|
||||
if (len < 1 || len >= (int)sizeof(err_msg)-index)
|
||||
len = sizeof(err_msg)-index-1;
|
||||
|
@ -201,7 +201,7 @@ static void alsa_error_handler (const char *file,
|
|||
err_msg[index] = '\0';
|
||||
}
|
||||
va_end(arg);
|
||||
if (err && index < sizeof(err_msg)-1) {
|
||||
if (err && index < (int)sizeof(err_msg)-1) {
|
||||
len = snprintf( err_msg+index, sizeof(err_msg)-index, ": %s",
|
||||
snd_strerror(err));
|
||||
if (len < 1 || len >= (int)sizeof(err_msg)-index)
|
||||
|
@ -258,7 +258,7 @@ static pj_status_t add_dev (struct alsa_factory *af, const char *dev_name)
|
|||
pj_bzero(adi, sizeof(*adi));
|
||||
|
||||
/* Set device name */
|
||||
strncpy(adi->name, dev_name, sizeof(adi->name));
|
||||
pj_ansi_strxcpy(adi->name, dev_name, sizeof(adi->name));
|
||||
|
||||
/* Check the number of playback channels */
|
||||
adi->output_count = (pb_result>=0) ? 1 : 0;
|
||||
|
@ -270,7 +270,7 @@ static pj_status_t add_dev (struct alsa_factory *af, const char *dev_name)
|
|||
adi->default_samples_per_sec = 8000;
|
||||
|
||||
/* Driver name */
|
||||
strcpy(adi->driver, "ALSA");
|
||||
pj_ansi_strxcpy(adi->driver, "ALSA", sizeof(adi->driver));
|
||||
|
||||
++af->dev_cnt;
|
||||
|
||||
|
@ -311,17 +311,15 @@ static void get_mixer_name(struct alsa_factory *af)
|
|||
{
|
||||
if (snd_mixer_selem_has_playback_volume(elem))
|
||||
{
|
||||
pj_ansi_strncpy(af->pb_mixer_name, elemname,
|
||||
sizeof(af->pb_mixer_name));
|
||||
af->pb_mixer_name[sizeof(af->pb_mixer_name)-1] = 0;
|
||||
pj_ansi_strxcpy(af->pb_mixer_name, elemname,
|
||||
sizeof(af->pb_mixer_name));
|
||||
TRACE_((THIS_FILE, "Playback mixer name: %s",
|
||||
af->pb_mixer_name));
|
||||
}
|
||||
if (snd_mixer_selem_has_capture_volume(elem))
|
||||
{
|
||||
pj_ansi_strncpy(af->cap_mixer_name, elemname,
|
||||
sizeof(af->cap_mixer_name));
|
||||
af->cap_mixer_name[sizeof(af->cap_mixer_name)-1] = 0;
|
||||
pj_ansi_strxcpy(af->cap_mixer_name, elemname,
|
||||
sizeof(af->cap_mixer_name));
|
||||
TRACE_((THIS_FILE, "Capture mixer name: %s",
|
||||
af->cap_mixer_name));
|
||||
}
|
||||
|
@ -451,7 +449,7 @@ static pj_status_t alsa_factory_get_dev_info(pjmedia_aud_dev_factory *f,
|
|||
{
|
||||
struct alsa_factory *af = (struct alsa_factory*)f;
|
||||
|
||||
PJ_ASSERT_RETURN(index>=0 && index<af->dev_cnt, PJ_EINVAL);
|
||||
PJ_ASSERT_RETURN(index<af->dev_cnt, PJ_EINVAL);
|
||||
|
||||
pj_memcpy(info, &af->devs[index], sizeof(*info));
|
||||
info->caps = PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY |
|
||||
|
@ -470,7 +468,7 @@ static pj_status_t alsa_factory_default_param(pjmedia_aud_dev_factory *f,
|
|||
struct alsa_factory *af = (struct alsa_factory*)f;
|
||||
pjmedia_aud_dev_info *adi;
|
||||
|
||||
PJ_ASSERT_RETURN(index>=0 && index<af->dev_cnt, PJ_EINVAL);
|
||||
PJ_ASSERT_RETURN(index<af->dev_cnt, PJ_EINVAL);
|
||||
|
||||
adi = &af->devs[index];
|
||||
|
||||
|
@ -637,7 +635,7 @@ static pj_status_t open_playback (struct alsa_stream* stream,
|
|||
snd_pcm_uframes_t tmp_buf_size;
|
||||
snd_pcm_uframes_t tmp_period_size;
|
||||
|
||||
if (param->play_id < 0 || param->play_id >= stream->af->dev_cnt)
|
||||
if (param->play_id < 0 || param->play_id >= (int)stream->af->dev_cnt)
|
||||
return PJMEDIA_EAUD_INVDEV;
|
||||
|
||||
/* Open PCM for playback */
|
||||
|
@ -755,7 +753,7 @@ static pj_status_t open_playback (struct alsa_stream* stream,
|
|||
}
|
||||
|
||||
PJ_LOG (5,(THIS_FILE, "Opened device alsa(%s) for playing, sample rate=%d"
|
||||
", ch=%d, bits=%d, period size=%d frames, latency=%d ms",
|
||||
", ch=%d, bits=%d, period size=%ld frames, latency=%d ms",
|
||||
stream->af->devs[param->play_id].name,
|
||||
rate, param->channel_count,
|
||||
param->bits_per_sample, stream->pb_frames,
|
||||
|
@ -775,7 +773,7 @@ static pj_status_t open_capture (struct alsa_stream* stream,
|
|||
snd_pcm_uframes_t tmp_buf_size;
|
||||
snd_pcm_uframes_t tmp_period_size;
|
||||
|
||||
if (param->rec_id < 0 || param->rec_id >= stream->af->dev_cnt)
|
||||
if (param->rec_id < 0 || param->rec_id >= (int)stream->af->dev_cnt)
|
||||
return PJMEDIA_EAUD_INVDEV;
|
||||
|
||||
/* Open PCM for capture */
|
||||
|
@ -893,7 +891,7 @@ static pj_status_t open_capture (struct alsa_stream* stream,
|
|||
}
|
||||
|
||||
PJ_LOG (5,(THIS_FILE, "Opened device alsa(%s) for capture, sample rate=%d"
|
||||
", ch=%d, bits=%d, period size=%d frames, latency=%d ms",
|
||||
", ch=%d, bits=%d, period size=%ld frames, latency=%d ms",
|
||||
stream->af->devs[param->rec_id].name,
|
||||
rate, param->channel_count,
|
||||
param->bits_per_sample, stream->ca_frames,
|
||||
|
|
|
@ -404,8 +404,8 @@ static pj_status_t android_get_dev_info(pjmedia_aud_dev_factory *f,
|
|||
|
||||
pj_bzero(info, sizeof(*info));
|
||||
|
||||
pj_ansi_strcpy(info->name, "Android JNI");
|
||||
pj_ansi_strcpy(info->driver, DRIVER_NAME);
|
||||
pj_ansi_strxcpy(info->name, "Android JNI", sizeof(info->name));
|
||||
pj_ansi_strxcpy(info->driver, DRIVER_NAME, sizeof(info->driver));
|
||||
info->default_samples_per_sec = 8000;
|
||||
info->caps = PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING |
|
||||
PJMEDIA_AUD_DEV_CAP_INPUT_SOURCE;
|
||||
|
|
|
@ -161,7 +161,13 @@ PJ_DEF(pj_status_t) pjmedia_aud_test( const pjmedia_aud_param *param,
|
|||
|
||||
test_data.pool = pj_pool_create(pjmedia_aud_subsys_get_pool_factory(),
|
||||
"audtest", 1000, 1000, NULL);
|
||||
pj_mutex_create_simple(test_data.pool, "sndtest", &test_data.mutex);
|
||||
status = pj_mutex_create_simple(test_data.pool, "sndtest",
|
||||
&test_data.mutex);
|
||||
if (status != PJ_SUCCESS) {
|
||||
app_perror("Error creating mutex", status);
|
||||
pj_pool_release(test_data.pool);
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* Open device.
|
||||
|
|
|
@ -212,7 +212,7 @@ static pj_status_t bb10_add_dev (struct bb10_factory *af)
|
|||
pj_bzero(adi, sizeof(*adi));
|
||||
|
||||
/* Set device name */
|
||||
strcpy(adi->name, "preferred");
|
||||
pj_ansi_strxcpy(adi->name, "preferred", sizeof(adi->name));
|
||||
|
||||
/* Check the number of playback channels */
|
||||
adi->output_count = (pb_result >= 0) ? 1 : 0;
|
||||
|
@ -224,7 +224,7 @@ static pj_status_t bb10_add_dev (struct bb10_factory *af)
|
|||
adi->default_samples_per_sec = 8000;
|
||||
|
||||
/* Driver name */
|
||||
strcpy(adi->driver, "BB10");
|
||||
pj_ansi_strxcpy(adi->driver, "BB10", sizeof(adi->driver));
|
||||
|
||||
++af->dev_cnt;
|
||||
|
||||
|
|
|
@ -306,12 +306,14 @@ static pj_status_t factory_refresh(pjmedia_aud_dev_factory *f)
|
|||
wf->dev_info[i].deviceId = i;
|
||||
bdIMADpj_getDeviceCapabilities(BD_IMAD_CAPTURE_DEVICES,&wf->dev_info[i].info.caps);
|
||||
wf->dev_info[i].info.default_samples_per_sec = BD_IMAD_DEFAULT_FREQ;
|
||||
strcpy(wf->dev_info[i].info.driver, "BD_IMAD");
|
||||
pj_ansi_strxcpy(wf->dev_info[i].info.driver, "BD_IMAD",
|
||||
sizeof(wf->dev_info[i].info.driver));
|
||||
wf->dev_info[i].info.ext_fmt_cnt = 0;
|
||||
wf->dev_info[i].info.input_count = BD_IMAD_MAX_CHANNELS;
|
||||
wf->dev_info[i].info.output_count = 0;
|
||||
strcpy(wf->dev_info[i].info.name,
|
||||
BD_IMAD_PJ_WCHARtoCHAR(captureDevName[i]));
|
||||
pj_ansi_strxcpy(wf->dev_info[i].info.name,
|
||||
BD_IMAD_PJ_WCHARtoCHAR(captureDevName[i]),
|
||||
sizeof(wf->dev_info[i].info.name));
|
||||
wf->dev_info[i].info.routes = 0;
|
||||
}
|
||||
|
||||
|
@ -321,13 +323,15 @@ static pj_status_t factory_refresh(pjmedia_aud_dev_factory *f)
|
|||
bdIMADpj_getDeviceCapabilities(BD_IMAD_PLAYBACK_DEVICES,&wf->dev_info[captureDeviceCount+i].info.caps);
|
||||
wf->dev_info[captureDeviceCount+i].info.default_samples_per_sec =
|
||||
BD_IMAD_DEFAULT_FREQ;
|
||||
strcpy(wf->dev_info[captureDeviceCount+i].info.driver, "BD_IMAD");
|
||||
pj_ansi_strxcpy(wf->dev_info[captureDeviceCount+i].info.driver, "BD_IMAD",
|
||||
sizeof(wf->dev_info[captureDeviceCount+i].info.driver));
|
||||
wf->dev_info[captureDeviceCount+i].info.ext_fmt_cnt = 0;
|
||||
wf->dev_info[captureDeviceCount+i].info.input_count = 0;
|
||||
wf->dev_info[captureDeviceCount+i].info.output_count =
|
||||
BD_IMAD_MAX_CHANNELS;
|
||||
strcpy(wf->dev_info[captureDeviceCount+i].info.name,
|
||||
BD_IMAD_PJ_WCHARtoCHAR(playbackDevName[i]));
|
||||
pj_ansi_strxcpy(wf->dev_info[captureDeviceCount+i].info.name,
|
||||
BD_IMAD_PJ_WCHARtoCHAR(playbackDevName[i]),
|
||||
sizeof(wf->dev_info[captureDeviceCount+i].info.name));
|
||||
wf->dev_info[captureDeviceCount+i].info.routes = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -291,8 +291,9 @@ static pj_status_t ca_factory_init(pjmedia_aud_dev_factory *f)
|
|||
cdi = &cf->dev_info[i];
|
||||
pj_bzero(cdi, sizeof(*cdi));
|
||||
cdi->dev_id = 0;
|
||||
strcpy(cdi->info.name, "iPhone IO device");
|
||||
strcpy(cdi->info.driver, "apple");
|
||||
pj_ansi_strxcpy(cdi->info.name, "iPhone IO device",
|
||||
sizeof(cdi->info.name));
|
||||
pj_ansi_strxcpy(cdi->info.driver, "apple", sizeof(cdi->info.driver));
|
||||
cdi->info.input_count = 1;
|
||||
cdi->info.output_count = 1;
|
||||
cdi->info.default_samples_per_sec = 8000;
|
||||
|
@ -549,7 +550,8 @@ static pj_status_t ca_factory_refresh(pjmedia_aud_dev_factory *f)
|
|||
0, NULL,
|
||||
&size, (void *)cdi->info.name);
|
||||
|
||||
strcpy(cdi->info.driver, "core audio");
|
||||
pj_ansi_strxcpy(cdi->info.driver, "core audio",
|
||||
sizeof(cdi->info.driver));
|
||||
|
||||
/* Get the number of input channels */
|
||||
addr.mSelector = kAudioDevicePropertyStreamConfiguration;
|
||||
|
|
|
@ -174,12 +174,11 @@ static pj_status_t factory_get_dev_info(pjmedia_aud_dev_factory *f,
|
|||
return PJMEDIA_EAUD_INVDEV;
|
||||
|
||||
pj_bzero(info, sizeof(*info));
|
||||
pj_ansi_strncpy(info->name, si->name, sizeof(info->name));
|
||||
info->name[sizeof(info->name)-1] = '\0';
|
||||
pj_ansi_strxcpy(info->name, si->name, sizeof(info->name));
|
||||
info->input_count = si->input_count;
|
||||
info->output_count = si->output_count;
|
||||
info->default_samples_per_sec = si->default_samples_per_sec;
|
||||
pj_ansi_strcpy(info->driver, "legacy");
|
||||
pj_ansi_strxcpy(info->driver, "legacy", sizeof(info->driver));
|
||||
info->caps = PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY |
|
||||
PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY;
|
||||
|
||||
|
|
|
@ -142,8 +142,8 @@ static pj_status_t null_factory_init(pjmedia_aud_dev_factory *f)
|
|||
sizeof(struct null_audio_dev_info));
|
||||
ndi = &nf->dev_info[0];
|
||||
pj_bzero(ndi, sizeof(*ndi));
|
||||
strcpy(ndi->info.name, "null device");
|
||||
strcpy(ndi->info.driver, "null");
|
||||
pj_ansi_strxcpy(ndi->info.name, "null device", sizeof(ndi->info.name));
|
||||
pj_ansi_strxcpy(ndi->info.driver, "null", sizeof(ndi->info.driver));
|
||||
ndi->info.input_count = 1;
|
||||
ndi->info.output_count = 1;
|
||||
ndi->info.default_samples_per_sec = 16000;
|
||||
|
|
|
@ -417,8 +417,8 @@ static pj_status_t oboe_refresh(pjmedia_aud_dev_factory *ff)
|
|||
jni_env->GetObjectField(jdev_info,
|
||||
jobjs.dev_info.f_name);
|
||||
const char *strtmp = jni_env->GetStringUTFChars(jstrtmp, NULL);
|
||||
pj_ansi_strncpy(base_adi->name, strtmp, sizeof(base_adi->name));
|
||||
pj_ansi_strncpy(base_adi->driver, DRIVER_NAME,
|
||||
pj_ansi_strxcpy(base_adi->name, strtmp, sizeof(base_adi->name));
|
||||
pj_ansi_strxcpy(base_adi->driver, DRIVER_NAME,
|
||||
sizeof(base_adi->driver));
|
||||
|
||||
f->dev_count++;
|
||||
|
|
|
@ -402,8 +402,8 @@ static pj_status_t opensl_get_dev_info(pjmedia_aud_dev_factory *f,
|
|||
|
||||
pj_bzero(info, sizeof(*info));
|
||||
|
||||
pj_ansi_strcpy(info->name, "OpenSL ES Audio");
|
||||
pj_ansi_strcpy(info->driver, DRIVER_NAME);
|
||||
pj_ansi_strxcpy(info->name, "OpenSL ES Audio", sizeof(info->name));
|
||||
pj_ansi_strxcpy(info->driver, DRIVER_NAME, sizeof(info->driver));
|
||||
info->default_samples_per_sec = 8000;
|
||||
info->caps = PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING;
|
||||
info->input_count = 1;
|
||||
|
|
|
@ -519,13 +519,11 @@ static pj_status_t pa_get_dev_info(pjmedia_aud_dev_factory *f,
|
|||
return PJMEDIA_EAUD_INVDEV;
|
||||
|
||||
pj_bzero(info, sizeof(*info));
|
||||
strncpy(info->name, pa_info->name, sizeof(info->name));
|
||||
info->name[sizeof(info->name)-1] = '\0';
|
||||
pj_ansi_strxcpy(info->name, pa_info->name, sizeof(info->name));
|
||||
info->input_count = pa_info->maxInputChannels;
|
||||
info->output_count = pa_info->maxOutputChannels;
|
||||
info->default_samples_per_sec = (unsigned)pa_info->defaultSampleRate;
|
||||
strncpy(info->driver, DRIVER_NAME, sizeof(info->driver));
|
||||
info->driver[sizeof(info->driver)-1] = '\0';
|
||||
pj_ansi_strxcpy(info->driver, DRIVER_NAME, sizeof(info->driver));
|
||||
info->caps = PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY |
|
||||
PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY;
|
||||
|
||||
|
|
|
@ -785,8 +785,8 @@ static pj_status_t wasapi_add_dev(struct wasapi_factory *wf)
|
|||
pj_bzero(adi, sizeof(*adi));
|
||||
|
||||
/* Set device name */
|
||||
strcpy(adi->name, "default");
|
||||
strcpy(adi->driver, "wasapi");
|
||||
pj_ansi_strxcpy(adi->name, "default", sizeof(adi->name));
|
||||
pj_ansi_strxcpy(adi->driver, "wasapi", sizeof(adi->driver));
|
||||
|
||||
/* Get default capture device */
|
||||
#if defined(USE_ASYNC_ACTIVATE)
|
||||
|
|
|
@ -330,20 +330,19 @@ static void build_dev_info(UINT deviceId, struct wmme_dev_info *wdi,
|
|||
|
||||
/* Device Name */
|
||||
if (deviceId==WAVE_MAPPER) {
|
||||
strncpy(wdi->info.name, "Wave mapper", sizeof(wdi->info.name));
|
||||
wdi->info.name[sizeof(wdi->info.name)-1] = '\0';
|
||||
pj_ansi_strxcpy(wdi->info.name, "Wave mapper",
|
||||
sizeof(wdi->info.name));
|
||||
} else {
|
||||
const pj_char_t *szPname = WIC_WOC(wic, woc, szPname);
|
||||
PJ_DECL_ANSI_TEMP_BUF(wTmp, sizeof(wdi->info.name));
|
||||
|
||||
strncpy(wdi->info.name,
|
||||
pj_ansi_strxcpy(wdi->info.name,
|
||||
PJ_NATIVE_TO_STRING(szPname, wTmp, PJ_ARRAY_SIZE(wTmp)),
|
||||
sizeof(wdi->info.name));
|
||||
wdi->info.name[sizeof(wdi->info.name)-1] = '\0';
|
||||
}
|
||||
|
||||
wdi->info.default_samples_per_sec = 16000;
|
||||
strcpy(wdi->info.driver, "WMME");
|
||||
pj_ansi_strxcpy(wdi->info.driver, "WMME", sizeof(wdi->info.driver));
|
||||
|
||||
if (wic) {
|
||||
wdi->info.input_count = wic->wChannels;
|
||||
|
|
|
@ -60,22 +60,23 @@
|
|||
#if LIBAVCODEC_VER_AT_LEAST(53,61)
|
||||
# if LIBAVCODEC_VER_AT_LEAST(54,59)
|
||||
/* Not sure when AVCodec::encode is obsoleted/removed. */
|
||||
# define AVCODEC_HAS_ENCODE(c) (c->encode2)
|
||||
# define AVCODEC_HAS_ENCODE(c) (c->encode2 != (void*)0)
|
||||
# else
|
||||
/* Not sure when AVCodec::encode2 is introduced. It appears in
|
||||
* libavcodec 53.61 where some codecs actually still use AVCodec::encode
|
||||
* (e.g: H263, H264).
|
||||
*/
|
||||
# define AVCODEC_HAS_ENCODE(c) (c->encode || c->encode2)
|
||||
# define AVCODEC_HAS_ENCODE(c) (c->encode != (void*)0 || \
|
||||
c->encode2 != (void*)0)
|
||||
# endif
|
||||
# define AV_OPT_SET(obj,name,val,opt) (av_opt_set(obj,name,val,opt)==0)
|
||||
# define AV_OPT_SET_INT(obj,name,val) (av_opt_set_int(obj,name,val,0)==0)
|
||||
#else
|
||||
# define AVCODEC_HAS_ENCODE(c) (c->encode)
|
||||
# define AVCODEC_HAS_ENCODE(c) (c->encode != (void*)0)
|
||||
# define AV_OPT_SET(obj,name,val,opt) (av_set_string3(obj,name,val,opt,NULL)==0)
|
||||
# define AV_OPT_SET_INT(obj,name,val) (av_set_int(obj,name,val)!=NULL)
|
||||
#endif
|
||||
#define AVCODEC_HAS_DECODE(c) (c->decode)
|
||||
#define AVCODEC_HAS_DECODE(c) (c->decode != (void*)0)
|
||||
|
||||
/* AVCodec H264 default PT */
|
||||
#define AVC_H264_PT PJMEDIA_RTP_PT_H264_RSV3
|
||||
|
@ -678,7 +679,7 @@ static FUNC_PACKETIZE(h263_packetize)
|
|||
pj_uint8_t *outbuf = payload;
|
||||
pj_size_t out_size = *payload_len;
|
||||
status = pjmedia_h263_packetize(data->pktz, bits, bits_len, bits_pos,
|
||||
(const pj_uint8_t **)&payload, payload_len);
|
||||
&payload, payload_len);
|
||||
if (status != PJ_SUCCESS)
|
||||
return status;
|
||||
if (out_size < *payload_len)
|
||||
|
@ -730,7 +731,7 @@ static int find_codec_idx_by_fmt_id(pjmedia_format_id fmt_id)
|
|||
return -1;
|
||||
}
|
||||
|
||||
static void init_codec(const AVCodec *c, pj_bool_t is_encoder,
|
||||
static void init_codec(AVCodec *c, pj_bool_t is_encoder,
|
||||
pj_bool_t is_decoder)
|
||||
{
|
||||
pj_status_t status;
|
||||
|
@ -873,7 +874,7 @@ PJ_DEF(pj_status_t) pjmedia_codec_ffmpeg_vid_init(pjmedia_vid_codec_mgr *mgr,
|
|||
pj_pool_factory *pf)
|
||||
{
|
||||
pj_pool_t *pool;
|
||||
const AVCodec *c;
|
||||
AVCodec *c;
|
||||
pj_status_t status;
|
||||
unsigned i;
|
||||
|
||||
|
@ -987,10 +988,10 @@ PJ_DEF(pj_status_t) pjmedia_codec_ffmpeg_vid_init(pjmedia_vid_codec_mgr *mgr,
|
|||
if (copied_dir != PJMEDIA_DIR_NONE) {
|
||||
const char *dir_name[] = {NULL, "encoder", "decoder", "codec"};
|
||||
PJ_LOG(5, (THIS_FILE, "The %.*s %s is using base codec (%.*s)",
|
||||
desc->info.encoding_name.slen,
|
||||
(int)desc->info.encoding_name.slen,
|
||||
desc->info.encoding_name.ptr,
|
||||
dir_name[copied_dir],
|
||||
base_desc->info.encoding_name.slen,
|
||||
(int)base_desc->info.encoding_name.slen,
|
||||
base_desc->info.encoding_name.ptr));
|
||||
}
|
||||
}
|
||||
|
@ -1006,12 +1007,12 @@ PJ_DEF(pj_status_t) pjmedia_codec_ffmpeg_vid_init(pjmedia_vid_codec_mgr *mgr,
|
|||
/* Print warning about missing encoder/decoder */
|
||||
if (!desc->enc) {
|
||||
PJ_LOG(4, (THIS_FILE, "Cannot find %.*s encoder in ffmpeg library",
|
||||
desc->info.encoding_name.slen,
|
||||
(int)desc->info.encoding_name.slen,
|
||||
desc->info.encoding_name.ptr));
|
||||
}
|
||||
if (!desc->dec) {
|
||||
PJ_LOG(4, (THIS_FILE, "Cannot find %.*s decoder in ffmpeg library",
|
||||
desc->info.encoding_name.slen,
|
||||
(int)desc->info.encoding_name.slen,
|
||||
desc->info.encoding_name.ptr));
|
||||
}
|
||||
}
|
||||
|
@ -1193,6 +1194,10 @@ static pj_status_t ffmpeg_alloc_codec( pjmedia_vid_codec_factory *factory,
|
|||
|
||||
/* Create pool for codec instance */
|
||||
pool = pj_pool_create(ffmpeg_factory.pf, "ffmpeg codec", 512, 512, NULL);
|
||||
if (!pool) {
|
||||
status = PJ_ENOMEM;
|
||||
goto on_error;
|
||||
}
|
||||
codec = PJ_POOL_ZALLOC_T(pool, pjmedia_vid_codec);
|
||||
if (!codec) {
|
||||
status = PJ_ENOMEM;
|
||||
|
|
|
@ -391,14 +391,19 @@ PJ_DEF(pj_status_t) pjmedia_codec_g7221_set_mode(unsigned sample_rate,
|
|||
if (codec_factory.modes[i].sample_rate == sample_rate &&
|
||||
codec_factory.modes[i].bitrate == bitrate)
|
||||
{
|
||||
pj_status_t status;
|
||||
|
||||
codec_factory.modes[i].enabled = enabled;
|
||||
|
||||
/* Re-register G722.1 codec factory to update codec list */
|
||||
pjmedia_codec_mgr_unregister_factory(codec_mgr,
|
||||
&codec_factory.base);
|
||||
pjmedia_codec_mgr_register_factory(codec_mgr,
|
||||
&codec_factory.base);
|
||||
return PJ_SUCCESS;
|
||||
status = pjmedia_codec_mgr_unregister_factory(codec_mgr,
|
||||
&codec_factory.base);
|
||||
if (status != PJ_SUCCESS)
|
||||
return status;
|
||||
|
||||
status = pjmedia_codec_mgr_register_factory(codec_mgr,
|
||||
&codec_factory.base);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -418,19 +423,24 @@ PJ_DEF(pj_status_t) pjmedia_codec_g7221_set_mode(unsigned sample_rate,
|
|||
{
|
||||
if (!codec_factory.modes[i].enabled)
|
||||
{
|
||||
pj_status_t status;
|
||||
codec_mode *mode = &codec_factory.modes[i];
|
||||
|
||||
mode->enabled = PJ_TRUE;
|
||||
mode->sample_rate = sample_rate;
|
||||
mode->bitrate = bitrate;
|
||||
pj_utoa(mode->bitrate, mode->bitrate_str);
|
||||
|
||||
/* Re-register G722.1 codec factory to update codec list */
|
||||
pjmedia_codec_mgr_unregister_factory(codec_mgr,
|
||||
&codec_factory.base);
|
||||
pjmedia_codec_mgr_register_factory(codec_mgr,
|
||||
&codec_factory.base);
|
||||
status = pjmedia_codec_mgr_unregister_factory(codec_mgr,
|
||||
&codec_factory.base);
|
||||
if (status != PJ_SUCCESS)
|
||||
return status;
|
||||
|
||||
return PJ_SUCCESS;
|
||||
status = pjmedia_codec_mgr_register_factory(codec_mgr,
|
||||
&codec_factory.base);
|
||||
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ PJ_DEF(pj_status_t) pjmedia_h263_packetize(pjmedia_h263_packetizer *pktz,
|
|||
pj_uint8_t *bits,
|
||||
pj_size_t bits_len,
|
||||
unsigned *pos,
|
||||
const pj_uint8_t **payload,
|
||||
pj_uint8_t **payload,
|
||||
pj_size_t *payload_len)
|
||||
{
|
||||
pj_uint8_t *p, *end;
|
||||
|
|
|
@ -172,7 +172,7 @@ PJ_DEF(pj_status_t) pjmedia_h264_packetize(pjmedia_h264_packetizer *pktz,
|
|||
//pj_assert(!"MTU too small for H.264 single NAL packetization mode");
|
||||
PJ_LOG(2,(THIS_FILE,
|
||||
"MTU too small for H.264 (required=%u, MTU=%u)",
|
||||
nal_end - nal_start, pktz->cfg.mtu));
|
||||
(unsigned)(nal_end - nal_start), pktz->cfg.mtu));
|
||||
return PJ_ETOOSMALL;
|
||||
}
|
||||
|
||||
|
|
|
@ -1150,7 +1150,7 @@ static pj_status_t oh264_codec_decode(pjmedia_vid_codec *codec,
|
|||
output->timestamp = packets[0].timestamp;
|
||||
|
||||
PJ_LOG(5,(THIS_FILE, "Decode couldn't produce picture, "
|
||||
"input nframes=%d, concatenated size=%d bytes, ret=%d",
|
||||
"input nframes=%lu, concatenated size=%d bytes, ret=%d",
|
||||
count, whole_len, ret));
|
||||
}
|
||||
|
||||
|
|
|
@ -909,7 +909,7 @@ static pj_status_t codec_parse( pjmedia_codec *codec,
|
|||
((unsigned char*)pkt) + out_pos,
|
||||
sizeof(tmp_buf));
|
||||
if (size < 0) {
|
||||
PJ_LOG(5, (THIS_FILE, "Parse failed! (pkt_size=%d, err=%d)",
|
||||
PJ_LOG(5, (THIS_FILE, "Parse failed! (pkt_size=%lu, err=%d)",
|
||||
pkt_size, size));
|
||||
pj_mutex_unlock (opus_data->mutex);
|
||||
return PJMEDIA_CODEC_EFAILED;
|
||||
|
|
|
@ -472,7 +472,8 @@ static pj_status_t silk_enum_codecs(pjmedia_codec_factory *factory,
|
|||
max = *count;
|
||||
*count = 0;
|
||||
|
||||
for (i = 0; i<PJ_ARRAY_SIZE(silk_factory.silk_param) && *count<max; ++i)
|
||||
for (i = 0; i<(int)PJ_ARRAY_SIZE(silk_factory.silk_param) && *count<max;
|
||||
++i)
|
||||
{
|
||||
silk_param *sp = &silk_factory.silk_param[i];
|
||||
|
||||
|
|
|
@ -274,6 +274,7 @@ PJ_DEF(pj_status_t) pjmedia_codec_speex_init( pjmedia_endpt *endpt,
|
|||
/* Get codec framesize and avg bitrate for each mode. */
|
||||
for (i=0; i<PJ_ARRAY_SIZE(spx_factory.speex_param); ++i) {
|
||||
status = get_speex_info(&spx_factory.speex_param[i]);
|
||||
PJ_ASSERT_ON_FAIL(status == PJ_SUCCESS, goto on_error);
|
||||
}
|
||||
|
||||
/* Get the codec manager. */
|
||||
|
|
|
@ -1370,7 +1370,7 @@ on_return:
|
|||
PJMEDIA_EVENT_PUBLISH_DEFAULT);
|
||||
|
||||
PJ_LOG(5,(THIS_FILE, "Decode couldn't produce picture, "
|
||||
"input nframes=%d, concatenated size=%d bytes",
|
||||
"input nframes=%ld, concatenated size=%d bytes",
|
||||
count, whole_len));
|
||||
|
||||
output->type = PJMEDIA_FRAME_TYPE_NONE;
|
||||
|
|
|
@ -829,7 +829,7 @@ on_return:
|
|||
PJMEDIA_EVENT_PUBLISH_DEFAULT);
|
||||
|
||||
PJ_LOG(4,(THIS_FILE, "Decode couldn't produce picture, "
|
||||
"input nframes=%d, concatenated size=%d bytes",
|
||||
"input nframes=%lu, concatenated size=%d bytes",
|
||||
count, whole_len));
|
||||
|
||||
output->type = PJMEDIA_FRAME_TYPE_NONE;
|
||||
|
|
|
@ -540,12 +540,12 @@ static pj_status_t and_factory_refresh(pjmedia_vid_dev_factory *ff)
|
|||
PJMEDIA_VID_DEV_CAP_ORIENTATION;
|
||||
|
||||
/* Set driver & name info */
|
||||
pj_ansi_strncpy(vdi->driver, "Android", sizeof(vdi->driver));
|
||||
pj_ansi_strxcpy(vdi->driver, "Android", sizeof(vdi->driver));
|
||||
adi->facing = facing;
|
||||
if (facing == 0) {
|
||||
pj_ansi_strncpy(vdi->name, "Back camera", sizeof(vdi->name));
|
||||
pj_ansi_strxcpy(vdi->name, "Back camera", sizeof(vdi->name));
|
||||
} else {
|
||||
pj_ansi_strncpy(vdi->name, "Front camera", sizeof(vdi->name));
|
||||
pj_ansi_strxcpy(vdi->name, "Front camera", sizeof(vdi->name));
|
||||
}
|
||||
|
||||
/* Get supported sizes */
|
||||
|
|
|
@ -281,8 +281,9 @@ static void reset_dev_info(struct avi_dev_info *adi)
|
|||
pj_bzero(adi, sizeof(*adi));
|
||||
|
||||
/* Fill up with *dummy" device info */
|
||||
pj_ansi_strncpy(adi->info.name, "AVI Player", sizeof(adi->info.name)-1);
|
||||
pj_ansi_strncpy(adi->info.driver, DRIVER_NAME, sizeof(adi->info.driver)-1);
|
||||
pj_ansi_strxcpy(adi->info.name, "AVI Player", sizeof(adi->info.name));
|
||||
pj_ansi_strxcpy(adi->info.driver, DRIVER_NAME,
|
||||
sizeof(adi->info.driver));
|
||||
adi->info.dir = PJMEDIA_DIR_CAPTURE;
|
||||
adi->info.has_callback = PJ_FALSE;
|
||||
}
|
||||
|
@ -397,7 +398,10 @@ PJ_DEF(pj_status_t) pjmedia_avi_dev_alloc( pjmedia_vid_dev_factory *f,
|
|||
/* Reinit */
|
||||
PJ_ASSERT_RETURN(p->path.slen, PJ_EINVAL);
|
||||
adi->pool = pj_pool_create(cf->pf, "avidi%p", 512, 512, NULL);
|
||||
|
||||
if (!adi->pool) {
|
||||
status = PJ_ENOMEM;
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
/* Open the AVI */
|
||||
pj_strdup_with_null(adi->pool, &adi->fpath, &p->path);
|
||||
|
@ -484,8 +488,10 @@ PJ_DEF(pj_status_t) pjmedia_avi_dev_alloc( pjmedia_vid_dev_factory *f,
|
|||
}
|
||||
|
||||
/* Init device info */
|
||||
pj_ansi_strncpy(adi->info.name, adi->title.ptr, sizeof(adi->info.name)-1);
|
||||
pj_ansi_strncpy(adi->info.driver, DRIVER_NAME, sizeof(adi->info.driver)-1);
|
||||
pj_ansi_strxcpy(adi->info.name, adi->title.ptr,
|
||||
sizeof(adi->info.name));
|
||||
pj_ansi_strxcpy(adi->info.driver, DRIVER_NAME,
|
||||
sizeof(adi->info.driver));
|
||||
adi->info.dir = PJMEDIA_DIR_CAPTURE;
|
||||
adi->info.has_callback = PJ_FALSE;
|
||||
|
||||
|
|
|
@ -201,11 +201,10 @@ static pj_status_t cbar_factory_init(pjmedia_vid_dev_factory *f)
|
|||
/* Passive capturer */
|
||||
ddi = &cf->dev_info[0];
|
||||
pj_bzero(ddi, sizeof(*ddi));
|
||||
pj_ansi_strncpy(ddi->info.name, "Colorbar generator",
|
||||
pj_ansi_strxcpy(ddi->info.name, "Colorbar generator",
|
||||
sizeof(ddi->info.name));
|
||||
ddi->info.driver[sizeof(ddi->info.driver)-1] = '\0';
|
||||
pj_ansi_strncpy(ddi->info.driver, "Colorbar", sizeof(ddi->info.driver));
|
||||
ddi->info.driver[sizeof(ddi->info.driver)-1] = '\0';
|
||||
pj_ansi_strxcpy(ddi->info.driver, "Colorbar",
|
||||
sizeof(ddi->info.driver));
|
||||
ddi->info.dir = PJMEDIA_DIR_CAPTURE;
|
||||
ddi->info.has_callback = PJ_FALSE;
|
||||
|
||||
|
@ -221,11 +220,10 @@ static pj_status_t cbar_factory_init(pjmedia_vid_dev_factory *f)
|
|||
/* Active capturer */
|
||||
ddi = &cf->dev_info[1];
|
||||
pj_bzero(ddi, sizeof(*ddi));
|
||||
pj_ansi_strncpy(ddi->info.name, "Colorbar-active",
|
||||
pj_ansi_strxcpy(ddi->info.name, "Colorbar-active",
|
||||
sizeof(ddi->info.name));
|
||||
ddi->info.driver[sizeof(ddi->info.driver)-1] = '\0';
|
||||
pj_ansi_strncpy(ddi->info.driver, "Colorbar", sizeof(ddi->info.driver));
|
||||
ddi->info.driver[sizeof(ddi->info.driver)-1] = '\0';
|
||||
pj_ansi_strxcpy(ddi->info.driver, "Colorbar",
|
||||
sizeof(ddi->info.driver));
|
||||
ddi->info.dir = PJMEDIA_DIR_CAPTURE;
|
||||
ddi->info.has_callback = PJ_TRUE;
|
||||
|
||||
|
|
|
@ -302,8 +302,8 @@ static pj_status_t darwin_factory_refresh(pjmedia_vid_dev_factory *f)
|
|||
/* Init output device */
|
||||
qdi = &qf->dev_info[qf->dev_count++];
|
||||
pj_bzero(qdi, sizeof(*qdi));
|
||||
pj_ansi_strncpy(qdi->info.name, "UIView", sizeof(qdi->info.name));
|
||||
pj_ansi_strncpy(qdi->info.driver, "iOS", sizeof(qdi->info.driver));
|
||||
pj_ansi_strxcpy(qdi->info.name, "UIView", sizeof(qdi->info.name));
|
||||
pj_ansi_strxcpy(qdi->info.driver, "iOS", sizeof(qdi->info.driver));
|
||||
qdi->info.dir = PJMEDIA_DIR_RENDER;
|
||||
qdi->info.has_callback = PJ_FALSE;
|
||||
#endif
|
||||
|
@ -361,9 +361,11 @@ static pj_status_t darwin_factory_refresh(pjmedia_vid_dev_factory *f)
|
|||
|
||||
qdi = &qf->dev_info[qf->dev_count++];
|
||||
pj_bzero(qdi, sizeof(*qdi));
|
||||
pj_ansi_strncpy(qdi->info.name, [device.localizedName UTF8String],
|
||||
pj_ansi_strxcpy(qdi->info.name,
|
||||
[device.localizedName UTF8String],
|
||||
sizeof(qdi->info.name));
|
||||
pj_ansi_strncpy(qdi->info.driver, "AVF", sizeof(qdi->info.driver));
|
||||
pj_ansi_strxcpy(qdi->info.driver, "AVF",
|
||||
sizeof(qdi->info.driver));
|
||||
qdi->info.dir = PJMEDIA_DIR_CAPTURE;
|
||||
qdi->info.has_callback = PJ_FALSE;
|
||||
#if TARGET_OS_IPHONE
|
||||
|
|
|
@ -475,9 +475,8 @@ static pj_status_t dshow_factory_refresh(pjmedia_vid_dev_factory *f)
|
|||
CoTaskMemFree(wszDisplayName);
|
||||
}
|
||||
|
||||
strncpy(ddi->info.driver, "dshow",
|
||||
sizeof(ddi->info.driver));
|
||||
ddi->info.driver[sizeof(ddi->info.driver)-1] = '\0';
|
||||
pj_ansi_strxcpy(ddi->info.driver, "dshow",
|
||||
sizeof(ddi->info.driver));
|
||||
ddi->info.dir = PJMEDIA_DIR_CAPTURE;
|
||||
ddi->info.has_callback = PJ_TRUE;
|
||||
|
||||
|
@ -505,10 +504,10 @@ static pj_status_t dshow_factory_refresh(pjmedia_vid_dev_factory *f)
|
|||
#if HAS_VMR
|
||||
ddi = &df->dev_info[df->dev_count++];
|
||||
pj_bzero(ddi, sizeof(*ddi));
|
||||
pj_ansi_strncpy(ddi->info.name, "Video Mixing Renderer",
|
||||
pj_ansi_strxcpy(ddi->info.name, "Video Mixing Renderer",
|
||||
sizeof(ddi->info.name));
|
||||
ddi->info.name[sizeof(ddi->info.name)-1] = '\0';
|
||||
pj_ansi_strncpy(ddi->info.driver, "dshow", sizeof(ddi->info.driver));
|
||||
pj_ansi_strxcpy(ddi->info.driver, "dshow",
|
||||
sizeof(ddi->info.driver));
|
||||
ddi->info.driver[sizeof(ddi->info.driver)-1] = '\0';
|
||||
ddi->info.dir = PJMEDIA_DIR_RENDER;
|
||||
ddi->info.has_callback = PJ_FALSE;
|
||||
|
|
|
@ -467,7 +467,7 @@ static pj_status_t ffmpeg_factory_refresh(pjmedia_vid_dev_factory *f)
|
|||
|
||||
info = &ff->dev_info[ff->dev_count++];
|
||||
pj_bzero(info, sizeof(*info));
|
||||
pj_ansi_strncpy(info->base.name, "default",
|
||||
pj_ansi_strxcpy(info->base.name, "default",
|
||||
sizeof(info->base.name));
|
||||
pj_ansi_snprintf(info->base.driver, sizeof(info->base.driver),
|
||||
"ffmpeg %s", p->name);
|
||||
|
|
|
@ -376,8 +376,8 @@ static pj_status_t opengl_factory_init(pjmedia_vid_dev_factory *f)
|
|||
qf->dev_count = 0;
|
||||
qdi = &qf->dev_info[qf->dev_count++];
|
||||
pj_bzero(qdi, sizeof(*qdi));
|
||||
strcpy(qdi->info.name, "OpenGL renderer");
|
||||
strcpy(qdi->info.driver, "OpenGL");
|
||||
pj_ansi_strxcpy(qdi->info.name, "OpenGL renderer", sizeof(qdi->info.name));
|
||||
pj_ansi_strxcpy(qdi->info.driver, "OpenGL", sizeof(qdi->info.driver));
|
||||
qdi->info.dir = PJMEDIA_DIR_RENDER;
|
||||
qdi->info.has_callback = PJ_FALSE;
|
||||
qdi->info.caps = PJMEDIA_VID_DEV_CAP_FORMAT;
|
||||
|
|
|
@ -253,7 +253,7 @@ static pj_status_t qt_factory_refresh(pjmedia_vid_dev_factory *f)
|
|||
[[dev uniqueID] getCString:qdi->dev_id
|
||||
maxLength:sizeof(qdi->dev_id)
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
strcpy(qdi->info.driver, "QT");
|
||||
pj_ansi_strxcpy(qdi->info.driver, "QT", sizeof(qdi->info.driver));
|
||||
qdi->info.dir = PJMEDIA_DIR_CAPTURE;
|
||||
qdi->info.has_callback = PJ_TRUE;
|
||||
|
||||
|
|
|
@ -493,22 +493,22 @@ static pj_status_t sdl_factory_init(pjmedia_vid_dev_factory *f)
|
|||
|
||||
ddi = &sf->dev_info[0];
|
||||
pj_bzero(ddi, sizeof(*ddi));
|
||||
strncpy(ddi->info.name, "SDL renderer", sizeof(ddi->info.name));
|
||||
ddi->info.name[sizeof(ddi->info.name)-1] = '\0';
|
||||
pj_ansi_strxcpy(ddi->info.name, "SDL renderer",
|
||||
sizeof(ddi->info.name));
|
||||
ddi->info.fmt_cnt = PJ_ARRAY_SIZE(sdl_fmts);
|
||||
|
||||
#if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL
|
||||
ddi = &sf->dev_info[OPENGL_DEV_IDX];
|
||||
pj_bzero(ddi, sizeof(*ddi));
|
||||
strncpy(ddi->info.name, "SDL openGL renderer", sizeof(ddi->info.name));
|
||||
ddi->info.name[sizeof(ddi->info.name)-1] = '\0';
|
||||
pj_ansi_strxcpy(ddi->info.name, "SDL openGL renderer",
|
||||
sizeof(ddi->info.name));
|
||||
ddi->info.fmt_cnt = 1;
|
||||
#endif /* PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL */
|
||||
|
||||
for (i = 0; i < sf->dev_count; i++) {
|
||||
ddi = &sf->dev_info[i];
|
||||
strncpy(ddi->info.driver, "SDL", sizeof(ddi->info.driver));
|
||||
ddi->info.driver[sizeof(ddi->info.driver)-1] = '\0';
|
||||
pj_ansi_strxcpy(ddi->info.driver, "SDL",
|
||||
sizeof(ddi->info.driver));
|
||||
ddi->info.dir = PJMEDIA_DIR_RENDER;
|
||||
ddi->info.has_callback = PJ_FALSE;
|
||||
ddi->info.caps = PJMEDIA_VID_DEV_CAP_FORMAT |
|
||||
|
@ -1237,7 +1237,7 @@ static pj_status_t set_cap(void *data)
|
|||
|
||||
status = sdl_create_window(strm, PJ_TRUE, sdl_info->sdl_format, hwnd);
|
||||
PJ_PERROR(4, (THIS_FILE, status,
|
||||
"Re-initializing SDL with native window %d",
|
||||
"Re-initializing SDL with native window %p",
|
||||
hwnd->info.window));
|
||||
return status;
|
||||
} else if (cap == PJMEDIA_VID_DEV_CAP_OUTPUT_FULLSCREEN) {
|
||||
|
@ -1485,10 +1485,10 @@ static pj_status_t job_queue_post_job(job_queue *jq, job_func_ptr func,
|
|||
jq->is_full = PJ_TRUE;
|
||||
PJ_LOG(4, (THIS_FILE, "SDL job queue is full, increasing "
|
||||
"the queue size."));
|
||||
pj_mutex_unlock(jq->mutex);
|
||||
pj_sem_post(jq->sem);
|
||||
/* Wait until our posted job is completed. */
|
||||
pj_sem_wait(jq->job_sem[tail]);
|
||||
pj_mutex_unlock(jq->mutex);
|
||||
} else {
|
||||
pj_mutex_unlock(jq->mutex);
|
||||
pj_sem_post(jq->sem);
|
||||
|
|
|
@ -244,7 +244,7 @@ static void v4l2_get_supported_size(int fd,
|
|||
if (fmt_map == NULL)
|
||||
return;
|
||||
|
||||
for (;i<PJ_ARRAY_SIZE(v4l_sizes) &&
|
||||
for (;i<(int)PJ_ARRAY_SIZE(v4l_sizes) &&
|
||||
info->fmt_cnt<PJMEDIA_VID_DEV_INFO_FMT_CNT;
|
||||
i++)
|
||||
{
|
||||
|
@ -322,7 +322,7 @@ static pj_status_t v4l2_scan_devs(vid4lin_factory *f)
|
|||
|
||||
PJ_LOG(5,(THIS_FILE, "Found capture device %s", pdi->v4l2_cap.card));
|
||||
PJ_LOG(5,(THIS_FILE, " Enumerating formats:"));
|
||||
for (j=0; fmt_cnt<PJ_ARRAY_SIZE(fmt_cap); ++j) {
|
||||
for (j=0; fmt_cnt<(int)PJ_ARRAY_SIZE(fmt_cap); ++j) {
|
||||
struct v4l2_fmtdesc fdesc;
|
||||
unsigned k;
|
||||
|
||||
|
@ -353,13 +353,11 @@ static pj_status_t v4l2_scan_devs(vid4lin_factory *f)
|
|||
continue;
|
||||
}
|
||||
|
||||
strncpy(pdi->dev_name, dev_name, sizeof(pdi->dev_name));
|
||||
pdi->dev_name[sizeof(pdi->dev_name)-1] = '\0';
|
||||
strncpy(pdi->info.name, (char*)pdi->v4l2_cap.card,
|
||||
sizeof(pdi->info.name));
|
||||
pdi->info.name[sizeof(pdi->info.name)-1] = '\0';
|
||||
strncpy(pdi->info.driver, DRIVER_NAME, sizeof(pdi->info.driver));
|
||||
pdi->info.driver[sizeof(pdi->info.driver)-1] = '\0';
|
||||
pj_ansi_strxcpy(pdi->dev_name, dev_name, sizeof(pdi->dev_name));
|
||||
pj_ansi_strxcpy(pdi->info.name, (char*)pdi->v4l2_cap.card,
|
||||
sizeof(pdi->info.name));
|
||||
pj_ansi_strxcpy(pdi->info.driver, DRIVER_NAME,
|
||||
sizeof(pdi->info.driver));
|
||||
pdi->info.dir = PJMEDIA_DIR_CAPTURE;
|
||||
pdi->info.has_callback = PJ_FALSE;
|
||||
pdi->info.caps = PJMEDIA_VID_DEV_CAP_FORMAT;
|
||||
|
@ -599,7 +597,7 @@ static pj_status_t vid4lin_factory_create_stream(pjmedia_vid_dev_factory *f,
|
|||
param->fmt.detail_type == PJMEDIA_FORMAT_DETAIL_VIDEO &&
|
||||
param->dir == PJMEDIA_DIR_CAPTURE,
|
||||
PJ_EINVAL);
|
||||
PJ_ASSERT_RETURN(param->cap_id >= 0 && param->cap_id < cf->dev_count,
|
||||
PJ_ASSERT_RETURN(param->cap_id >= 0 && param->cap_id < (int)cf->dev_count,
|
||||
PJMEDIA_EVID_INVDEV);
|
||||
|
||||
fmt_info = pjmedia_get_video_format_info(NULL, param->fmt.id);
|
||||
|
@ -618,8 +616,7 @@ static pj_status_t vid4lin_factory_create_stream(pjmedia_vid_dev_factory *f,
|
|||
pj_memcpy(&stream->param, param, sizeof(*param));
|
||||
stream->pool = pool;
|
||||
pj_memcpy(&stream->vid_cb, cb, sizeof(*cb));
|
||||
strncpy(stream->name, vdi->info.name, sizeof(stream->name));
|
||||
stream->name[sizeof(stream->name)-1] = '\0';
|
||||
pj_ansi_strxcpy(stream->name, vdi->info.name, sizeof(stream->name));
|
||||
stream->user_data = user_data;
|
||||
stream->fd = INVALID_FD;
|
||||
|
||||
|
|
|
@ -135,8 +135,7 @@ PJ_DEF(pj_status_t) pjmedia_aud_driver_init(unsigned drv_idx,
|
|||
|
||||
if (drv->name[0]=='\0') {
|
||||
/* Set driver name */
|
||||
pj_ansi_strncpy(drv->name, info.driver, sizeof(drv->name));
|
||||
drv->name[sizeof(drv->name)-1] = '\0';
|
||||
pj_ansi_strxcpy(drv->name, info.driver, sizeof(drv->name));
|
||||
}
|
||||
|
||||
if (drv->play_dev_idx < 0 && info.output_count) {
|
||||
|
|
|
@ -183,8 +183,9 @@ static pj_status_t file_read3(pj_oshandle_t fd, void *data, pj_ssize_t size,
|
|||
/* Normalize AVI header fields values from little-endian to host
|
||||
* byte order.
|
||||
*/
|
||||
if (bits > 0)
|
||||
if (bits > 0) {
|
||||
data_to_host(data, bits, size_read);
|
||||
}
|
||||
|
||||
if (size_read != size_to_read) {
|
||||
if (psz_read)
|
||||
|
@ -303,14 +304,15 @@ pjmedia_avi_player_create_streams(pj_pool_t *pool,
|
|||
goto on_error;
|
||||
|
||||
/* Normalize the endian */
|
||||
if (elem == sizeof(strf_video_hdr_t))
|
||||
if (elem == sizeof(strf_video_hdr_t)) {
|
||||
data_to_host2(&avi_hdr.strf_hdr[i],
|
||||
PJ_ARRAY_SIZE(strf_video_hdr_sizes),
|
||||
strf_video_hdr_sizes);
|
||||
else if (elem == sizeof(strf_audio_hdr_t))
|
||||
} else if (elem == sizeof(strf_audio_hdr_t)) {
|
||||
data_to_host2(&avi_hdr.strf_hdr[i],
|
||||
PJ_ARRAY_SIZE(strf_audio_hdr_sizes),
|
||||
strf_audio_hdr_sizes);
|
||||
}
|
||||
|
||||
/* Skip the remainder of the header */
|
||||
size_to_read = avi_hdr.strl_hdr[i].list_sz - (sizeof(strl_hdr_t) -
|
||||
|
|
|
@ -106,7 +106,7 @@ PJ_DEF(pj_status_t) pjmedia_delay_buf_create( pj_pool_t *pool,
|
|||
|
||||
b = PJ_POOL_ZALLOC_T(pool, pjmedia_delay_buf);
|
||||
|
||||
pj_ansi_strncpy(b->obj_name, name, PJ_MAX_OBJ_NAME-1);
|
||||
pj_ansi_strxcpy(b->obj_name, name, PJ_MAX_OBJ_NAME);
|
||||
|
||||
b->samples_per_frame = samples_per_frame;
|
||||
b->channel_count = channel_count;
|
||||
|
|
|
@ -1011,16 +1011,16 @@ PJ_DEF(pj_status_t) pjmedia_endpt_create_sdp( pjmedia_endpt *endpt,
|
|||
|
||||
|
||||
#if PJ_LOG_MAX_LEVEL >= 3
|
||||
static const char *good_number(char *buf, pj_int32_t val)
|
||||
static const char *good_number(char *buf, unsigned buf_size, pj_int32_t val)
|
||||
{
|
||||
if (val < 1000) {
|
||||
pj_ansi_sprintf(buf, "%d", val);
|
||||
pj_ansi_snprintf(buf, buf_size, "%d", val);
|
||||
} else if (val < 1000000) {
|
||||
pj_ansi_sprintf(buf, "%d.%dK",
|
||||
pj_ansi_snprintf(buf, buf_size, "%d.%dK",
|
||||
val / 1000,
|
||||
(val % 1000) / 100);
|
||||
} else {
|
||||
pj_ansi_sprintf(buf, "%d.%02dM",
|
||||
pj_ansi_snprintf(buf, buf_size, "%d.%02dM",
|
||||
val / 1000000,
|
||||
(val % 1000000) / 10000);
|
||||
}
|
||||
|
@ -1076,7 +1076,7 @@ PJ_DEF(pj_status_t) pjmedia_endpt_dump(pjmedia_endpt *endpt)
|
|||
codec_info[i].encoding_name.ptr,
|
||||
codec_info[i].clock_rate/1000,
|
||||
codec_info[i].channel_cnt,
|
||||
good_number(bps, param.info.avg_bps),
|
||||
good_number(bps, sizeof(bps), param.info.avg_bps),
|
||||
param.info.frm_ptime * param.setting.frm_per_pkt,
|
||||
(param.setting.vad ? " vad" : ""),
|
||||
(param.setting.cng ? " cng" : ""),
|
||||
|
|
|
@ -78,7 +78,7 @@ void pjmedia_ffmpeg_add_ref()
|
|||
if (pjmedia_ffmpeg_ref_cnt++ == 0) {
|
||||
av_log_set_level(AV_LOG_ERROR);
|
||||
av_log_set_callback(&ffmpeg_log_cb);
|
||||
#if !LIBAVCODEC_VER_AT_LEAST(58,137)
|
||||
#if !LIBAVCODEC_VER_AT_LEAST(58,76)
|
||||
av_register_all();
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -627,8 +627,8 @@ static void parse_rtcp_report( pjmedia_rtcp_session *sess,
|
|||
eedelay *= 1000;
|
||||
}
|
||||
|
||||
TRACE_((sess->name, "Rx RTCP RR: lsr=%p, dlsr=%p (%d:%03dms), "
|
||||
"now=%p, rtt=%p",
|
||||
TRACE_((sess->name, "Rx RTCP RR: lsr=%u, dlsr=%u (%u:%03ums), "
|
||||
"now=%u, rtt=%u",
|
||||
lsr, dlsr, dlsr/65536, (dlsr%65536)*1000/65536,
|
||||
now, (pj_uint32_t)eedelay));
|
||||
|
||||
|
@ -669,7 +669,7 @@ static void parse_rtcp_report( pjmedia_rtcp_session *sess,
|
|||
|
||||
} else {
|
||||
PJ_LOG(5, (sess->name, "Internal RTCP NTP clock skew detected: "
|
||||
"lsr=%p, now=%p, dlsr=%p (%d:%03dms), "
|
||||
"lsr=%u, now=%u, dlsr=%u (%u:%03ums), "
|
||||
"diff=%d",
|
||||
lsr, now, dlsr, dlsr/65536,
|
||||
(dlsr%65536)*1000/65536,
|
||||
|
@ -787,7 +787,7 @@ static void parse_rtcp_bye(pjmedia_rtcp_session *sess,
|
|||
|
||||
/* Just print RTCP BYE log */
|
||||
PJ_LOG(5, (sess->name, "Received RTCP BYE, reason: %.*s",
|
||||
reason.slen, reason.ptr));
|
||||
(int)reason.slen, reason.ptr));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1023,8 +1023,8 @@ PJ_DEF(void) pjmedia_rtcp_build_rtcp(pjmedia_rtcp_session *sess,
|
|||
dlsr = (pj_uint32_t)(ts.u64 - lsr_time);
|
||||
rr->dlsr = pj_htonl(dlsr);
|
||||
|
||||
TRACE_((sess->name,"Tx RTCP RR: lsr=%p, lsr_time=%p, now=%p, dlsr=%p"
|
||||
"(%ds:%03dms)",
|
||||
TRACE_((sess->name,"Tx RTCP RR: lsr=%u, lsr_time=%u, now=%u, dlsr=%u"
|
||||
"(%us:%03ums)",
|
||||
lsr,
|
||||
(pj_uint32_t)lsr_time,
|
||||
(pj_uint32_t)ts.u64,
|
||||
|
|
|
@ -479,7 +479,7 @@ void pjmedia_rtcp_xr_rx_rtcp_xr( pjmedia_rtcp_xr_session *sess,
|
|||
/* Calculate RR arrival time for DLRR */
|
||||
pj_get_timestamp(&sess->rx_lrr_time);
|
||||
|
||||
TRACE_((sess->name, "Rx RTCP SR: ntp_ts=%p", sess->rx_lrr,
|
||||
TRACE_((sess->name, "Rx RTCP SR: ntp_ts=%x",
|
||||
(pj_uint32_t)(sess->rx_lrr_time.u64*65536/
|
||||
sess->rtcp_session->ts_freq.u64)));
|
||||
}
|
||||
|
@ -516,8 +516,8 @@ void pjmedia_rtcp_xr_rx_rtcp_xr( pjmedia_rtcp_xr_session *sess,
|
|||
eedelay *= 1000;
|
||||
}
|
||||
|
||||
TRACE_((sess->name, "Rx RTCP XR DLRR: lrr=%p, dlrr=%p (%d:%03dms), "
|
||||
"now=%p, rtt=%p",
|
||||
TRACE_((sess->name, "Rx RTCP XR DLRR: lrr=%x, dlrr=%x (%d:%03dms), "
|
||||
"now=%x, rtt=%x",
|
||||
lrr, dlrr, dlrr/65536, (dlrr%65536)*1000/65536,
|
||||
now, (pj_uint32_t)eedelay));
|
||||
|
||||
|
@ -549,7 +549,7 @@ void pjmedia_rtcp_xr_rx_rtcp_xr( pjmedia_rtcp_xr_session *sess,
|
|||
}
|
||||
} else {
|
||||
PJ_LOG(5, (sess->name, "Internal RTCP NTP clock skew detected: "
|
||||
"lrr=%p, now=%p, dlrr=%p (%d:%03dms), "
|
||||
"lrr=%x, now=%x, dlrr=%x (%d:%03dms), "
|
||||
"diff=%d",
|
||||
lrr, now, dlrr, dlrr/65536,
|
||||
(dlrr%65536)*1000/65536,
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue