osaf/services/saf/amf/amfd/cluster.cc | 3 +-- osaf/services/saf/amf/amfd/comp.cc | 17 ++++++++++------- osaf/services/saf/amf/amfd/compcstype.cc | 5 +++++ osaf/services/saf/amf/amfd/comptype.cc | 7 +++++-- osaf/services/saf/amf/amfd/csi.cc | 20 ++++++++++++++++++-- osaf/services/saf/amf/amfd/csiattr.cc | 2 ++ osaf/services/saf/amf/amfd/cstype.cc | 4 +++- osaf/services/saf/amf/amfd/ctcstype.cc | 14 +++++--------- 8 files changed, 49 insertions(+), 23 deletions(-)
* Unnecessary header file (HFA) * Logically dead code (DEADCODE) * Dereference null return value (NULL_RETURNS) * Uninitialized scalar variable (UNINIT) * Unused pointer value (UNUSED_VALUE) diff --git a/osaf/services/saf/amf/amfd/cluster.cc b/osaf/services/saf/amf/amfd/cluster.cc --- a/osaf/services/saf/amf/amfd/cluster.cc +++ b/osaf/services/saf/amf/amfd/cluster.cc @@ -24,7 +24,6 @@ #include <cluster.h> #include <imm.h> #include <evt.h> -#include <proc.h> /* Singleton cluster object */ static AVD_CLUSTER _avd_cluster; @@ -201,7 +200,7 @@ SaAisErrorT avd_cluster_config_get(void) { SaAisErrorT error, rc = SA_AIS_ERR_FAILED_OPERATION; - SaImmSearchHandleT searchHandle; + SaImmSearchHandleT searchHandle = 0; SaImmSearchParametersT_2 searchParam; SaNameT dn; const SaImmAttrValuesT_2 **attributes; diff --git a/osaf/services/saf/amf/amfd/comp.cc b/osaf/services/saf/amf/amfd/comp.cc --- a/osaf/services/saf/amf/amfd/comp.cc +++ b/osaf/services/saf/amf/amfd/comp.cc @@ -184,6 +184,11 @@ avsv_sanamet_init(&comp->comp_info.name, &dn, "safSu"); comp->su = avd_su_get(&dn); + if (comp->su == NULL) { + LOG_ER("component '%s' references an invalid SU", + comp->comp_info.name.value); + osafassert(comp->su); + } avd_comp_db_add(comp); comp->comp_type = avd_comptype_get(&comp->saAmfCompType); @@ -412,7 +417,6 @@ static AVD_COMP *comp_create(const SaNameT *dn, const SaImmAttrValuesT_2 **attributes) { - int rc = -1; AVD_COMP *comp; char *cmd_argv; const char *str; @@ -585,13 +589,7 @@ comp->max_num_csi_actv = -1; // TODO comp->max_num_csi_stdby = -1; // TODO - rc = 0; done: - if (rc != 0) { - avd_comp_delete(comp); - comp = NULL; - } - return comp; } @@ -788,6 +786,7 @@ TRACE_ENTER(); comp = avd_comp_get(&opdata->objectName); + osafassert(comp); while ((attr_mod = opdata->param.modify.attrMods[i++]) != NULL) { const SaImmAttrValuesT_2 *attribute = &attr_mod->modAttr; @@ -1028,6 +1027,7 @@ TRACE_ENTER(); comp = avd_comp_get(&opdata->objectName); + osafassert(comp); if (comp->su->saAmfSUAdminState != SA_AMF_ADMIN_LOCKED_INSTANTIATION) { report_ccb_validation_error(opdata, "SU admin state is not locked instantiation required for deletion"); @@ -1085,6 +1085,7 @@ param.act = AVSV_OBJ_OPR_MOD; comp = avd_comp_get(&opdata->objectName); + osafassert(comp); param.name = comp->comp_info.name; comp_type = avd_comptype_get(&comp->saAmfCompType); @@ -1103,6 +1104,7 @@ if ((attr_mod->modType == SA_IMM_ATTR_VALUES_DELETE) || (attribute->attrValues == NULL)) { /* Attribute value is deleted, revert to default value */ value_is_deleted = true; + osafassert(comp_type); } else { /* Attribute value is modified */ value_is_deleted = false; @@ -1573,6 +1575,7 @@ void avd_comp_constructor(void) { NCS_PATRICIA_PARAMS patricia_params; + memset(&patricia_params, 0, sizeof(NCS_PATRICIA_PARAMS)); patricia_params.key_size = sizeof(SaNameT); osafassert(ncs_patricia_tree_init(&comp_db, &patricia_params) == NCSCC_RC_SUCCESS); diff --git a/osaf/services/saf/amf/amfd/compcstype.cc b/osaf/services/saf/amf/amfd/compcstype.cc --- a/osaf/services/saf/amf/amfd/compcstype.cc +++ b/osaf/services/saf/amf/amfd/compcstype.cc @@ -251,6 +251,7 @@ avsv_sanamet_init(dn, &comp_name, "safComp="); comp = avd_comp_get(&comp_name); + osafassert(comp); p = strchr(cstype_name, ',') + 1; p = strchr(p, ','); @@ -259,6 +260,7 @@ "%s,%s", cstype_name, comp->comp_type->name.value); ctcstype = avd_ctcstype_get(&ctcstype_name); + osafassert(ctcstype); if (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCompNumMaxActiveCSIs"), attributes, 0, &num_max_act_csi) != SA_AIS_OK) { @@ -397,6 +399,8 @@ break; case CCBUTIL_DELETE: cst = avd_compcstype_get(&opdata->objectName); + // cst should be present in compcstype_db + osafassert(cst); avd_compcstype_delete(&cst); break; default: @@ -434,6 +438,7 @@ void avd_compcstype_constructor(void) { NCS_PATRICIA_PARAMS patricia_params; + memset(&patricia_params, 0, sizeof(NCS_PATRICIA_PARAMS)); patricia_params.key_size = sizeof(SaNameT); osafassert(ncs_patricia_tree_init(&compcstype_db, &patricia_params) == NCSCC_RC_SUCCESS); diff --git a/osaf/services/saf/amf/amfd/comptype.cc b/osaf/services/saf/amf/amfd/comptype.cc --- a/osaf/services/saf/amf/amfd/comptype.cc +++ b/osaf/services/saf/amf/amfd/comptype.cc @@ -389,6 +389,8 @@ break; case CCBUTIL_DELETE: comp_type = avd_comptype_get(&opdata->objectName); + // comp_type should be present in comptype_db + osafassert(comp_type); if (NULL != comp_type->list_of_comp) { /* check whether there exists a delete operation for * each of the Comp in the comp_type list in the current CCB @@ -422,7 +424,8 @@ void avd_comptype_constructor(void) { NCS_PATRICIA_PARAMS patricia_params; - + memset(&patricia_params, 0, sizeof(NCS_PATRICIA_PARAMS)); + patricia_params.key_size = sizeof(SaNameT); osafassert(ncs_patricia_tree_init(&comptype_db, &patricia_params) == NCSCC_RC_SUCCESS); @@ -438,7 +441,7 @@ { SaAisErrorT rc; const SaImmAttrValuesT_2 **attributes; - SaImmAccessorHandleT accessorHandle; + SaImmAccessorHandleT accessorHandle = 0; SaNameT dn = {0, "safRdn=compGlobalAttributes,safApp=safAmfService" }; dn.length = strlen((char *)dn.value); diff --git a/osaf/services/saf/amf/amfd/csi.cc b/osaf/services/saf/amf/amfd/csi.cc --- a/osaf/services/saf/amf/amfd/csi.cc +++ b/osaf/services/saf/amf/amfd/csi.cc @@ -36,6 +36,8 @@ temp = csi->list_attributes; while (temp != NULL) { avd_csi_remove_csiattr(csi, temp); + // Coverity will complain csi->list_attributes has + // already been freed but it appears to be a false positive temp = csi->list_attributes; } @@ -304,6 +306,9 @@ if (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCSIDependencies"), attributes, i, &new_csi_dep->csi_dep_name_value) != SA_AIS_OK) { LOG_ER("Get saAmfCSIDependencies FAILED for '%s'", csi->name.value); + // make sure we don't leak any memory if + // saAmfCSIDependencies can't be read + delete new_csi_dep; goto done; } found = csi_add_csidep(csi,new_csi_dep); @@ -317,7 +322,9 @@ } csi->cstype = avd_cstype_get(&csi->saAmfCSType); + osafassert(csi->cstype); csi->si = avd_si_get(si_name); + osafassert(csi->si); avd_cstype_add_csi(csi); avd_si_add_csi(csi); @@ -540,6 +547,7 @@ AVD_CSI *csi; SaNameT cstype_name = *(SaNameT*) attr_mod->modAttr.attrValues[0]; csi = avd_csi_get(&opdata->objectName); + osafassert(csi); if(SA_AMF_ADMIN_LOCKED != csi->si->saAmfSIAdminState) { report_ccb_validation_error(opdata, "Parent SI is not in locked state, SI state '%d'", csi->si->saAmfSIAdminState); @@ -600,6 +608,8 @@ } } + osafassert(csi); + if(AVD_SG_FSM_STABLE != csi->si->sg_of_si->sg_fsm_state) { report_ccb_validation_error(opdata, "SG('%s') fsm state('%u') is not in AVD_SG_FSM_STABLE(0)", csi->si->sg_of_si->name.value, csi->si->sg_of_si->sg_fsm_state); @@ -695,6 +705,8 @@ } goto done; } + + osafassert(csi); /* Check whether si has been assigned to any SU. */ if ((NULL != csi->si->list_of_sisu) && @@ -765,6 +777,7 @@ TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId, opdata->objectName.value); csi = avd_csi_get(&opdata->objectName); + osafassert(csi); while ((attr_mod = opdata->param.modify.attrMods[i++]) != NULL) { if (!strcmp(attr_mod->modAttr.attrName, "saAmfCSType")) { struct avd_cstype *csi_type; @@ -772,6 +785,7 @@ TRACE("saAmfCSType modified from '%s' to '%s' for Csi'%s'", csi->saAmfCSType.value, cstype_name.value, csi->name.value); csi_type = avd_cstype_get(&cstype_name); + osafassert(csi_type); avd_cstype_remove_csi(csi); csi->saAmfCSType = cstype_name; csi->cstype = csi_type; @@ -815,6 +829,7 @@ * we might get compcsi create checkpoint and csi will be created as part of checkpoint processing */ csi = csi_create(&opdata->objectName); + osafassert(csi); } csi_get_attr_and_add_to_model(csi, opdata->param.create.attrValues, opdata->param.create.parentName); @@ -842,7 +857,7 @@ t_comp = t_sisu->su->list_of_comp; while (t_comp != NULL) { if ((t_comp->assign_flag == false) && - (NULL != (cst = avd_compcstype_find_match(&csi->saAmfCSType, t_comp)))) { + (avd_compcstype_find_match(&csi->saAmfCSType, t_comp) != NULL)) { /* We have found the component. Assign csi to it. */ break; } @@ -987,7 +1002,7 @@ { AVD_COMP_CSI_REL *compcsi = NULL; - if ((csi == NULL) && (comp == NULL)) { + if ((csi == NULL) || (comp == NULL)) { LOG_ER("Either csi or comp is NULL"); return NULL; } @@ -1232,6 +1247,7 @@ void avd_csi_constructor(void) { NCS_PATRICIA_PARAMS patricia_params; + memset(&patricia_params, 0, sizeof(NCS_PATRICIA_PARAMS)); patricia_params.key_size = sizeof(SaNameT); osafassert(ncs_patricia_tree_init(&csi_db, &patricia_params) == NCSCC_RC_SUCCESS); diff --git a/osaf/services/saf/amf/amfd/csiattr.cc b/osaf/services/saf/amf/amfd/csiattr.cc --- a/osaf/services/saf/amf/amfd/csiattr.cc +++ b/osaf/services/saf/amf/amfd/csiattr.cc @@ -507,6 +507,7 @@ csiattr = csiattr_create(&opdata->objectName, opdata->param.create.attrValues); csi = avd_csi_get(opdata->param.create.parentName); + osafassert(csi); avd_csi_add_csiattr(csi, csiattr); } @@ -527,6 +528,7 @@ csi_dn.length = strlen((char *)&csi_dn.value); csi = avd_csi_get(&csi_dn); + osafassert(csi); csiattr_dn_to_csiattr_name(&opdata->objectName, &csi_attr_name); /* create new name-value pairs for the modified csi attribute */ diff --git a/osaf/services/saf/amf/amfd/cstype.cc b/osaf/services/saf/amf/amfd/cstype.cc --- a/osaf/services/saf/amf/amfd/cstype.cc +++ b/osaf/services/saf/amf/amfd/cstype.cc @@ -190,7 +190,7 @@ if (!is_config_valid(&dn, NULL)) goto done2; - if ((cst = avd_cstype_get(&dn)) == NULL){ + if (avd_cstype_get(&dn) == NULL){ if ((cst = cstype_create(&dn, attributes)) == NULL) goto done2; @@ -233,6 +233,7 @@ break; case CCBUTIL_DELETE: cst = avd_cstype_get(&opdata->objectName); + osafassert(cst); if (cst->list_of_csi != NULL) { /* check whether there exists a delete operation for * each of the CSI in the cs_type list in the current CCB @@ -287,6 +288,7 @@ void avd_cstype_constructor(void) { NCS_PATRICIA_PARAMS patricia_params; + memset(&patricia_params, 0, sizeof(NCS_PATRICIA_PARAMS)); patricia_params.key_size = sizeof(SaNameT); osafassert(ncs_patricia_tree_init(&cstype_db, &patricia_params) == NCSCC_RC_SUCCESS); diff --git a/osaf/services/saf/amf/amfd/ctcstype.cc b/osaf/services/saf/amf/amfd/ctcstype.cc --- a/osaf/services/saf/amf/amfd/ctcstype.cc +++ b/osaf/services/saf/amf/amfd/ctcstype.cc @@ -65,7 +65,6 @@ static AVD_CTCS_TYPE *ctcstype_create(const SaNameT *dn, const SaImmAttrValuesT_2 **attributes) { AVD_CTCS_TYPE *ctcstype; - int rc = -1; SaAisErrorT error; TRACE_ENTER2("'%s'", dn->value); @@ -87,12 +86,6 @@ SA_AIS_OK) ctcstype->saAmfCtDefNumMaxStandbyCSIs = -1; /* no limit */ - rc = 0; - - if (rc != 0) { - delete ctcstype; - ctcstype = NULL; - } return ctcstype; } @@ -143,7 +136,7 @@ if (!is_config_valid(&dn, attributes, NULL)) goto done2; - if ((ctcstype = avd_ctcstype_get(&dn)) == NULL ) { + if (avd_ctcstype_get(&dn) == NULL) { if ((ctcstype = ctcstype_create(&dn, attributes)) == NULL) goto done2; @@ -200,6 +193,8 @@ break; case CCBUTIL_DELETE: ctcstype = avd_ctcstype_get(&opdata->objectName); + // ctcstype should be in ctcstype_db + osafassert(ctcstype); ctcstype_delete(ctcstype); break; default: @@ -213,7 +208,8 @@ void avd_ctcstype_constructor(void) { NCS_PATRICIA_PARAMS patricia_params; - + memset(&patricia_params, 0, sizeof(NCS_PATRICIA_PARAMS)); + patricia_params.key_size = sizeof(SaNameT); osafassert(ncs_patricia_tree_init(&ctcstype_db, &patricia_params) == NCSCC_RC_SUCCESS); avd_class_impl_set(const_cast<SaImmClassNameT>("SaAmfCtCsType"), NULL, NULL, ctcstype_ccb_completed_cb, ctcstype_ccb_apply_cb); ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel