osaf/services/saf/amf/amfd/comp.cc           |   2 +-
 osaf/services/saf/amf/amfd/csi.cc            |   3 +-
 osaf/services/saf/amf/amfd/include/sg.h      |   9 ++-
 osaf/services/saf/amf/amfd/include/si.h      |   2 +-
 osaf/services/saf/amf/amfd/ndproc.cc         |   3 +-
 osaf/services/saf/amf/amfd/sg.cc             |  64 +++++++---------------------
 osaf/services/saf/amf/amfd/sg_2n_fsm.cc      |  25 ++--------
 osaf/services/saf/amf/amfd/sg_nored_fsm.cc   |   8 +---
 osaf/services/saf/amf/amfd/sg_npm_fsm.cc     |  55 +++++++++++------------
 osaf/services/saf/amf/amfd/sg_nway_fsm.cc    |  13 +++--
 osaf/services/saf/amf/amfd/sg_nwayact_fsm.cc |  16 +++---
 osaf/services/saf/amf/amfd/si.cc             |   1 -
 osaf/services/saf/amf/amfd/si_dep.cc         |   8 +--
 13 files changed, 74 insertions(+), 135 deletions(-)


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
@@ -1659,7 +1659,7 @@
 
 bool is_comp_assigned_any_csi(AVD_COMP *comp)
 {
-       for (AVD_SI *si = comp->su->sg_of_su->list_of_si; si != NULL; si = 
si->sg_list_of_si_next) {
+       for (const auto& si : comp->su->sg_of_su->list_of_si) {
                for (AVD_CSI *csi = si->list_of_csi; csi; csi = 
csi->si_list_of_csi_next) {
                        for (AVD_COMP_CSI_REL *compcsi = csi->list_compcsi; 
compcsi; compcsi = compcsi->csi_csicomp_next) {
                                if (compcsi->comp == comp)
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
@@ -1383,10 +1383,9 @@
  */
 bool csi_assignment_validate(AVD_SG *sg)
 {
-       AVD_SI *temp_si;
        AVD_SU_SI_REL *temp_sisu;
 
-       for (temp_si = sg->list_of_si; temp_si; temp_si = 
temp_si->sg_list_of_si_next)
+       for (const auto& temp_si : sg->list_of_si)
                for (temp_sisu = temp_si->list_of_sisu; temp_sisu; temp_sisu = 
temp_sisu->si_next)
                        if (temp_sisu->csi_add_rem == true)
                                return true;
diff --git a/osaf/services/saf/amf/amfd/include/sg.h 
b/osaf/services/saf/amf/amfd/include/sg.h
--- a/osaf/services/saf/amf/amfd/include/sg.h
+++ b/osaf/services/saf/amf/amfd/include/sg.h
@@ -186,10 +186,11 @@
        std::vector<AVD_SU*> list_of_su;
        AVD_SU* first_su();
 
-       AVD_SI *list_of_si;     /* the list of service instances in 
-                                * this group in the descending order 
-                                * of the rank.
-                                */
+       /* the list of service instances in 
+        * this group in the descending order 
+        * of the rank.
+        */
+       std::vector<AVD_SI*> list_of_si;
        SaInvocationT adminOp_invocationId;
        SaAmfAdminOperationIdT adminOp;
 
diff --git a/osaf/services/saf/amf/amfd/include/si.h 
b/osaf/services/saf/amf/amfd/include/si.h
--- a/osaf/services/saf/amf/amfd/include/si.h
+++ b/osaf/services/saf/amf/amfd/include/si.h
@@ -93,7 +93,6 @@
 
        AVD_SG *sg_of_si;       /* the service group of this SI */
        AVD_CSI *list_of_csi;   /* The list of CSIs in the SI */
-       AVD_SI *sg_list_of_si_next;     /* next SI in the SG list of SIs */
        struct avd_su_si_rel_tag *list_of_sisu; /* the list of su si 
relationship elements */
        AVD_SI_DEP_STATE si_dep_state;  /* SI-SI dep state of this SI */
        struct avd_spons_si_tag *spons_si_list;
@@ -141,6 +140,7 @@
        void add_csi_db(AVD_CSI* csi);
        bool is_sirank_valid(uint32_t newSiRank) const;
        void update_sirank(uint32_t newSiRank);
+
 private:
        AVD_SI(const AVD_SI&);
        AVD_SI& operator=(const AVD_SI&);
diff --git a/osaf/services/saf/amf/amfd/ndproc.cc 
b/osaf/services/saf/amf/amfd/ndproc.cc
--- a/osaf/services/saf/amf/amfd/ndproc.cc
+++ b/osaf/services/saf/amf/amfd/ndproc.cc
@@ -780,8 +780,7 @@
                                        }
 
                                        if (l_val == 
SA_AMF_PRESENCE_TERMINATION_FAILED) {
-                                               for (AVD_SI* si = 
su->sg_of_su->list_of_si; si != NULL;
-                                                               si = 
si->sg_list_of_si_next) {
+                                               for (const auto& si : 
su->sg_of_su->list_of_si) {
                                                        if (si->invocation != 
0) {
                                                                
report_admin_op_error(cb->immOiHandle, si->invocation,
                                                                                
SA_AIS_ERR_REPAIR_PENDING,
diff --git a/osaf/services/saf/amf/amfd/sg.cc b/osaf/services/saf/amf/amfd/sg.cc
--- a/osaf/services/saf/amf/amfd/sg.cc
+++ b/osaf/services/saf/amf/amfd/sg.cc
@@ -117,7 +117,6 @@
                sg_fsm_state(AVD_SG_FSM_STABLE),
                admin_si(NULL),
                sg_redundancy_model(SA_AMF_NO_REDUNDANCY_MODEL),
-               list_of_si(NULL),
                sg_type(NULL),
                sg_list_app_next(NULL),
                app(NULL),
@@ -162,56 +161,30 @@
 {
        /* by now SU and SI should have been deleted */ 
        osafassert(sg->list_of_su.empty() == true);
-       osafassert(sg->list_of_si == NULL);
+       osafassert(sg->list_of_si.empty() == true);
        sg_remove_from_model(sg);
        delete sg;
 }
 
 void AVD_SG::add_si(AVD_SI* si)
 {
-       AVD_SI *i_si = AVD_SI_NULL;
-       AVD_SI *prev_si = AVD_SI_NULL;
-
-       i_si = this->list_of_si;
-
-       while ((i_si != AVD_SI_NULL) && (i_si->saAmfSIRank < si->saAmfSIRank)) {
-               prev_si = i_si;
-               i_si = i_si->sg_list_of_si_next;
-       }
        si->sg_of_si = this;
-       if (prev_si == AVD_SI_NULL) {
-               si->sg_list_of_si_next = si->sg_of_si->list_of_si;
-               this->list_of_si = si;
-       } else {
-               prev_si->sg_list_of_si_next = si;
-               si->sg_list_of_si_next = i_si;
-       }
+       list_of_si.push_back(si);
+       std::sort(list_of_si.begin(), list_of_si.end(),
+               [](const AVD_SI *a, const AVD_SI *b) -> bool {return 
a->saAmfSIRank < b->saAmfSIRank;});
 }
 
 void AVD_SG::remove_si(AVD_SI* si)
 {
-       AVD_SI *i_si = NULL;
-       AVD_SI *prev_si = NULL;
+       auto si_to_remove = std::find(list_of_si.begin(), list_of_si.end(), si);
+       
+       if (si_to_remove != list_of_si.end()) {
+               list_of_si.erase(si_to_remove);
+       } else {
+               osafassert(false);
+       }
 
-       if (list_of_si != NULL) {
-               i_si = list_of_si;
-
-               while ((i_si != NULL) && (i_si != si)) {
-                       prev_si = i_si;
-                       i_si = i_si->sg_list_of_si_next;
-               }
-
-               if (i_si == si) {
-                       if (prev_si == NULL) {
-                               list_of_si = si->sg_list_of_si_next;
-                       } else {
-                               prev_si->sg_list_of_si_next = 
si->sg_list_of_si_next;
-                       }
-
-                       si->sg_list_of_si_next = NULL;
-                       si->sg_of_si = NULL;
-               }
-       }
+       si->sg_of_si = NULL;
 }
 
 /**
@@ -1199,9 +1172,7 @@
  **/
 bool sg_is_tolerance_timer_running_for_any_si(AVD_SG *sg)
 {
-       AVD_SI  *si;
-
-       for (si = sg->list_of_si; si != NULL; si = si->sg_list_of_si_next) {
+       for (const auto& si : sg->list_of_si) {
                if (si->si_dep_state == AVD_SI_TOL_TIMER_RUNNING) {
                        TRACE("Tolerance timer running for si: 
%s",si->name.value);
                        return true;
@@ -1484,7 +1455,6 @@
 {
        SaAisErrorT rc = SA_AIS_ERR_BAD_OPERATION;
        AVD_SG *sg;
-       AVD_SI *si;
        bool si_exist = false;
        CcbUtilOperationData_t *t_opData;
 
@@ -1500,21 +1470,19 @@
                break;
        case CCBUTIL_DELETE:
                sg = sg_db->find(Amf::to_string(&opdata->objectName));
-               if (sg->list_of_si != NULL) {
+               if (sg->list_of_si.empty() == false) {
                        /* check whether there is parent app delete */
                        t_opData = ccbutil_getCcbOpDataByDN(opdata->ccbId, 
&sg->app->name);
                        if (t_opData == NULL || t_opData->operationType != 
CCBUTIL_DELETE) {
                                /* check whether there exists a delete 
operation for 
                                 * each of the SIs in the SG's list in the 
current CCB
                                 */
-                               si = sg->list_of_si;
-                               while (si != NULL) {
+                               for (const auto& si : sg->list_of_si) {
                                        t_opData = 
ccbutil_getCcbOpDataByDN(opdata->ccbId, &si->name);
                                        if ((t_opData == NULL) || 
(t_opData->operationType != CCBUTIL_DELETE)) {
                                                si_exist = true;
                                                break;
                                        }
-                                       si = si->sg_list_of_si_next;
                                }
                        }
                        if (si_exist == true) {
@@ -1665,7 +1633,7 @@
                        adminOp_invocationId = 0;
                        adminOp = static_cast<SaAmfAdminOperationIdT>(0);
                }
-               for (AVD_SI* si = list_of_si; si != NULL; si = 
si->sg_list_of_si_next) {
+               for (const auto& si : list_of_si) {
                        if (si->invocation != 0) {
                                
avd_saImmOiAdminOperationResult(avd_cb->immOiHandle,
                                                si->invocation, SA_AIS_OK);
diff --git a/osaf/services/saf/amf/amfd/sg_2n_fsm.cc 
b/osaf/services/saf/amf/amfd/sg_2n_fsm.cc
--- a/osaf/services/saf/amf/amfd/sg_2n_fsm.cc
+++ b/osaf/services/saf/amf/amfd/sg_2n_fsm.cc
@@ -264,7 +264,6 @@
        bool act_found = false, quisced_found = false, std_found = false, 
any_susi_act_found = false;
        AVD_SU_SI_REL *a_susi = NULL;
        AVD_SU_SI_REL *s_susi = NULL;
-       AVD_SI *si_temp;
 
        TRACE_ENTER2("'%s'", su->name.value);
 
@@ -288,7 +287,7 @@
                /* Any one SI is act: SU state can be said to be Act. Find 
SUSI, which has both Act and Std assgnt.*/
 
                /* Find SI, which has both Act and Stdby SUSI.*/
-               for (si_temp = su->sg_of_su->list_of_si;NULL != si_temp;si_temp 
= si_temp->sg_list_of_si_next) {
+               for (const auto& si_temp : su->sg_of_su->list_of_si) {
                        TRACE("si'%s'", si_temp->name.value);
                        /* check to see if this SI has both the assignments */
                        if (NULL == (susi = si_temp->list_of_sisu)) {
@@ -324,12 +323,10 @@
                   SU state can be said to be Act if other Su is not Act. Find 
SUSI,which has both Act and Std assgnt.*/
 
                /* Find SI, which has both Act and Stdby SUSI.*/
-               si_temp = su->sg_of_su->list_of_si;
-               while (NULL != si_temp) {
+               for (const auto& si_temp : su->sg_of_su->list_of_si) {
                        TRACE("si'%s'", si_temp->name.value);
                        /* check to see if this SI has both the assignments */
                        if (NULL == (susi = si_temp->list_of_sisu)) {
-                               si_temp = si_temp->sg_list_of_si_next;
                                continue;
                        }
                        TRACE("su'%s', si'%s'", susi->su->name.value, 
susi->si->name.value);
@@ -390,7 +387,6 @@
                                }
                                break;
                        }
-                       si_temp = si_temp->sg_list_of_si_next;
                }/* while (NULL != si_temp)  */
                osafassert(a_susi);
                osafassert(s_susi);
@@ -401,12 +397,10 @@
        } else if ((true == std_found) && (false == quisced_found)) {
                /* This means that there is no Act/Quisced assignment, then it 
may have all std assignment.*/
                /* Find SI, which has both Act and Stdby SUSI.*/
-               si_temp = su->sg_of_su->list_of_si;
-               while (NULL != si_temp) {
+               for (const auto& si_temp : su->sg_of_su->list_of_si) {
                        TRACE("si'%s'", si_temp->name.value);
                        /* check to see if this SI has both the assignments */
                        if (NULL == (susi = si_temp->list_of_sisu)) {
-                               si_temp = si_temp->sg_list_of_si_next;
                                continue;
                        }
                        TRACE("su'%s', si'%s'", susi->su->name.value, 
susi->si->name.value);
@@ -428,7 +422,6 @@
                                }
                                break;
                        }
-                       si_temp = si_temp->sg_list_of_si_next;
                }
                osafassert(a_susi);
                osafassert(s_susi);
@@ -470,18 +463,14 @@
        AVD_SU_SI_REL *susi;
        AVD_SU_SI_REL *a_susi = NULL, *a_susi_1 = NULL, *a_susi_2 = NULL;
        AVD_SU_SI_REL *s_susi = NULL, *s_susi_1 = NULL, *s_susi_2 = NULL;
-       AVD_SI *l_si;
        AVD_SU *su_1 = NULL, *su_2 = NULL;
 
        TRACE_ENTER2("'%s'", sg->name.value);
 
-       l_si = sg->list_of_si;
-
        /* Find out single/both the assigned SUs of SG. */
-       while (NULL != l_si) {
+       for (const auto& l_si : sg->list_of_si) {
                if ((susi = l_si->list_of_sisu) == NULL) {
                        /* SI with no assignments!! Check another SI.*/
-                       l_si = l_si->sg_list_of_si_next;
                        continue;
                }
                su_1 = susi->su;
@@ -493,7 +482,6 @@
                        su_2 = susi->si_next->su;
                        break;  
                }
-               l_si = l_si->sg_list_of_si_next;
        }
 
        if ((NULL == su_1) && (NULL == su_2))
@@ -590,7 +578,6 @@
        AVD_SU *a_su = NULL;
        AVD_SU *s_su = NULL;
        AVD_SU *return_su = NULL;
-       AVD_SI *i_si;
        bool l_flag = true;
        AVD_SU_SI_REL *tmp_susi;
 
@@ -629,7 +616,7 @@
        l_flag = false;
 
        /* choose and assign SIs in the SG that dont have active assignment */
-       for (i_si = sg->list_of_si; i_si != NULL; i_si = 
i_si->sg_list_of_si_next) {
+       for (const auto& i_si : sg->list_of_si) {
 
                if ((i_si->saAmfSIAdminState == SA_AMF_ADMIN_UNLOCKED) &&
                    (i_si->list_of_csi != NULL) &&
@@ -687,7 +674,7 @@
        /* choose and assign SIs in the SG that have active assignment but dont
         * have standby assignment.
         */
-       for (i_si = sg->list_of_si; i_si != NULL; i_si = 
i_si->sg_list_of_si_next) {
+       for (const auto& i_si : sg->list_of_si) {
                if (i_si->list_of_sisu != AVD_SU_SI_REL_NULL) {
                        /* found a SI that has active assignment. check if it 
has standby
                         * assignment. If not assign standby to this SU. 
diff --git a/osaf/services/saf/amf/amfd/sg_nored_fsm.cc 
b/osaf/services/saf/amf/amfd/sg_nored_fsm.cc
--- a/osaf/services/saf/amf/amfd/sg_nored_fsm.cc
+++ b/osaf/services/saf/amf/amfd/sg_nored_fsm.cc
@@ -37,15 +37,12 @@
  *          no assignments need to happen.
  */
 AVD_SU *SG_NORED::assign_sis_to_sus() {
-       AVD_SI *i_si;
        AVD_SU_SI_REL *tmp;
 
        TRACE_ENTER();
 
-       i_si = list_of_si;
-
        avd_sidep_update_si_dep_state_for_all_sis(this);
-       while (i_si != NULL) {
+       for (const auto& i_si : list_of_si) {
 
                /* verify that the SI is unassigned and ready */
                if ((i_si->saAmfSIAdminState != SA_AMF_ADMIN_UNLOCKED) ||
@@ -54,7 +51,6 @@
                    (i_si->si_dep_state == AVD_SI_UNASSIGNING_DUE_TO_DEP) ||
                        (i_si->list_of_csi == NULL) ||
                    (i_si->list_of_sisu != NULL)) {
-                       i_si = i_si->sg_list_of_si_next;
                        continue;
                }
 
@@ -79,8 +75,6 @@
                if (iter == list_of_su.end()) {
                        break;
                }
-
-               i_si = i_si->sg_list_of_si_next;
        }
 
        TRACE_LEAVE();
diff --git a/osaf/services/saf/amf/amfd/sg_npm_fsm.cc 
b/osaf/services/saf/amf/amfd/sg_npm_fsm.cc
--- a/osaf/services/saf/amf/amfd/sg_npm_fsm.cc
+++ b/osaf/services/saf/amf/amfd/sg_npm_fsm.cc
@@ -338,7 +338,6 @@
  *****************************************************************************/
 static void avd_sg_npm_distribute_si_equal(AVD_SG *sg)
 {
-       AVD_SI *curr_si = NULL;
        AVD_SU *curr_su = NULL;
        AVD_SU_SI_REL *susi;
 
@@ -349,8 +348,7 @@
         * qualified SU to take the active assignment for that SI
         */
 
-       curr_si = sg->list_of_si;
-       while (curr_si != NULL) {
+       for (const auto& curr_si : sg->list_of_si) {
 
                /* verify that the SI is ready and needs active assignments. */
                if ((curr_si->saAmfSIAdminState != SA_AMF_ADMIN_UNLOCKED) ||
@@ -358,7 +356,6 @@
                                (curr_si->si_dep_state == 
AVD_SI_SPONSOR_UNASSIGNED) ||
                                (curr_si->si_dep_state == 
AVD_SI_UNASSIGNING_DUE_TO_DEP) ||
                                (curr_si->list_of_csi == NULL)) {
-                       curr_si = curr_si->sg_list_of_si_next;
                        continue;
                }
 
@@ -388,7 +385,6 @@
                                LOG_ER("%s:%u: %s (%u)", __FILE__, __LINE__, 
curr_su->name.value, curr_su->name.length);
                        }
                }
-               curr_si = curr_si->sg_list_of_si_next;
        }
 
        /* Now run through SI list of the SG to identify if there is
@@ -396,14 +392,12 @@
         * make a Standby HA assignment accordingly
         */
 
-       curr_si = sg->list_of_si;
-       while (curr_si != NULL) {
+       for (const auto& curr_si : sg->list_of_si) {
                if ((curr_si->list_of_sisu ==  AVD_SU_SI_REL_NULL) || 
                        (curr_si->saAmfSIAssignmentState == 
SA_AMF_ASSIGNMENT_FULLY_ASSIGNED)) { 
                        /* No standby assignment needs to be done when there is 
                         * either no active assignment exists or it is fully 
assigned already
                         */
-                       curr_si = curr_si->sg_list_of_si_next;
                        continue;
                }
                /* an assignment exists for this SI check for 
@@ -435,8 +429,6 @@
                                LOG_ER("%s:%u: %s (%u)", __FILE__, __LINE__, 
curr_su->name.value, curr_su->name.length);
                        }
                }
-
-               curr_si = curr_si->sg_list_of_si_next;
        }
 
        TRACE_LEAVE();
@@ -471,11 +463,12 @@
 {
        AVD_SU *i_su = NULL, *l_su = NULL, *n_su;
        uint32_t cnt = 0;
-       AVD_SI *i_si;
+       AVD_SI *i_si = NULL;
        bool new_su = false;
        bool su_found, load_su_found;
        bool actv_su_found = false;
        AVD_SU_SI_REL *o_susi, *tmp_susi;
+       std::vector<AVD_SI*>::iterator si_iter;
 
        TRACE_ENTER();
 
@@ -489,11 +482,12 @@
        }
 
        /* Identifying and assigning active assignments. */
-       i_si = sg->list_of_si;
+       si_iter = sg->list_of_si.begin();
        su_found = true;
        actv_su_found = load_su_found = false;
 
-       while ((i_si != AVD_SI_NULL) && (su_found == true)) {
+       while ((si_iter != sg->list_of_si.end()) && (su_found == true)) {
+               i_si = *si_iter;
 
                /* verify that the SI is ready and needs active assignments. */
                if ((i_si->saAmfSIAdminState != SA_AMF_ADMIN_UNLOCKED) ||
@@ -501,12 +495,12 @@
                    (i_si->si_dep_state == AVD_SI_READY_TO_UNASSIGN) ||
                        (i_si->list_of_csi == NULL) ||
                    (i_si->si_dep_state == AVD_SI_UNASSIGNING_DUE_TO_DEP)) {
-                       i_si = i_si->sg_list_of_si_next;
+                       ++si_iter;
                        continue;
                }
 
                if (i_si->list_of_sisu != AVD_SU_SI_REL_NULL) {
-                       i_si = i_si->sg_list_of_si_next;
+                       ++si_iter;
                        actv_su_found = true;
                        continue;
                }
@@ -652,6 +646,7 @@
                        /* if ((su_found == false) && 
                           (cnt < sg->pref_num_active_su)) */
                }               /* else (i_su != AVD_SU_NULL) */
+
                if (su_found == true) {
                        if (avd_new_assgn_susi(cb, i_su, i_si, 
SA_AMF_HA_ACTIVE, false, &tmp_susi) == NCSCC_RC_SUCCESS) {
                                /* Add the SU to the operation list */
@@ -662,24 +657,26 @@
                        }
 
                        /* choose the next SI */
-                       i_si = i_si->sg_list_of_si_next;
+                       ++si_iter;
                }
 
-       }                       /* while ((i_si != AVD_SI_NULL) && (su_found == 
true)) */
+       }
 
        /* The SUs were loaded only upto the preffered level. If still SIs
         * are left load them upto capability level.
         */
-       if ((load_su_found == true) && (i_si != AVD_SI_NULL) && (cnt == 
sg->saAmfSGNumPrefActiveSUs)) {
+       if ((load_su_found == true) && (si_iter != sg->list_of_si.end()) && 
(cnt == sg->saAmfSGNumPrefActiveSUs)) {
                /* Identify the highest ranked active assigning SU.  */
                i_su = avd_sg_npm_su_next_asgn(cb, sg, NULL, SA_AMF_HA_ACTIVE);
-               while ((i_si != AVD_SI_NULL) && (i_su != NULL)) {
+               while ((si_iter != sg->list_of_si.end()) && (i_su != NULL)) {
+                       i_si = *si_iter;
+
                        if ((i_si->saAmfSIAdminState != SA_AMF_ADMIN_UNLOCKED) 
||
                            (i_si->si_dep_state == AVD_SI_SPONSOR_UNASSIGNED) ||
                            (i_si->si_dep_state == 
AVD_SI_UNASSIGNING_DUE_TO_DEP) ||
                                (i_si->list_of_csi == NULL) ||
                            (i_si->list_of_sisu != AVD_SU_SI_REL_NULL)) {
-                               i_si = i_si->sg_list_of_si_next;
+                               ++si_iter;
                                continue;
                        }
 
@@ -696,9 +693,8 @@
                        }
 
                        /* choose the next SI */
-                       i_si = i_si->sg_list_of_si_next;
-
-               }               /* while ((i_si != AVD_SI_NULL) && (i_su != 
AVD_SU_NULL)) */
+                       ++si_iter;
+               }
 
        }
        /* if ((load_su_found == true) && (i_si != AVD_SI_NULL)) */
@@ -716,16 +712,18 @@
        }
 
        /* Identifying and assigning standby assignments. */
-       i_si = sg->list_of_si;
+       si_iter = sg->list_of_si.begin();
        new_su = false;
        cnt = 0;
        l_su = NULL;
        /* su with last inservice un assigned SUs. */
        n_su = NULL;
-       while (i_si != AVD_SI_NULL) {
+       while (si_iter != sg->list_of_si.end()) {
+               i_si = *si_iter;
+
                /* verify that the SI has active assignments and needs standby 
assignments. */
                if ((i_si->list_of_sisu == AVD_SU_SI_REL_NULL) || 
(i_si->list_of_sisu->si_next != AVD_SU_SI_REL_NULL)) {
-                       i_si = i_si->sg_list_of_si_next;
+                       ++si_iter;
                        continue;
                }
 
@@ -924,9 +922,8 @@
                }
 
                /* choose the next SI */
-               i_si = i_si->sg_list_of_si_next;
-
-       }                       /* while (i_si != AVD_SI_NULL) */
+               ++si_iter;
+       }
 
 done:
        if (sg->su_oper_list.empty() == true) {
diff --git a/osaf/services/saf/amf/amfd/sg_nway_fsm.cc 
b/osaf/services/saf/amf/amfd/sg_nway_fsm.cc
--- a/osaf/services/saf/amf/amfd/sg_nway_fsm.cc
+++ b/osaf/services/saf/amf/amfd/sg_nway_fsm.cc
@@ -689,7 +689,6 @@
 
 uint32_t SG_NWAY::sg_admin_down(AVD_CL_CB *cb, AVD_SG *sg) {
        AVD_SU_SI_REL *curr_susi = 0;
-       AVD_SI *curr_si = 0;
        bool is_act_asgn;
        uint32_t rc = NCSCC_RC_SUCCESS;
 
@@ -751,7 +750,7 @@
                if (SA_AMF_ADMIN_LOCKED == sg->saAmfSGAdminState) {
                        /* pick up all the quiescing susi assignments & 
                           send quiesced assignments to them */
-                       for (curr_si = sg->list_of_si; curr_si; curr_si = 
curr_si->sg_list_of_si_next) {
+                       for (const auto& curr_si : sg->list_of_si) {
                                for (curr_susi = curr_si->list_of_sisu;
                                     curr_susi && (SA_AMF_HA_QUIESCING != 
curr_susi->state);
                                     curr_susi = curr_susi->si_next) ;
@@ -1244,7 +1243,6 @@
  **************************************************************************/
 uint32_t avd_sg_nway_si_assign(AVD_CL_CB *cb, AVD_SG *sg)
 {
-       AVD_SI *curr_si = 0;
        AVD_SU *curr_su = NULL;
        AVD_SU *pref_su = NULL;
        bool is_act_ass_sent = false, is_all_su_oos = true, is_all_si_ok = 
false, su_found = true;
@@ -1258,8 +1256,7 @@
 
        avd_sidep_update_si_dep_state_for_all_sis(sg);
        /* assign active assignments to unassigned sis */
-       for (curr_si = sg->list_of_si; curr_si; curr_si = 
curr_si->sg_list_of_si_next) {
-
+       for (const auto& curr_si : sg->list_of_si) {
                /* verify if si is ready and needs an assignment */
                if ((curr_si->saAmfSIAdminState != SA_AMF_ADMIN_UNLOCKED) ||
                    (curr_si->si_dep_state == AVD_SI_SPONSOR_UNASSIGNED) ||
@@ -1409,7 +1406,11 @@
                goto done;
 
        /* assign standby assignments to the sis */
-       for (curr_si = sg->list_of_si; curr_si && (true == su_found); curr_si = 
curr_si->sg_list_of_si_next) {
+       for (const auto& curr_si : sg->list_of_si) {
+               if (su_found == false) {
+                       break;
+               }
+
                /* verify if si is ready */
                if (curr_si->saAmfSIAdminState != SA_AMF_ADMIN_UNLOCKED)
                        continue;
diff --git a/osaf/services/saf/amf/amfd/sg_nwayact_fsm.cc 
b/osaf/services/saf/amf/amfd/sg_nwayact_fsm.cc
--- a/osaf/services/saf/amf/amfd/sg_nwayact_fsm.cc
+++ b/osaf/services/saf/amf/amfd/sg_nwayact_fsm.cc
@@ -57,22 +57,24 @@
 AVD_SU *avd_sg_nacvred_su_chose_asgn(AVD_CL_CB *cb, AVD_SG *sg)
 {
        AVD_SU *i_su, *qualified_su;
-       AVD_SI *i_si;
        bool l_flag, next_si_tobe_assigned = true;
        AVD_SU_SI_REL *tmp_rel;
 
        TRACE_ENTER2("'%s'", sg->name.value);
 
-       i_si = sg->list_of_si;
+       // @todo remove this l_flag??
        l_flag = true;
 
        avd_sidep_update_si_dep_state_for_all_sis(sg);
-       while ((i_si != AVD_SI_NULL) && (l_flag == true)) {
+       for (const auto& i_si : sg->list_of_si) {
+               if (l_flag == false) {
+                       break;
+               }
+
                /* verify that the SI is ready and needs come more assignments. 
*/
                if ((i_si->saAmfSIAdminState != SA_AMF_ADMIN_UNLOCKED) ||
                        (i_si->list_of_csi == NULL) ||
                    (i_si->pref_active_assignments() <= 
i_si->curr_active_assignments() )) {
-                       i_si = i_si->sg_list_of_si_next;
                        continue;
                }
 
@@ -80,7 +82,6 @@
                if ((i_si->si_dep_state == AVD_SI_SPONSOR_UNASSIGNED) ||
                                (i_si->si_dep_state == 
AVD_SI_READY_TO_UNASSIGN) ||
                                (i_si->si_dep_state == 
AVD_SI_UNASSIGNING_DUE_TO_DEP)) {
-                       i_si = i_si->sg_list_of_si_next;
                        continue;
                }
 
@@ -228,11 +229,8 @@
                        }/* while */
                }/* if (true == sg->equal_ranked_su) */
 
-
                /* choose the next SI */
-               i_si = i_si->sg_list_of_si_next;
-
-       }/* while ((i_si != AVD_SI_NULL) && (l_flag == true)) */
+       }
 
        TRACE_LEAVE();
 
diff --git a/osaf/services/saf/amf/amfd/si.cc b/osaf/services/saf/amf/amfd/si.cc
--- a/osaf/services/saf/amf/amfd/si.cc
+++ b/osaf/services/saf/amf/amfd/si.cc
@@ -307,7 +307,6 @@
        si_switch(AVSV_SI_TOGGLE_STABLE),
        sg_of_si(NULL),
        list_of_csi(NULL),
-       sg_list_of_si_next(NULL),
        list_of_sisu(NULL),
        si_dep_state(AVD_SI_NO_DEPENDENCY),
        spons_si_list(NULL),
diff --git a/osaf/services/saf/amf/amfd/si_dep.cc 
b/osaf/services/saf/amf/amfd/si_dep.cc
--- a/osaf/services/saf/amf/amfd/si_dep.cc
+++ b/osaf/services/saf/amf/amfd/si_dep.cc
@@ -666,11 +666,9 @@
  **************************************************************************/
 void avd_sidep_update_si_dep_state_for_all_sis(AVD_SG *sg)
 {
-       AVD_SI *si = NULL;
-
        TRACE_ENTER2("'%s'", sg->name.value);
 
-       for (si = sg->list_of_si; si != NULL; si = si->sg_list_of_si_next) {
+       for (const auto& si : sg->list_of_si) {
 
                /*Avoid screening if si is neither a sponsor si nor a dependent 
si*/
                if ((si->spons_si_list != NULL) || (si->num_dependents > 0)) 
@@ -2427,11 +2425,9 @@
  **/
 void avd_sidep_sg_take_action(AVD_SG *sg)
 {
-       AVD_SI *si = NULL;
-
        TRACE_ENTER2("'%s'", sg->name.value);
 
-       for (si = sg->list_of_si; si != NULL; si = si->sg_list_of_si_next) {
+       for (const auto& si : sg->list_of_si) {
                if ((si->spons_si_list != NULL) || (si->num_dependents > 0)) 
                        sidep_si_take_action(si);
        }

------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to