Skip to content

Commit

Permalink
Misc Coverity fixes (#4145)
Browse files Browse the repository at this point in the history
  • Loading branch information
sauwming authored Nov 11, 2024
1 parent 5259a21 commit e127571
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pjlib-util/src/pjlib-util/crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ PJ_DEF(pj_uint32_t) pj_crc32_update(pj_crc32_context *ctx,
data += 4;
}

while (nbytes--) {
for (; nbytes; nbytes--) {
crc = crc_tab[CRC32_INDEX(crc) ^ *data++] ^ CRC32_SHIFTED(crc);
}

Expand Down
2 changes: 1 addition & 1 deletion pjlib-util/src/pjlib-util/http_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ static pj_status_t http_response_parse(pj_pool_t *pool,
pj_scan_fini(&scanner);

/* Parse the response headers. */
size = i - 2 - (end_status - newdata);
size = (i < 2)? 0: i - 2 - (end_status - newdata);
if (size > 0) {
status = http_headers_parse(end_status + 1, size,
&response->headers);
Expand Down
4 changes: 3 additions & 1 deletion pjlib/src/pj/atomic_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ class AtomicQueue {
return old_ptr;
}

AtomicQueue():name_(""){}
AtomicQueue():maxItemCnt_(0), itemSize_(0), ptrWrite(0),
ptrRead(0), buffer(NULL), name_("")
{}
};

struct pj_atomic_queue_t
Expand Down
2 changes: 2 additions & 0 deletions pjlib/src/pj/pool_caching.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ PJ_DEF(void) pj_caching_pool_init( pj_caching_pool *cp,
*/
//cp->factory.on_block_alloc = &cpool_on_block_alloc;
//cp->factory.on_block_free = &cpool_on_block_free;
PJ_UNUSED_ARG(cpool_on_block_alloc);
PJ_UNUSED_ARG(cpool_on_block_free);

pool = pj_pool_create_on_buf("cachingpool", cp->pool_buf, sizeof(cp->pool_buf));
status = pj_lock_create_simple_mutex(pool, "cachingpool", &cp->lock);
Expand Down
6 changes: 4 additions & 2 deletions pjlib/src/pj/unittest.c
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ PJ_DEF(pj_status_t) pj_test_create_text_runner(
text_runner_t *runner;
unsigned i;
pj_status_t status;
unsigned nthreads = (PJ_HAS_THREADS? 1: 0);

*p_runner = NULL;

Expand All @@ -795,13 +796,14 @@ PJ_DEF(pj_status_t) pj_test_create_text_runner(

if (prm) {
pj_memcpy(&runner->base.prm, prm, sizeof(*prm));
nthreads = prm->nthreads;
} else {
pj_test_runner_param_default(&runner->base.prm);
}
runner->base.prm.nthreads = 0;
runner->threads = (pj_thread_t**) pj_pool_calloc(pool, prm->nthreads,
runner->threads = (pj_thread_t**) pj_pool_calloc(pool, nthreads,
sizeof(pj_thread_t*));
for (i=0; i<prm->nthreads; ++i) {
for (i=0; i<nthreads; ++i) {
thread_param_t *tprm = PJ_POOL_ZALLOC_T(pool, thread_param_t);
tprm->runner = runner;
tprm->tid = i+1;
Expand Down
1 change: 0 additions & 1 deletion pjlib/src/pjlib-test/fifobuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ static int fifobuf_misc_test()
LOOP=10000 };
pj_pool_t *pool;
pj_fifobuf_t fifo;
pj_size_t available = SIZE;
void *entries[MAX_ENTRIES];
void *buffer;
int i;
Expand Down
4 changes: 4 additions & 0 deletions pjlib/src/pjlib-test/ssl_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,8 @@ static pj_status_t load_cert_to_buf(pj_pool_t *pool, const pj_str_t *file_name,
}
#endif

#if (PJ_SSL_SOCK_IMP == PJ_SSL_SOCK_IMP_SCHANNEL)

static pj_status_t load_cert_from_store(pj_pool_t *pool,
pj_ssl_cert_t **p_cert)
{
Expand Down Expand Up @@ -573,6 +575,8 @@ static pj_status_t load_cert_from_store(pj_pool_t *pool,
#endif
}

#endif

static int echo_test(pj_ssl_sock_proto srv_proto, pj_ssl_sock_proto cli_proto,
pj_ssl_cipher srv_cipher, pj_ssl_cipher cli_cipher,
pj_bool_t req_client_cert, pj_bool_t client_provide_cert)
Expand Down
6 changes: 4 additions & 2 deletions pjmedia/src/pjmedia/endpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,10 @@ pjmedia_endpt_create_audio_sdp(pjmedia_endpt *endpt,
break;

codec_info = &endpt->codec_mgr.codec_desc[i].info;
pjmedia_codec_mgr_get_default_param(&endpt->codec_mgr, codec_info,
&codec_param);
status = pjmedia_codec_mgr_get_default_param(&endpt->codec_mgr,
codec_info, &codec_param);
if (status != PJ_SUCCESS)
return status;
fmt = &m->desc.fmt[m->desc.fmt_count++];
pt = codec_info->pt;

Expand Down
2 changes: 1 addition & 1 deletion pjmedia/src/pjmedia/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ static void create_dtmf_payload(pjmedia_stream *stream,
}
#endif
if (!pj_stricmp2(&stream->si.fmt.encoding_name, "opus")) {
ts_modifier = 48000 / stream->codec_param.info.clock_rate;
ts_modifier = (float)48000 / stream->codec_param.info.clock_rate;
}
duration = ts_modifier * digit->send_duration * stream->codec_param.info.clock_rate / 1000;
}
Expand Down
3 changes: 2 additions & 1 deletion pjsip/src/pjsip/sip_multipart.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ static pjsip_multipart_part *parse_multipart_part(pj_pool_t *pool,
const pjsip_media_type *pct)
{
pjsip_multipart_part *part = pjsip_multipart_create_part(pool);
char *p = start, *end = start+len, *end_hdr = NULL, *start_body = NULL;
char *p = start, *end = start+len, *end_hdr = NULL, *start_body;
pjsip_ctype_hdr *ctype_hdr = NULL;

TRACE_((THIS_FILE, "Parsing part: begin--\n%.*s\n--end",
Expand All @@ -657,6 +657,7 @@ static pjsip_multipart_part *parse_multipart_part(pj_pool_t *pool,
/* Empty body section */
end_hdr = end;
start_body = ++p;
break;
} else if ((p>=start+1 && *(p-1)=='\n') ||
(p>=start+2 && *(p-1)=='\r' && *(p-2)=='\n'))
{
Expand Down
2 changes: 2 additions & 0 deletions pjsip/src/pjsua-lib/pjsua_aud.c
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,8 @@ PJ_DEF(pj_status_t) pjsua_player_create( const pj_str_t *filename,
pjmedia_port *port;
pj_status_t status = PJ_SUCCESS;

PJ_ASSERT_RETURN(filename && filename->slen > 0, PJ_EINVAL);

if (pjsua_var.player_cnt >= PJ_ARRAY_SIZE(pjsua_var.player))
return PJ_ETOOMANY;

Expand Down

0 comments on commit e127571

Please sign in to comment.