Skip to content

Commit

Permalink
fix logically dead code
Browse files Browse the repository at this point in the history
Fixes Coverity CID 40589, 40584, 40582, 40590, 40593, 40594, 40596,
      40597, 40598, 40599, 40600, 40602, 40604, 40606, 40607, 40608,
      40609, 40610, 40611, 40614, 40615, 40616, 40617, 40618
  • Loading branch information
razvancrainea committed Nov 11, 2016
1 parent 343a532 commit ee093cb
Show file tree
Hide file tree
Showing 17 changed files with 17 additions and 74 deletions.
3 changes: 1 addition & 2 deletions modules/b2b_entities/dlg.c
Expand Up @@ -2265,8 +2265,7 @@ void b2b_tm_cback(struct cell *t, b2b_table htable, struct tmcb_params *ps)
"transaction [%p]\n", dlg, dlg->uac_tran, t);
if(dlg_based_search)
dlg = b2b_search_htable_next_dlg( previous_dlg, htable, hash_index,
local_index, &from_tag,
(method_id==METHOD_CANCEL)?NULL:&to_tag, &callid);
local_index, &from_tag, &to_tag, &callid);
else
dlg = b2b_search_htable_next( previous_dlg, htable, hash_index,
local_index);
Expand Down
3 changes: 0 additions & 3 deletions modules/carrierroute/carrier_tree.c
Expand Up @@ -99,9 +99,6 @@ int prepare_route_tree(void) {
LM_ERR("could not load routing data\n");
return -1;
}
if (new_data == NULL) {
return -1;
}

