osaf/services/saf/cpsv/cpd/cpd_db.c | 8 ++--- osaf/services/saf/cpsv/cpd/cpd_evt.c | 4 +- osaf/services/saf/cpsv/cpd/cpd_imm.c | 2 +- osaf/services/saf/cpsv/cpd/cpd_tmr.c | 2 +- osaf/services/saf/cpsv/cpnd/cpnd_evt.c | 49 ++++++++++++++++---------------- osaf/services/saf/cpsv/cpnd/cpnd_proc.c | 2 +- 6 files changed, 32 insertions(+), 35 deletions(-)
This enhancement fix following warning results from cppcheck 1.74: Either the condition is redundant or there is possible null pointer dereference This enhancement does not fix following warnings when they are not problems: Possible null pointer dereference Style and performance warnings diff --git a/osaf/services/saf/cpsv/cpd/cpd_db.c b/osaf/services/saf/cpsv/cpd/cpd_db.c --- a/osaf/services/saf/cpsv/cpd/cpd_db.c +++ b/osaf/services/saf/cpsv/cpd/cpd_db.c @@ -842,12 +842,10 @@ uint32_t cpd_cpnd_info_node_delete(CPD_C } /* Free the Client Node */ - if (cpnd_info_node) { - if (cpnd_info_node->cpnd_ret_timer.uarg) - ncshm_destroy_hdl(NCS_SERVICE_ID_CPD, cpnd_info_node->cpnd_ret_timer.uarg); + if (cpnd_info_node->cpnd_ret_timer.uarg) + ncshm_destroy_hdl(NCS_SERVICE_ID_CPD, cpnd_info_node->cpnd_ret_timer.uarg); - m_MMGR_FREE_CPD_CPND_INFO_NODE(cpnd_info_node); - } + m_MMGR_FREE_CPD_CPND_INFO_NODE(cpnd_info_node); return rc; diff --git a/osaf/services/saf/cpsv/cpd/cpd_evt.c b/osaf/services/saf/cpsv/cpd/cpd_evt.c --- a/osaf/services/saf/cpsv/cpd/cpd_evt.c +++ b/osaf/services/saf/cpsv/cpd/cpd_evt.c @@ -1434,7 +1434,7 @@ static uint32_t cpd_evt_proc_mds_evt(CPD /* No Checkpoints on this node, */ TRACE_LEAVE(); return NCSCC_RC_SUCCESS; - } else if (node_info && (node_info->ckpt_ref_list == NULL)) { + } else if (node_info->ckpt_ref_list == NULL) { cpd_cpnd_info_node_delete(cb, node_info); TRACE_LEAVE(); return NCSCC_RC_SUCCESS; @@ -1448,7 +1448,7 @@ static uint32_t cpd_evt_proc_mds_evt(CPD /* No Checkpoints on this node, */ return NCSCC_RC_SUCCESS; } - else if (node_info && (node_info->ckpt_ref_list == NULL)) { + else if (node_info->ckpt_ref_list == NULL) { cpd_cpnd_info_node_delete(cb, node_info); TRACE_LEAVE(); return NCSCC_RC_SUCCESS; diff --git a/osaf/services/saf/cpsv/cpd/cpd_imm.c b/osaf/services/saf/cpsv/cpd/cpd_imm.c --- a/osaf/services/saf/cpsv/cpd/cpd_imm.c +++ b/osaf/services/saf/cpsv/cpd/cpd_imm.c @@ -1014,7 +1014,7 @@ SaUint32T cpd_get_scAbsenceAllowed_attr( /* Handle the global scAbsenceAllowed_flag */ attribute = attributes[0]; - TRACE("%s attrName \"%s\"",__FUNCTION__,attribute->attrName); + TRACE("%s attrName \"%s\"",__FUNCTION__,attribute?attribute->attrName:""); if ((attribute != NULL) && (attribute->attrValuesNumber != 0)) { /* scAbsenceAllowed has value. Get the value */ value = attribute->attrValues[0]; diff --git a/osaf/services/saf/cpsv/cpd/cpd_tmr.c b/osaf/services/saf/cpsv/cpd/cpd_tmr.c --- a/osaf/services/saf/cpsv/cpd/cpd_tmr.c +++ b/osaf/services/saf/cpsv/cpd/cpd_tmr.c @@ -42,7 +42,7 @@ void cpd_timer_expiry(NCSCONTEXT uarg) CPSV_EVT *evt = NULL; uint32_t cpd_hdl = m_CPD_GET_CB_HDL; - TRACE("cpd_timer_expiry(uarg=%p, type=%u)", uarg, tmr->type); + TRACE("cpd_timer_expiry(uarg=%p, type=%u)", uarg, tmr ? tmr->type : 0); /* post a message to the corresponding component */ if ((cb = (CPD_CB *)ncshm_take_hdl(NCS_SERVICE_ID_CPD, cpd_hdl)) == NULL) diff --git a/osaf/services/saf/cpsv/cpnd/cpnd_evt.c b/osaf/services/saf/cpsv/cpnd/cpnd_evt.c --- a/osaf/services/saf/cpsv/cpnd/cpnd_evt.c +++ b/osaf/services/saf/cpsv/cpnd/cpnd_evt.c @@ -759,7 +759,7 @@ static uint32_t cpnd_evt_proc_ckpt_open( send_evt.info.cpa.info.openRsp.error = SA_AIS_ERR_NO_MEMORY; goto agent_rsp; } - if (out_evt && out_evt->info.cpnd.info.ckpt_info.error != SA_AIS_OK) { + if (out_evt->info.cpnd.info.ckpt_info.error != SA_AIS_OK) { send_evt.info.cpa.info.openRsp.error = out_evt->info.cpnd.info.ckpt_info.error; goto agent_rsp; } @@ -872,10 +872,8 @@ static uint32_t cpnd_evt_proc_ckpt_open( goto ckpt_shm_node_free_error; } } - if (out_evt) { - cpnd_evt_destroy(out_evt); - out_evt = NULL; - } + cpnd_evt_destroy(out_evt); + out_evt = NULL; /* if not the first collocated replica, response will come from REP_ADD processing */ @@ -2523,20 +2521,18 @@ static uint32_t cpnd_evt_proc_ckpt_sect_ /* Send the arrival callback */ memset(&ckpt_data, '\0', sizeof(CPSV_CKPT_DATA)); - if (sec_info) { - ckpt_data.sec_id = sec_info->sec_id; - ckpt_data.data = NULL; - ckpt_data.dataSize = 0; - ckpt_data.dataOffset = 0; - - memset(&ckpt_access, '\0', sizeof(CPSV_CKPT_ACCESS)); - ckpt_access.ckpt_id = cp_node->ckpt_id; - ckpt_access.lcl_ckpt_id = evt->info.sec_delReq.lcl_ckpt_id; - ckpt_access.agent_mdest = evt->info.sec_delReq.agent_mdest; - ckpt_access.num_of_elmts = 1; - ckpt_access.data = &ckpt_data; - cpnd_proc_ckpt_arrival_info_ntfy(cb, cp_node, &ckpt_access, sinfo); - } + ckpt_data.sec_id = sec_info->sec_id; + ckpt_data.data = NULL; + ckpt_data.dataSize = 0; + ckpt_data.dataOffset = 0; + + memset(&ckpt_access, '\0', sizeof(CPSV_CKPT_ACCESS)); + ckpt_access.ckpt_id = cp_node->ckpt_id; + ckpt_access.lcl_ckpt_id = evt->info.sec_delReq.lcl_ckpt_id; + ckpt_access.agent_mdest = evt->info.sec_delReq.agent_mdest; + ckpt_access.num_of_elmts = 1; + ckpt_access.data = &ckpt_data; + cpnd_proc_ckpt_arrival_info_ntfy(cb, cp_node, &ckpt_access, sinfo); if (cp_node->cpnd_dest_list != NULL) { /* yes ,go trough cp_node->cpnd_dest_list(sync send) */ @@ -3984,11 +3980,7 @@ static uint32_t cpnd_proc_cpd_new_active break; } - if (node) - m_MMGR_FREE_CPND_CPD_DEFERRED_REQ_NODE(node); - - node = NULL; - + m_MMGR_FREE_CPND_CPD_DEFERRED_REQ_NODE(node); node = (CPND_CPD_DEFERRED_REQ_NODE *)ncs_dequeue(&cb->cpnd_cpd_deferred_reqs_list); } TRACE_LEAVE(); @@ -4708,7 +4700,7 @@ static uint32_t cpnd_transfer_replica(CP while (1) { - if (((tmp_sec_info) && ((size + tmp_sec_info->sec_size) > MAX_SYNC_TRANSFER_SIZE)) + if (((size + tmp_sec_info->sec_size) > MAX_SYNC_TRANSFER_SIZE) || (total_num == cp_node->replica_info.n_secs)) { send_evt.info.cpnd.info.ckpt_nd2nd_sync.num_of_elmts = num; @@ -4766,6 +4758,13 @@ static uint32_t cpnd_transfer_replica(CP total_num++; tmp_sec_info = cpnd_ckpt_sec_get_next(&cp_node->replica_info, tmp_sec_info); + if (tmp_sec_info == NULL) { + rc = NCSCC_RC_FAILURE; + TRACE_4("cpnd ckpt memory get next allocation failed"); + send_evt.info.cpnd.info.ckpt_nd2nd_sync.data = sec_data; + cpnd_proc_free_cpsv_ckpt_data(send_evt.info.cpnd.info.ckpt_nd2nd_sync.data); + return rc; + } } TRACE_LEAVE(); diff --git a/osaf/services/saf/cpsv/cpnd/cpnd_proc.c b/osaf/services/saf/cpsv/cpnd/cpnd_proc.c --- a/osaf/services/saf/cpsv/cpnd/cpnd_proc.c +++ b/osaf/services/saf/cpsv/cpnd/cpnd_proc.c @@ -2817,7 +2817,7 @@ static SaUint32T cpnd_get_imm_attr(char void *value; attribute = attributes[0]; - TRACE("%s attrName \"%s\"",__FUNCTION__,attribute->attrName); + TRACE("%s attrName \"%s\"",__FUNCTION__,attribute?attribute->attrName:""); if ((attribute != NULL) && (attribute->attrValuesNumber != 0)) { value = attribute->attrValues[0]; rc_attr_val = *((SaUint32T *) value); ------------------------------------------------------------------------------ _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel