Ack. Can you please push it today.

Thanks
-Nagu

> -----Original Message-----
> From: Hans Nordeback [mailto:[email protected]]
> Sent: 23 September 2015 14:33
> To: Praveen Malviya; Nagendra Kumar; [email protected]
> Cc: [email protected]
> Subject: [PATCH 1 of 1] AMFD: Convert SU list_of_comp to std::vector
> [#1142]
> 
>  osaf/services/saf/amf/amfd/comp.cc         |    1 -
>  osaf/services/saf/amf/amfd/csi.cc          |   84 ++++++++++-------------
>  osaf/services/saf/amf/amfd/include/comp.h  |    5 +-
>  osaf/services/saf/amf/amfd/include/csi.h   |    3 +
>  osaf/services/saf/amf/amfd/include/su.h    |    3 +-
>  osaf/services/saf/amf/amfd/ndfsm.cc        |    6 +-
>  osaf/services/saf/amf/amfd/nodeswbundle.cc |    3 +-
>  osaf/services/saf/amf/amfd/sgproc.cc       |   15 +--
>  osaf/services/saf/amf/amfd/su.cc           |  102 
> +++++++---------------------
>  9 files changed, 78 insertions(+), 144 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
> @@ -79,7 +79,6 @@ void AVD_COMP::initialize() {
>    comp_type = {};
>    comp_type_list_comp_next = {};
>    su = {};
> -  su_comp_next = {};
>    admin_pend_cbk = {};
>  }
> 
> 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
> @@ -26,6 +26,38 @@
> 
>  AmfDb<std::string, AVD_CSI> *csi_db = NULL;
> 
> +//
> +AVD_COMP* AVD_CSI::find_assigned_comp(const SaNameT *cstype,
> +                                        const AVD_SU_SI_REL *sisu,
> +                                        const std::vector<AVD_COMP*> 
> &list_of_comp) {
> +  auto iter = list_of_comp.begin();
> +  AVD_COMP* comp = nullptr;
> +  for (; iter != list_of_comp.end(); ++iter) {
> +    comp = *iter;
> +    AVD_COMPCS_TYPE *cst;
> +    if (NULL != (cst = avd_compcstype_find_match(cstype, comp))) {
> +      if (SA_AMF_HA_ACTIVE == sisu->state) {
> +        if (cst->saAmfCompNumCurrActiveCSIs < cst-
> >saAmfCompNumMaxActiveCSIs) {
> +          break;
> +        } else { /* We can't assign this csi to this comp, so check for 
> another
> comp */
> +          continue ;
> +        }
> +      } else {
> +        if (cst->saAmfCompNumCurrStandbyCSIs < cst-
> >saAmfCompNumMaxStandbyCSIs) {
> +          break;
> +        } else { /* We can't assign this csi to this comp, so check for 
> another
> comp */
> +          continue ;
> +        }
> +      }
> +    }
> +  }
> +  if (iter == list_of_comp.end()) {
> +    return NULL;
> +  } else {
> +    return comp;
> +  }
> +}
> +
>  void avd_csi_delete(AVD_CSI *csi)
>  {
>       AVD_CSI_ATTR *temp;
> @@ -445,7 +477,6 @@ static SaAisErrorT csi_ccb_completed_cre
>       AVD_SU_SI_REL *t_sisu;
>       AVD_COMP_CSI_REL *compcsi;
>       SaNameT cstype_name;
> -     AVD_COMPCS_TYPE *cst;
> 
>       TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId, opdata-
> >objectName.value);
> 
> @@ -480,7 +511,7 @@ static SaAisErrorT csi_ccb_completed_cre
> 
>                               compcsi = t_sisu->list_of_csicomp;
>                               while (compcsi != NULL) {
> -                                     compcsi->comp->assign_flag = true;
> +                                     compcsi->comp->set_assigned();
>                                       compcsi = compcsi-
> >susi_csicomp_next;
>                               }
> 
> @@ -488,29 +519,9 @@ static SaAisErrorT csi_ccb_completed_cre
> 
>                               /* Component not found.*/
>                               if (NULL == t_comp) {
> -                                     /* This means that all the
> components are assigned, let us assigned it to assigned
> +                                     /* This means that all the
> components are assigned, let us assigned it to assigned
>                                          component.*/
> -                                     t_comp = su->list_of_comp;
> -                                     while (t_comp != NULL) {
> -                                             if (NULL != (cst =
> avd_compcstype_find_match(&cstype_name, t_comp))) {
> -                                                     if
> (SA_AMF_HA_ACTIVE == t_sisu->state) {
> -                                                             if (cst-
> >saAmfCompNumCurrActiveCSIs < cst->saAmfCompNumMaxActiveCSIs) {
> -
>       break;
> -                                                             } else { /* We
> cann't assign this csi to this comp, so check for another comp */
> -
>       t_comp = t_comp->su_comp_next;
> -
>       continue ;
> -                                                             }
> -                                                     } else {
> -                                                             if (cst-
> >saAmfCompNumCurrStandbyCSIs < cst->saAmfCompNumMaxStandbyCSIs)
> {
> -
>       break;
> -                                                             } else { /* We
> cann't assign this csi to this comp, so check for another comp */
> -
>       t_comp = t_comp->su_comp_next;
> -
>       continue ;
> -                                                             }
> -                                                     }
> -                                             }
> -                                             t_comp = t_comp-
> >su_comp_next;
> -                                     }
> +                                     t_comp =
> AVD_CSI::find_assigned_comp(&cstype_name, t_sisu, su->list_of_comp);
>                               }
>                               if (NULL == t_comp) {
>                                       report_ccb_validation_error(opdata,
> "Compcsi doesn't exist or "
> @@ -958,7 +969,6 @@ SaAisErrorT csi_assign_hdlr(AVD_CSI *csi
>       AVD_SU_SI_REL *t_sisu;
>       bool first_sisu = true;
>       AVD_COMP_CSI_REL *compcsi;
> -     AVD_COMPCS_TYPE *cst;
>       SaAisErrorT rc = SA_AIS_ERR_NO_OP;
> 
>       /* Check whether csi assignment is already in progress and if yes,
> then return.
> @@ -983,7 +993,7 @@ SaAisErrorT csi_assign_hdlr(AVD_CSI *csi
> 
>                       compcsi = t_sisu->list_of_csicomp;
>                       while (compcsi != NULL) {
> -                             compcsi->comp->assign_flag = true;
> +                             compcsi->comp->set_assigned();
>                               compcsi = compcsi->susi_csicomp_next;
>                       }
> 
> @@ -993,27 +1003,7 @@ SaAisErrorT csi_assign_hdlr(AVD_CSI *csi
>                       if (NULL == t_comp) {
>                               /* This means that all the components are
> assigned, let us assigned it to assigned
>                                  component.*/
> -                             t_comp = t_sisu->su->list_of_comp;
> -                             while (t_comp != NULL) {
> -                                     if (NULL != (cst =
> avd_compcstype_find_match(&csi->saAmfCSType, t_comp))) {
> -                                             if (SA_AMF_HA_ACTIVE ==
> t_sisu->state) {
> -                                                     if (cst-
> >saAmfCompNumCurrActiveCSIs < cst->saAmfCompNumMaxActiveCSIs) {
> -                                                             break;
> -                                                     } else { /* We cann't
> assign this csi to this comp, so check for another comp */
> -                                                             t_comp =
> t_comp->su_comp_next;
> -                                                             continue ;
> -                                                     }
> -                                             } else {
> -                                                     if (cst-
> >saAmfCompNumCurrStandbyCSIs < cst->saAmfCompNumMaxStandbyCSIs)
> {
> -                                                             break;
> -                                                     } else { /* We cann't
> assign this csi to this comp, so check for another comp */
> -                                                             t_comp =
> t_comp->su_comp_next;
> -                                                             continue ;
> -                                                     }
> -                                             }
> -                                     }
> -                                     t_comp = t_comp->su_comp_next;
> -                             }
> +                             t_comp =
> AVD_CSI::find_assigned_comp(&csi->saAmfCSType, t_sisu, t_sisu->su-
> >list_of_comp);
>                       }
>                       if (NULL == t_comp) {
>                               LOG_ER("Compcsi doesn't exist or
> MaxActiveCSI/MaxStandbyCSI have reached for csi '%s'",
> diff --git a/osaf/services/saf/amf/amfd/include/comp.h
> b/osaf/services/saf/amf/amfd/include/comp.h
> --- a/osaf/services/saf/amf/amfd/include/comp.h
> +++ b/osaf/services/saf/amf/amfd/include/comp.h
> @@ -121,10 +121,11 @@ class AVD_COMP {
>    AVD_COMP_TYPE *comp_type;
>    AVD_COMP *comp_type_list_comp_next;
>    AVD_SU *su;                /* SU to which this component belongs */
> -  AVD_COMP *su_comp_next;    /* the next component in list of  components
> -                                 * in this SU */
>    AVD_ADMIN_OPER_CBK admin_pend_cbk;  /* holds callback invocation for
> admin operation */
> 
> +  void set_unassigned() {assign_flag = false;}
> +  void set_assigned() {assign_flag = true;}
> +  bool is_assigned() {return assign_flag;}
>   private:
>    void initialize();
>    // disallow copy and assign
> diff --git a/osaf/services/saf/amf/amfd/include/csi.h
> b/osaf/services/saf/amf/amfd/include/csi.h
> --- a/osaf/services/saf/amf/amfd/include/csi.h
> +++ b/osaf/services/saf/amf/amfd/include/csi.h
> @@ -84,6 +84,9 @@ class AVD_CSI {
>    AVD_CS_TYPE *cstype {};
>    bool assign_flag {};   /* Flag used while assigning. to mark this csi has 
> been
> assigned a Comp
>                           from * current SI being assigned */
> +
> +  static AVD_COMP* find_assigned_comp(const SaNameT *cstype, const
> AVD_SU_SI_REL *sisu, const std::vector<AVD_COMP*> &list_of_comp);
> +
>   private:
>    AVD_CSI();
>    // disallow copy and assign
> diff --git a/osaf/services/saf/amf/amfd/include/su.h
> b/osaf/services/saf/amf/amfd/include/su.h
> --- a/osaf/services/saf/amf/amfd/include/su.h
> +++ b/osaf/services/saf/amf/amfd/include/su.h
> @@ -90,8 +90,7 @@ class AVD_SU {
>       AVD_AVND *su_on_node;   /*  the node on which this SU resides
> */
>       struct avd_su_si_rel_tag *list_of_susi; /* the list of su si 
> relationship
> elements */
> 
> -     // TODO: use some container for the comp list
> -     AVD_COMP *list_of_comp; /* the list of  components in this SU
> */
> +     std::vector<AVD_COMP*> list_of_comp;    /* the list of
> components in this SU */
> 
>       AVD_SUTYPE *su_type;
>       AVD_SU *su_list_su_type_next;
> diff --git a/osaf/services/saf/amf/amfd/ndfsm.cc
> b/osaf/services/saf/amf/amfd/ndfsm.cc
> --- a/osaf/services/saf/amf/amfd/ndfsm.cc
> +++ b/osaf/services/saf/amf/amfd/ndfsm.cc
> @@ -28,6 +28,7 @@
>  #include <amfd.h>
>  #include <cluster.h>
>  #include <daemon.h>
> +#include <algorithm>
> 
>  AmfDb<uint32_t, AVD_FAIL_OVER_NODE> *node_list_db = 0;      /*
> SaClmNodeIdT index */
> 
> @@ -205,9 +206,8 @@ void avd_nd_ncs_su_assigned(AVD_CL_CB *c
>               /* Make application SUs operational state ENABLED */
>               for (const auto& su : avnd->list_of_su) {
>                       su-
> >set_oper_state(SA_AMF_OPERATIONAL_ENABLED);
> -                     AVD_COMP *comp;
> -                     for (comp = su->list_of_comp; comp; comp = comp-
> >su_comp_next)
> -                             avd_comp_oper_state_set(comp,
> SA_AMF_OPERATIONAL_ENABLED);
> +                     std::for_each (su->list_of_comp.begin(), su-
> >list_of_comp.end(),
> +                             [] (AVD_COMP *comp)
> {avd_comp_oper_state_set(comp, SA_AMF_OPERATIONAL_ENABLED);});
>               }
>               /* We can now set the LEDS */
>               avd_snd_set_leds_msg(cb, avnd);
> diff --git a/osaf/services/saf/amf/amfd/nodeswbundle.cc
> b/osaf/services/saf/amf/amfd/nodeswbundle.cc
> --- a/osaf/services/saf/amf/amfd/nodeswbundle.cc
> +++ b/osaf/services/saf/amf/amfd/nodeswbundle.cc
> @@ -71,11 +71,10 @@ static int is_config_valid(const SaNameT
>  static int is_swbdl_delete_ok_for_node(const SaNameT
> *bundle_dn_to_delete,
>       const SaNameT *node_dn, const std::vector<AVD_SU*> &su_list,
> CcbUtilOperationData_t *opdata)
>  {
> -     const AVD_COMP *comp;
>       SaNameT bundle_dn;
> 
>       for (const auto& su : su_list) {
> -             for (comp = su->list_of_comp; comp != NULL; comp = comp-
> >su_comp_next) {
> +             for (const auto& comp : su->list_of_comp) {
>                       avsv_create_association_class_dn(&comp-
> >comp_type->saAmfCtSwBundle,
>                               node_dn, "safInstalledSwBundle",
> &bundle_dn);
> 
> diff --git a/osaf/services/saf/amf/amfd/sgproc.cc
> b/osaf/services/saf/amf/amfd/sgproc.cc
> --- a/osaf/services/saf/amf/amfd/sgproc.cc
> +++ b/osaf/services/saf/amf/amfd/sgproc.cc
> @@ -62,7 +62,7 @@ static void verify_csi_deps_and_delete_i
>                                                       compcsi->comp-
> >comp_info.name.value,
>                                                       compcsi->csi-
> >name.value);
>                                       compcsi->csi->assign_flag = false;
> -                                     compcsi->comp->assign_flag = false;
> +                                     compcsi->comp->set_unassigned();
> 
>       avd_compcsi_from_csi_and_susi_delete(susi, compcsi, true);
>                                       //Delete compcsi of dependents.
> 
>       verify_csi_deps_and_delete_invalid_compcsi(susi);
> @@ -148,7 +148,7 @@ uint32_t avd_new_assgn_susi(AVD_CL_CB *c
>                       continue;
>               }
> 
> -             l_comp->assign_flag = true;
> +             l_comp->set_assigned();
>               l_csi->assign_flag = true;
>               l_csi = l_csi->si_list_of_csi_next;
>       } /* while(l_csi != AVD_CSI_NULL) */
> @@ -169,31 +169,27 @@ uint32_t avd_new_assgn_susi(AVD_CL_CB *c
>       l_csi = si->list_of_csi;
>       while (NULL !=  l_csi) {
>               if (false == l_csi->assign_flag) {
> -                     l_comp = su->list_of_comp;
>                       /* Assign to only those comps, which have
> assignment. Those comps, which could not have assignment
>                          before, cann't find compcsi here also.*/
> -                     while (l_comp != NULL) {
> +                     for (const auto& l_comp : su->list_of_comp) {
>                               AVD_COMP_TYPE *comptype =
> comptype_db->find(Amf::to_string(&l_comp->saAmfCompType));
>                               osafassert(comptype);
> -                             if ((true == l_comp->assign_flag) &&
> (comptype->saAmfCtCompCategory != SA_AMF_COMP_LOCAL)) {
> +                             if ((true == l_comp->is_assigned()) &&
> (comptype->saAmfCtCompCategory != SA_AMF_COMP_LOCAL)) {
>                                       if (NULL != (cst =
> avd_compcstype_find_match(&l_csi->saAmfCSType, l_comp))) {
>                                               if (SA_AMF_HA_ACTIVE ==
> ha_state) {
>                                                       if (cst-
> >saAmfCompNumCurrActiveCSIs < cst->saAmfCompNumMaxActiveCSIs) {
>                                                       } else { /* We cann't
> assign this csi to this comp, so check for another comp */
> -                                                             l_comp =
> l_comp->su_comp_next;
>                                                               continue ;
>                                                       }
>                                               } else {
>                                                       if (cst-
> >saAmfCompNumCurrStandbyCSIs < cst->saAmfCompNumMaxStandbyCSIs)
> {
>                                                       } else { /* We cann't
> assign this csi to this comp, so check for another comp */
> -                                                             l_comp =
> l_comp->su_comp_next;
>                                                               continue ;
>                                                       }
>                                               }
>                                               if ((compcsi =
> avd_compcsi_create(susi, l_csi, l_comp, true)) == NULL) {
>                                                       /* free all the CSI
> assignments and end this loop */
> 
>       avd_compcsi_delete(cb, susi, true);
> -                                                     l_comp = l_comp-
> >su_comp_next;
>                                                       continue;
>                                               }
>                                               l_csi->assign_flag = true;
> @@ -201,8 +197,7 @@ uint32_t avd_new_assgn_susi(AVD_CL_CB *c
>                                               break;
>                                       }/* if (NULL != (cst =
> avd_compcstype_find_match(&l_csi->saAmfCSType, l_comp))) */
>                               }/* if (true == l_comp->assign_flag) */
> -                             l_comp = l_comp->su_comp_next;
> -                     }/* while (l_comp != NULL) */
> +                     }/* for (const auto& l_comp : su->list_of_comp) */
>               }/* if (false == l_csi->assign_flag)*/
>               l_csi = l_csi->si_list_of_csi_next;
>       }/* while (l_csi != NULL) */
> diff --git a/osaf/services/saf/amf/amfd/su.cc
> b/osaf/services/saf/amf/amfd/su.cc
> --- a/osaf/services/saf/amf/amfd/su.cc
> +++ b/osaf/services/saf/amf/amfd/su.cc
> @@ -54,7 +54,7 @@ void AVD_SU::initialize() {
>       sg_of_su = NULL;
>       su_on_node = NULL;
>       list_of_susi = NULL;
> -     list_of_comp = NULL;
> +     list_of_comp = {};
>       su_type = NULL;
>       su_list_su_type_next = NULL;
>       name.length = 0;
> @@ -85,7 +85,7 @@ void AVD_SU::remove_from_model() {
>       /* All the components under this SU should have been deleted
>        * by now, just do the sanity check to confirm it is done
>        */
> -     osafassert(list_of_comp == NULL);
> +     osafassert(list_of_comp.empty() == true);
>       osafassert(list_of_susi == NULL);
> 
>       m_AVSV_SEND_CKPT_UPDT_ASYNC_RMV(avd_cb, this,
> AVSV_CKPT_AVD_SU_CONFIG);
> @@ -117,47 +117,25 @@ int AVD_SU::hastate_assignments_count(Sa
>  }
> 
>  void AVD_SU::remove_comp(AVD_COMP *comp) {
> -     AVD_COMP *i_comp = NULL;
> -     AVD_COMP *prev_comp = NULL;
>       AVD_SU *su_ref = comp->su;
> 
>       osafassert(su_ref != NULL);
> 
> -     if (comp->su != NULL) {
> -             /* remove COMP from SU */
> -             i_comp = comp->su->list_of_comp;
> -
> -             while ((i_comp != NULL) && (i_comp != comp)) {
> -                     prev_comp = i_comp;
> -                     i_comp = i_comp->su_comp_next;
> -             }
> -
> -             if (i_comp == comp) {
> -                     if (prev_comp == NULL) {
> -                             comp->su->list_of_comp = comp-
> >su_comp_next;
> -                     } else {
> -                             prev_comp->su_comp_next = comp-
> >su_comp_next;
> -                     }
> -
> -                     comp->su_comp_next = NULL;
> -                     /* Marking SU referance pointer to NULL, please
> dont use further in the routine */
> -                     comp->su = NULL;
> -             }
> -     }
> -
> +     if (comp->su != nullptr) {
> +     comp->su->list_of_comp.erase(std::remove(comp->su-
> >list_of_comp.begin(),
> +                                          comp->su->list_of_comp.end(), 
> comp), comp->su-
> >list_of_comp.end());
> +  }
>       bool old_preinst_value = saAmfSUPreInstantiable;
>       bool curr_preinst_value = saAmfSUPreInstantiable;
> 
>       // check if preinst possibly is still true
>       if (comp_is_preinstantiable(comp) == true) {
>               curr_preinst_value = false;
> -             i_comp = list_of_comp;
> -             while (i_comp) {
> +             for (const auto& i_comp : list_of_comp) {
>                       if ((comp_is_preinstantiable(i_comp) == true) &&
> (i_comp != comp)) {
>                               curr_preinst_value = true;
>                               break;
>                       }
> -                     i_comp = i_comp->su_comp_next;
>               }
>       }
> 
> @@ -174,37 +152,15 @@ void AVD_SU::remove_comp(AVD_COMP *comp)
>  }
> 
>  void AVD_SU::add_comp(AVD_COMP *comp) {
> -     AVD_COMP *i_comp = comp->su->list_of_comp;
> -     AVD_COMP *prev_comp = NULL;
> -     bool found_pos= false;
> -
> -     while ((i_comp == NULL) || (comp->comp_info.inst_level >= i_comp-
> >comp_info.inst_level)) {
> -             while ((i_comp != NULL) && (comp->comp_info.inst_level ==
> i_comp->comp_info.inst_level)) {
> -
> -                     if (m_CMP_HORDER_SANAMET(comp-
> >comp_info.name, i_comp->comp_info.name) < 0){
> -                             found_pos = true;
> -                             break;
> +     comp->su->list_of_comp.push_back(comp);
> +     std::sort(comp->su->list_of_comp.begin(), comp->su-
> >list_of_comp.end(), [] (const AVD_COMP *c1, const AVD_COMP *c2) ->
> bool {
> +                     if (c1->comp_info.inst_level < c2-
> >comp_info.inst_level) return true;
> +                     if (c1->comp_info.inst_level == c2-
> >comp_info.inst_level) {
> +                             if (m_CMP_HORDER_SANAMET(c1-
> >comp_info.name, c2->comp_info.name) < 0)
> +                                     return true;
>                       }
> -                     prev_comp = i_comp;
> -                     i_comp = i_comp->su_comp_next;
> -                     if ((i_comp != NULL) && (i_comp-
> >comp_info.inst_level > comp->comp_info.inst_level)) {
> -                             found_pos = true;
> -                             break;
> -                     }
> -
> -             }
> -             if (found_pos || (i_comp == NULL))
> -                     break;
> -             prev_comp = i_comp;
> -             i_comp = i_comp->su_comp_next;
> -     }
> -     if (prev_comp == NULL) {
> -             comp->su_comp_next = comp->su->list_of_comp;
> -             comp->su->list_of_comp = comp;
> -     } else {
> -             prev_comp->su_comp_next = comp;
> -             comp->su_comp_next = i_comp;
> -     }
> +                     return false;
> +             });
> 
>       /* Verify if the SUs preinstan value need to be changed */
>       if (comp_is_preinstantiable(comp) == true) {
> @@ -804,7 +760,6 @@ void AVD_SU::set_readiness_state(SaAmfRe
>       if (saAmfSuReadinessState == readiness_state)
>               return;
> 
> -     AVD_COMP *comp = NULL;
>       osafassert(readiness_state <= SA_AMF_READINESS_STOPPING);
>       TRACE_ENTER2("'%s' %s", name.value,
>               avd_readiness_state_name[readiness_state]);
> @@ -819,8 +774,8 @@ void AVD_SU::set_readiness_state(SaAmfRe
> 
>       /* Since Su readiness state has changed, we need to change it for all
> the
>        * component in this SU.*/
> -     comp = list_of_comp;
> -     while (comp != NULL) {
> +
> +     for (const auto& comp : list_of_comp) {
>               SaAmfReadinessStateT saAmfCompReadinessState;
>               if ((saAmfSuReadinessState ==
> SA_AMF_READINESS_IN_SERVICE) &&
>                               (comp->saAmfCompOperState ==
> SA_AMF_OPERATIONAL_ENABLED)) {
> @@ -832,7 +787,6 @@ void AVD_SU::set_readiness_state(SaAmfRe
>                       saAmfCompReadinessState =
> SA_AMF_READINESS_OUT_OF_SERVICE;
> 
>               avd_comp_readiness_state_set(comp,
> saAmfCompReadinessState);
> -             comp = comp->su_comp_next;
>       }
> 
>       TRACE_LEAVE();
> @@ -1028,7 +982,7 @@ void AVD_SU::unlock_instantiation(SaImmO
> 
>       TRACE_ENTER2("'%s'", name.value);
> 
> -     if (list_of_comp == NULL) {
> +     if (list_of_comp.empty() == true) {
>               report_admin_op_error(immoi_handle, invocation,
> SA_AIS_ERR_BAD_OPERATION, NULL,
>                               "There is no component configured for SU
> '%s'.", name.value);
>               goto done;
> @@ -2057,12 +2011,7 @@ void AVD_SU::set_saAmfSUPreInstantiable(
>   * resets the assign flag for all contained components
>   */
>  void AVD_SU::reset_all_comps_assign_flag() {
> -     AVD_COMP *t_comp = list_of_comp;
> -     // TODO(hafe) add and use a comp method
> -     while (t_comp != NULL) {
> -             t_comp->assign_flag = false;
> -             t_comp = t_comp->su_comp_next;
> -     }
> +     std::for_each(list_of_comp.begin(), list_of_comp.end(),
> [](AVD_COMP *comp ) {comp->set_unassigned();});
>  }
> 
>  /**
> @@ -2071,20 +2020,20 @@ void AVD_SU::reset_all_comps_assign_flag
>   * @return
>   */
>  AVD_COMP *AVD_SU::find_unassigned_comp_that_provides_cstype(const
> SaNameT *cstype) {
> -     AVD_COMP *l_comp = list_of_comp;
> -     while (l_comp != NULL) {
> +     AVD_COMP *l_comp = nullptr;
> +     for (const auto& comp : list_of_comp) {
> +             l_comp = comp;
>               bool npi_is_assigned = false;
>               AVD_COMP_TYPE *comptype = comptype_db-
> >find(Amf::to_string(&l_comp->saAmfCompType));
>               osafassert(comptype);
>               if ((comptype->saAmfCtCompCategory ==
> SA_AMF_COMP_LOCAL) && is_comp_assigned_any_csi(l_comp))
>                       npi_is_assigned = true;
> 
> -             if ((l_comp->assign_flag == false) && (npi_is_assigned ==
> false)) {
> +             if ((l_comp->is_assigned() == false) && (npi_is_assigned ==
> false)) {
>                       AVD_COMPCS_TYPE *cst =
> avd_compcstype_find_match(cstype, l_comp);
>                       if (cst != NULL)
>                               break;
>               }
> -             l_comp = l_comp->su_comp_next;
>       }
> 
>       return l_comp;
> @@ -2097,8 +2046,7 @@ AVD_COMP *AVD_SU::find_unassigned_comp_t
>   */
>  void AVD_SU::disable_comps(SaAisErrorT result)
>  {
> -     AVD_COMP *comp;
> -     for (comp = list_of_comp; comp; comp = comp->su_comp_next) {
> +     for (const auto& comp : list_of_comp) {
>               comp->curr_num_csi_actv = 0;
>               comp->curr_num_csi_stdby = 0;
>               avd_comp_oper_state_set(comp,
> SA_AMF_OPERATIONAL_DISABLED);
> @@ -2180,7 +2128,7 @@ SaAisErrorT AVD_SU::check_su_stability()
>               rc = SA_AIS_ERR_BAD_OPERATION;
>               goto done;
>       }
> -     for (AVD_COMP *comp = list_of_comp; comp; comp = comp-
> >su_comp_next) {
> +     for (const auto& comp : list_of_comp) {
>               rc = check_comp_stability(comp);
>               if (rc != SA_AIS_OK)
>                       goto done;

------------------------------------------------------------------------------
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