if (rule_fixup(new_data) < 0) {
LM_ERR("could not fixup rules\n");
Expand Down
2 changes: 1 addition & 1 deletion modules/db_berkeley/bdb_lib.c
Expand Up @@ -1141,7 +1141,7 @@ int bdblib_valtochar(table_p _tp, int* _lres, char* _k, int* _klen, db_val_t* _v
the schema. the app does not know the order
of the columns in our schema!
*/
k = (_lres) ? _lres[j] : j;
k = _lres[j];

/*
* k index will remap back to our schema order; like i
Expand Down
2 changes: 1 addition & 1 deletion modules/db_berkeley/db_berkeley.c
Expand Up @@ -697,7 +697,7 @@ int bdb_insert(db_con_t* _h, db_key_t* _k, db_val_t* _v, int _n)

/* verify col types provided */
for(i=0; i<_n; i++)
{ j = (lkey)?lkey[i]:i;
{ j = lkey[i];
if(bdb_is_neq_type(_tp->colp[j]->type, _v[i].type))
{
LM_WARN("incompatible types v[%d] - c[%d]!\n", i, j);
Expand Down
12 changes: 5 additions & 7 deletions modules/db_text/dbt_base.c
Expand Up @@ -314,12 +314,10 @@ int dbt_insert(db_con_t* _h, db_key_t* _k, db_val_t* _v, int _n)
goto error;
}

if(_k)
{
lkey = dbt_get_refs(_tbc, _k, _n);
if(!lkey)
goto error;
}
lkey = dbt_get_refs(_tbc, _k, _n);
if(!lkey)
goto error;

_drp = dbt_row_new(_tbc->nrcols);
if(!_drp)
{
Expand All @@ -329,7 +327,7 @@ int dbt_insert(db_con_t* _h, db_key_t* _k, db_val_t* _v, int _n)

for(i=0; i<_n; i++)
{
j = (lkey)?lkey[i]:i;
j = lkey[i];
if(dbt_is_neq_type(_tbc->colv[j]->type, _v[i].type))
{
LM_ERR("incompatible types v[%d] - c[%d]!\n", i, j);
Expand Down
2 changes: 1 addition & 1 deletion modules/drouting/prefix_tree.c
Expand Up @@ -104,7 +104,7 @@ internal_check_rt(
ok_exit:
/* if rules are still in this node, point to the next index */
*rgidx = (rtlw->next) ? j : 0 ;
return rtlw?rtlw->rtl:0;
return rtlw->rtl;
}


Expand Down
5 changes: 0 additions & 5 deletions modules/imc/imc.c
Expand Up @@ -317,11 +317,6 @@ int add_from_db(void)
imc_dbf.free_result(imc_db, r_res);
r_res = NULL;
}
if(m_res)
{
imc_dbf.free_result(imc_db, m_res);
m_res = NULL;
}

return 0;

Expand Down
2 changes: 0 additions & 2 deletions modules/lua/sipapi.c
Expand Up @@ -241,8 +241,6 @@ static int l_siplua_getContact(lua_State *L)
for (_c = ((contact_body_t *)_p->parsed)->contacts; _c; _c = _c->next)
{
/* siplua_log(L_DBG, "l_siplua_getContact _c/%p", _c); */
if (!_c)
break;
lua_pushinteger(L, n++);
lua_newtable(L);
lua_pushstring(L, "name");
Expand Down
2 changes: 1 addition & 1 deletion modules/permissions/hash.c
Expand Up @@ -151,7 +151,7 @@ int hash_match(struct sip_msg *msg, struct address_list** table,
}

/* group not found */
if (!node || i == PERM_HASH_SIZE) {
if (!node) {
LM_DBG("specified group %u does not exist in hash table\n", grp);
return -2;
}
Expand Down
7 changes: 0 additions & 7 deletions modules/presence/hash.c
Expand Up @@ -169,13 +169,6 @@ subs_t* mem_copy_subs(subs_t* s, int mem_type)
return dest;

error:
if(dest)
{
if(mem_type == PKG_MEM_TYPE)
pkg_free(dest);
else
shm_free(dest);
}
return NULL;
}

Expand Down
6 changes: 0 additions & 6 deletions modules/presence/notify.c
Expand Up @@ -448,12 +448,6 @@ str* get_wi_notify_body(subs_t* subs, subs_t* watcher_subs)
return notify_body;

error:
if(notify_body)
{
if(notify_body->s)
xmlFree(notify_body->s);
pkg_free(notify_body);
}
free_watcher_list(watchers);
return NULL;
}
Expand Down
1 change: 0 additions & 1 deletion modules/presence/presence.c
Expand Up @@ -729,7 +729,6 @@ static inline int mi_print_shtable_record(struct mi_node *rpl, subs_t* s)
attr = add_mi_attr(node, MI_DUP_VALUE, "event_id", 8, s->event_id.s, s->event_id.len);
if (attr==NULL) goto error;
*/
if (attr==NULL) goto error;
_ts = (time_t)s->expires;
date_buf_len = strftime(date_buf, MI_DATE_BUF_LEN - 1,
"%Y-%m-%d %H:%M:%S", localtime(&_ts));
Expand Down
3 changes: 3 additions & 0 deletions modules/presence_xml/notify_body.c
Expand Up @@ -1218,6 +1218,8 @@ str* get_final_notify_body( subs_t *subs, str* notify_body, xmlNodePtr rule_node
xmlFree(new_body->s);
pkg_free(new_body);
}
/* none of these are used before error!
* Detected by Coverity 40606-40609
if(class_cont)
xmlFree(class_cont);
if(occurence_ID)
Expand All @@ -1226,6 +1228,7 @@ str* get_final_notify_body( subs_t *subs, str* notify_body, xmlNodePtr rule_node
xmlFree(deviceID);
if(service_uri)
xmlFree(service_uri);
*/

return NULL;
}
6 changes: 0 additions & 6 deletions modules/pua_dialoginfo/dialog_publish.c
Expand Up @@ -277,12 +277,6 @@ str* build_dialoginfo(char *state, struct to_body *entity, struct to_body *peer,
return body;

error:
if(body)
{
if(body->s)
xmlFree(body->s);
pkg_free(body);
}
if(doc)
xmlFreeDoc(doc);
return NULL;
Expand Down
10 changes: 1 addition & 9 deletions modules/pua_xmpp/xmpp2simple.c
Expand Up @@ -326,12 +326,6 @@ str* build_pidf(xmlNodePtr pres_node, char* uri, char* resource)
error:
if(entity)
pkg_free(entity);
if(body)
{
if(body->s)
xmlFree(body->s);
pkg_free(body);
}
if(status_cont)
xmlFree(status_cont);
if(show_cont)
Expand Down Expand Up @@ -437,7 +431,7 @@ int build_publish(xmlNodePtr pres_node, int expires)
int presence_subscribe(xmlNodePtr pres_node, int expires,int flag)
{
subs_info_t subs;
char* type= NULL, *uri= NULL;
char *uri= NULL;
str to_uri= {0, 0};
str from_uri= {0, 0};
char buf_from[256];
Expand Down Expand Up @@ -505,8 +499,6 @@ int presence_subscribe(xmlNodePtr pres_node, int expires,int flag)
return 0;

error:
if(type)
xmlFree(type);
return -1;
}

19 changes: 0 additions & 19 deletions modules/rls/subscribe.c
Expand Up @@ -269,8 +269,6 @@ int get_resource_list(str* service_uri, str owner_user, str owner_domain,
pkg_free(etag->s);
pkg_free(etag);
}
if(xml_doc)
xmlFreeDoc(xml_doc);
return -1;
}

Expand Down Expand Up @@ -432,7 +430,6 @@ int rls_handle_subscribe(struct sip_msg* msg, char* s1, char* s2)
struct to_body *pto, *pfrom = NULL;
subs_t subs;
pres_ev_t* event= NULL;
str* contact= NULL;
xmlDocPtr doc= NULL;
xmlNodePtr service_node= NULL;
unsigned int hash_code= 0;
Expand Down Expand Up @@ -672,13 +669,6 @@ int rls_handle_subscribe(struct sip_msg* msg, char* s1, char* s2)
goto error_free;
}

if(contact)
{
if(contact->s)
pkg_free(contact->s);
pkg_free(contact);
}

pkg_free(subs.pres_uri.s);
if(subs.record_route.s)
pkg_free(subs.record_route.s);
Expand All @@ -700,12 +690,6 @@ int rls_handle_subscribe(struct sip_msg* msg, char* s1, char* s2)


error_free:
if(contact)
{
if(contact->s)
pkg_free(contact->s);
pkg_free(contact);
}
if(subs.pres_uri.s)
pkg_free(subs.pres_uri.s);

Expand Down Expand Up @@ -853,7 +837,6 @@ int send_resource_subs(char* uri, void* param)

int resource_subscriptions(subs_t* subs, xmlNodePtr rl_node)
{
char* uri= NULL;
subs_info_t s;
str wuri= {0, 0};
str did_str= {0, 0};
Expand Down Expand Up @@ -944,8 +927,6 @@ int resource_subscriptions(subs_t* subs, xmlNodePtr rl_node)
error:
if(wuri.s)
pkg_free(wuri.s);
if(uri)
xmlFree(uri);
if(did_str.s)
pkg_free(did_str.s);
return -1;
Expand Down
6 changes: 3 additions & 3 deletions modules/tls_mgm/tls_select.c
Expand Up @@ -302,7 +302,7 @@ int tlsops_check_cert(struct sip_msg *msg, pv_param_t *param,
if (!c) return -1;

ssl = get_ssl(c);
if (!ssl) goto err;
if (!ssl) goto error;

if ((cert = SSL_get_peer_certificate(ssl)) && SSL_get_verify_result(ssl) == err) {
res->rs.s = succ.s;
Expand All @@ -319,8 +319,8 @@ int tlsops_check_cert(struct sip_msg *msg, pv_param_t *param,
tcp_conn_release(c,0);

return 0;
err:
if (cert) X509_free(cert);
error:
/* if (cert) X509_free(cert); */
if (c) tcp_conn_release(c,0);
return pv_get_null(msg, param, res);
}
Expand Down

0 comments on commit ee093cb

Please sign in to comment.