Skip to content

Commit 2776fe3

Browse files
authored
Fix Coverity and build warnings across multiple modules (#4637)
1 parent 8d5a561 commit 2776fe3

File tree

6 files changed

+32
-7
lines changed

6 files changed

+32
-7
lines changed

pjlib/src/pj/os_core_unix.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,9 @@ PJ_DEF(pj_status_t) pj_atomic_create( pj_pool_t *pool,
10541054
pj_atomic_value_t initial,
10551055
pj_atomic_t **ptr_atomic)
10561056
{
1057+
#if EMULATE_ATOMICS
10571058
pj_status_t rc;
1059+
#endif
10581060
pj_atomic_t *atomic_var;
10591061

10601062
atomic_var = PJ_POOL_ZALLOC_T(pool, pj_atomic_t);
@@ -1081,7 +1083,9 @@ PJ_DEF(pj_status_t) pj_atomic_create( pj_pool_t *pool,
10811083
*/
10821084
PJ_DEF(pj_status_t) pj_atomic_destroy( pj_atomic_t *atomic_var )
10831085
{
1086+
#if EMULATE_ATOMICS
10841087
pj_status_t status;
1088+
#endif
10851089

10861090
PJ_ASSERT_RETURN(atomic_var, PJ_EINVAL);
10871091

@@ -1101,7 +1105,9 @@ PJ_DEF(pj_status_t) pj_atomic_destroy( pj_atomic_t *atomic_var )
11011105
*/
11021106
PJ_DEF(void) pj_atomic_set(pj_atomic_t *atomic_var, pj_atomic_value_t value)
11031107
{
1108+
#if EMULATE_ATOMICS
11041109
pj_status_t status;
1110+
#endif
11051111

11061112
PJ_CHECK_STACK();
11071113
PJ_ASSERT_ON_FAIL(atomic_var, return);

pjlib/src/pj/pool_caching.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,10 @@ PJ_DEF(void) pj_caching_pool_destroy( pj_caching_pool *cp )
122122
}
123123

124124
if (cp->lock) {
125+
pj_status_t status;
125126
pj_lock_destroy(cp->lock);
126-
pj_lock_create_null_mutex(NULL, "cachingpool", &cp->lock);
127+
status = pj_lock_create_null_mutex(NULL, "cachingpool", &cp->lock);
128+
PJ_ASSERT_ON_FAIL(status==PJ_SUCCESS, return);
127129
}
128130
}
129131

pjmedia/src/test/mips_test.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,7 @@ static pj_status_t init_l16_default(pjmedia_endpt *endpt)
10131013
return pjmedia_codec_l16_init(endpt, 0);
10141014
}
10151015

1016+
#if PJMEDIA_CODEC_L16_HAS_8KHZ_MONO
10161017
/* L16/8000/1 benchmark */
10171018
static pjmedia_port* l16_8_encode_decode(pj_pool_t *pool,
10181019
unsigned clock_rate,
@@ -1026,7 +1027,9 @@ static pjmedia_port* l16_8_encode_decode(pj_pool_t *pool,
10261027
clock_rate, channel_count,
10271028
samples_per_frame, flags, te);
10281029
}
1030+
#endif
10291031

1032+
#if PJMEDIA_CODEC_L16_HAS_16KHZ_MONO
10301033
/* L16/16000/1 benchmark */
10311034
static pjmedia_port* l16_16_encode_decode(pj_pool_t *pool,
10321035
unsigned clock_rate,
@@ -1041,6 +1044,7 @@ static pjmedia_port* l16_16_encode_decode(pj_pool_t *pool,
10411044
samples_per_frame, flags, te);
10421045
}
10431046
#endif
1047+
#endif
10441048

10451049
/***************************************************************************/
10461050
/* WSOLA PLC mode */

pjsip-apps/src/samples/stateful_proxy.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,20 @@ static pj_bool_t proxy_on_rx_request( pjsip_rx_data *rdata )
271271
uas_data2 = (struct uas_data*) invite_uas->mod_data[mod_tu.id];
272272
if (uas_data2->uac_tsx && uas_data2->uac_tsx->status_code < 200) {
273273
pjsip_tx_data *cancel;
274+
pj_status_t status;
274275

275276
pj_grp_lock_acquire(uas_data2->uac_tsx->grp_lock);
276277

277-
pjsip_endpt_create_cancel(global.endpt, uas_data2->uac_tsx->last_tx,
278-
&cancel);
279-
pjsip_endpt_send_request(global.endpt, cancel, -1, NULL, NULL);
278+
status = pjsip_endpt_create_cancel(global.endpt, uas_data2->uac_tsx->last_tx,
279+
&cancel);
280+
if (status == PJ_SUCCESS) {
281+
status = pjsip_endpt_send_request(global.endpt, cancel, -1, NULL, NULL);
282+
if (status != PJ_SUCCESS) {
283+
PJ_LOG(4,(THIS_FILE, "Failed to send CANCEL request (%d)", status));
284+
}
285+
} else {
286+
PJ_LOG(4,(THIS_FILE, "Failed to create CANCEL request (%d)", status));
287+
}
280288

281289
pj_grp_lock_release(uas_data2->uac_tsx->grp_lock);
282290
}

pjsip/src/pjsua-lib/pjsua_acc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4786,8 +4786,8 @@ PJ_DEF(pj_status_t) pjsua_acc_send_response(pjsua_acc_id acc_id,
47864786
}
47874787

47884788
if (msg_data) {
4789-
pjsip_hdr *hdr;
4790-
for (hdr = &msg_data->hdr_list; hdr && hdr != &msg_data->hdr_list;
4789+
const pjsip_hdr *hdr;
4790+
for (hdr = msg_data->hdr_list.next; hdr && hdr != &msg_data->hdr_list;
47914791
hdr=hdr->next) {
47924792
pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)pjsip_hdr_clone(
47934793
tdata->pool, hdr));

pjsip/src/pjsua2-test/instant_messaging.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,12 @@ InstantMessagingTests::~InstantMessagingTests()
105105
senderAcc.reset();
106106
receiverAcc.reset();
107107

108-
ep.libDestroy();
108+
try {
109+
ep.libDestroy();
110+
} catch (const pj::Error& e) {
111+
// Log the error but don't rethrow from destructor
112+
std::cerr << "Error during libDestroy: " << e.reason << std::endl;
113+
}
109114
}
110115

111116
void InstantMessagingTests::immediateResponse()

0 commit comments

Comments
 (0)