ack, code review only. Minor comments below/Thanks HansN
On 01/25/2016 05:35 AM, Gary Lee wrote:
> osaf/services/saf/amf/amfd/app.cc | 68 ++++----
> osaf/services/saf/amf/amfd/apptype.cc | 61 ++++---
> osaf/services/saf/amf/amfd/clm.cc | 14 +-
> osaf/services/saf/amf/amfd/cluster.cc | 2 +-
> osaf/services/saf/amf/amfd/comp.cc | 169 ++++++++++----------
> osaf/services/saf/amf/amfd/compcstype.cc | 174 ++++++++++-----------
> osaf/services/saf/amf/amfd/comptype.cc | 43 ++--
> osaf/services/saf/amf/amfd/csi.cc | 248
> +++++++++++++++++-------------
> osaf/services/saf/amf/amfd/csiattr.cc | 4 +-
> osaf/services/saf/amf/amfd/cstype.cc | 55 ++----
> osaf/services/saf/amf/amfd/ctcstype.cc | 67 ++++----
> 11 files changed, 465 insertions(+), 440 deletions(-)
>
>
> diff --git a/osaf/services/saf/amf/amfd/app.cc
> b/osaf/services/saf/amf/amfd/app.cc
> --- a/osaf/services/saf/amf/amfd/app.cc
> +++ b/osaf/services/saf/amf/amfd/app.cc
> @@ -26,6 +26,8 @@
> AmfDb<std::string, AVD_APP> *app_db = 0;
>
> AVD_APP::AVD_APP() :
> + name{},
> + saAmfAppType{},
> saAmfApplicationAdminState(SA_AMF_ADMIN_UNLOCKED),
> saAmfApplicationCurrNumSGs(0),
> list_of_sg(nullptr),
> @@ -33,11 +35,11 @@
> app_type_list_app_next(nullptr),
> app_type(nullptr)
> {
> - memset(&name, 0, sizeof(SaNameT));
> - memset(&saAmfAppType, 0, sizeof(SaNameT));
> }
>
> -AVD_APP::AVD_APP(const SaNameT* dn) :
> +AVD_APP::AVD_APP(const std::string& dn) :
> + name{dn},
> + saAmfAppType{},
> saAmfApplicationAdminState(SA_AMF_ADMIN_UNLOCKED),
> saAmfApplicationCurrNumSGs(0),
> list_of_sg(nullptr),
> @@ -45,10 +47,6 @@
> app_type_list_app_next(nullptr),
> app_type(nullptr)
> {
> - memset(&name, 0, sizeof(SaNameT));
> - memcpy(name.value, dn->value, dn->length);
> - name.length = dn->length;
> - memset(&saAmfAppType, 0, sizeof(SaNameT));
> }
>
> AVD_APP::~AVD_APP()
> @@ -58,7 +56,7 @@
> // TODO(hafe) change this to a destructor
> static void avd_app_delete(AVD_APP *app)
> {
> - app_db->erase(Amf::to_string(&app->name));
> + app_db->erase(app->name);
> m_AVSV_SEND_CKPT_UPDT_ASYNC_RMV(avd_cb, app, AVSV_CKPT_AVD_APP_CONFIG);
> avd_apptype_remove_app(app);
> delete app;
> @@ -66,7 +64,7 @@
>
> static void app_add_to_model(AVD_APP *app)
> {
> - TRACE_ENTER2("%s", app->name.value);
> + TRACE_ENTER2("%s", app->name.c_str());
>
> /* Check type link to see if it has been added already */
> if (app->app_type != nullptr) {
> @@ -74,10 +72,10 @@
> goto done;
> }
>
> - app_db->insert(Amf::to_string(&app->name), app);
> + app_db->insert(app->name, app);
>
> /* Find application type and make a link with app type */
> - app->app_type = avd_apptype_get(&app->saAmfAppType);
> + app->app_type = avd_apptype_get(app->saAmfAppType);
> osafassert(app->app_type);
> avd_apptype_add_app(app);
>
> @@ -160,7 +158,7 @@
> sg->app = nullptr;
> }
>
> -static int is_config_valid(const SaNameT *dn, const SaImmAttrValuesT_2
> **attributes,
> +static int is_config_valid(const std::string& dn, const SaImmAttrValuesT_2
> **attributes,
> const CcbUtilOperationData_t *opdata)
> {
> SaAisErrorT rc;
> @@ -168,15 +166,15 @@
> SaAmfAdminStateT admstate;
>
> /* Applications should be root objects */
> - if (strchr((char *)dn->value, ',') != nullptr) {
> - report_ccb_validation_error(opdata, "Parent to '%s' is not
> root", dn->value);
> + if (dn.find(',') != std::string::npos) {
> + report_ccb_validation_error(opdata, "Parent to '%s' is not
> root", dn.c_str());
> return 0;
> }
>
> rc = immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfAppType"),
> attributes, 0, &aname);
> osafassert(rc == SA_AIS_OK);
>
> - if (avd_apptype_get(&aname) == nullptr) {
> + if (avd_apptype_get(Amf::to_string(&aname)) == nullptr) {
> /* App type does not exist in current model, check CCB */
> if (opdata == nullptr) {
> report_ccb_validation_error(opdata, "'%s' does not
> exist in model", aname.value);
> @@ -191,32 +189,35 @@
>
> if
> ((immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfApplicationAdminState"),
> attributes, 0, &admstate) == SA_AIS_OK) &&
> !avd_admin_state_is_valid(admstate, opdata)) {
> - report_ccb_validation_error(opdata, "Invalid
> saAmfApplicationAdminState %u for '%s'", admstate, dn->value);
> + report_ccb_validation_error(opdata, "Invalid
> saAmfApplicationAdminState %u for '%s'", admstate, dn.c_str());
> return 0;
> }
>
> return 1;
> }
>
> -AVD_APP *avd_app_create(const SaNameT *dn, const SaImmAttrValuesT_2
> **attributes)
> +AVD_APP *avd_app_create(const std::string& dn, const SaImmAttrValuesT_2
> **attributes)
> {
> AVD_APP *app;
> SaAisErrorT error;
> + SaNameT app_type;
>
> - TRACE_ENTER2("'%s'", dn->value);
> + TRACE_ENTER2("'%s'", dn.c_str());
>
> /*
> ** If called at new active at failover, the object is found in the DB
> ** but needs to get configuration attributes initialized.
> */
> - app = app_db->find(Amf::to_string(dn));
> + app = app_db->find(dn);
> if (app == nullptr) {
> app = new AVD_APP(dn);
> - } else
> + } else {
> TRACE("already created, refreshing config...");
> + }
>
> - error = immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfAppType"),
> attributes, 0, &app->saAmfAppType);
> + error = immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfAppType"),
> attributes, 0, &app_type);
> osafassert(error == SA_AIS_OK);
> + app->saAmfAppType = Amf::to_string(&app_type);
>
> if
> (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfApplicationAdminState"),
> attributes, 0, &app->saAmfApplicationAdminState) != SA_AIS_OK) {
> /* Empty, assign default value */
> @@ -237,7 +238,7 @@
>
> switch (opdata->operationType) {
> case CCBUTIL_CREATE:
> - if (is_config_valid(&opdata->objectName,
> opdata->param.create.attrValues, opdata))
> + if (is_config_valid(Amf::to_string(&opdata->objectName),
> opdata->param.create.attrValues, opdata))
> rc = SA_AIS_OK;
> break;
> case CCBUTIL_MODIFY:
> @@ -246,7 +247,7 @@
>
> if (!strcmp(attribute->attrName, "saAmfAppType")) {
> SaNameT dn =
> *((SaNameT*)attribute->attrValues[0]);
> - if (nullptr == avd_apptype_get(&dn)) {
> + if (nullptr ==
> avd_apptype_get(Amf::to_string(&dn))) {
> report_ccb_validation_error(opdata,
> "saAmfAppType '%s' not found", dn.value);
> rc = SA_AIS_ERR_BAD_OPERATION;
> goto done;
> @@ -287,7 +288,7 @@
>
> switch (opdata->operationType) {
> case CCBUTIL_CREATE:
> - app = avd_app_create(&opdata->objectName,
> opdata->param.create.attrValues);
> + app = avd_app_create(Amf::to_string(&opdata->objectName),
> opdata->param.create.attrValues);
> osafassert(app);
> app_add_to_model(app);
> break;
> @@ -299,11 +300,11 @@
> const SaImmAttrValuesT_2 *attribute =
> &attr_mod->modAttr;
>
> if (!strcmp(attribute->attrName, "saAmfAppType")) {
> - LOG_NO("Modified saAmfAppType from '%s' to '%s'
> for '%s'", app->saAmfAppType.value,
> -
> (*((SaNameT*)attribute->attrValues[0])).value, app->name.value);
> + LOG_NO("Modified saAmfAppType from '%s' to '%s'
> for '%s'", app->saAmfAppType.c_str(),
> +
> (*((SaNameT*)attribute->attrValues[0])).value, app->name.c_str());
> avd_apptype_remove_app(app);
> - app->saAmfAppType =
> *((SaNameT*)attribute->attrValues[0]);
> - app->app_type =
> avd_apptype_get(&app->saAmfAppType);
[HansN] static_cast<SaNameT*> can be used
> + app->saAmfAppType =
> Amf::to_string((SaNameT*)attribute->attrValues[0]);
> + app->app_type =
> avd_apptype_get(app->saAmfAppType);
> avd_apptype_add_app(app);
> }
> else {
> @@ -398,14 +399,15 @@
> AVD_APP *app = app_db->find(Amf::to_string(objectName));
> SaImmAttrNameT attributeName;
> int i = 0;
> + const std::string obj(Amf::to_string(objectName));
>
> - TRACE_ENTER2("%s", objectName->value);
> + TRACE_ENTER2("%s", obj.c_str());
> osafassert(app != nullptr);
>
> while ((attributeName = attributeNames[i++]) != nullptr) {
> TRACE("Attribute %s", attributeName);
> if (!strcmp(attributeName, "saAmfApplicationCurrNumSGs")) {
> - avd_saImmOiRtObjectUpdate_sync(objectName,
> attributeName,
> + avd_saImmOiRtObjectUpdate_sync(obj, attributeName,
> SA_IMM_ATTR_SAUINT32T,
> &app->saAmfApplicationCurrNumSGs);
> } else {
> LOG_ER("Ignoring unknown attribute '%s'",
> attributeName);
> @@ -447,15 +449,15 @@
> while ((rc = immutil_saImmOmSearchNext_2(searchHandle, &dn,
> (SaImmAttrValuesT_2 ***)&attributes)) == SA_AIS_OK) {
>
> - if (!is_config_valid(&dn, attributes, nullptr))
> + if (!is_config_valid(Amf::to_string(&dn), attributes, nullptr))
> goto done2;
>
> - if ((app = avd_app_create(&dn, (const SaImmAttrValuesT_2
> **)attributes)) == nullptr)
> + if ((app = avd_app_create(Amf::to_string(&dn), (const
> SaImmAttrValuesT_2 **)attributes)) == nullptr)
> goto done2;
>
> app_add_to_model(app);
>
> - if (avd_sg_config_get(&dn, app) != SA_AIS_OK)
> + if (avd_sg_config_get(Amf::to_string(&dn), app) != SA_AIS_OK)
> goto done2;
>
> if (avd_si_config_get(app) != SA_AIS_OK)
> diff --git a/osaf/services/saf/amf/amfd/apptype.cc
> b/osaf/services/saf/amf/amfd/apptype.cc
> --- a/osaf/services/saf/amf/amfd/apptype.cc
> +++ b/osaf/services/saf/amf/amfd/apptype.cc
> @@ -27,23 +27,23 @@
> AmfDb<std::string, AVD_APP_TYPE> *app_type_db = 0;
>
> //
> -AVD_APP_TYPE::AVD_APP_TYPE(const SaNameT* dn) {
> - memcpy(name.value, dn->value, dn->length);
> - name.length = dn->length;
> +AVD_APP_TYPE::AVD_APP_TYPE(const std::string& dn) :
> + name(dn)
> +{
> }
>
> //
> AVD_APP_TYPE::~AVD_APP_TYPE() {
> }
>
> -AVD_APP_TYPE *avd_apptype_get(const SaNameT *dn)
> +AVD_APP_TYPE *avd_apptype_get(const std::string& dn)
> {
> - return app_type_db->find(Amf::to_string(dn));
> + return app_type_db->find(dn);
> }
>
> static void apptype_delete(AVD_APP_TYPE **apptype)
> {
> - app_type_db->erase(Amf::to_string(&(*apptype)->name));
> + app_type_db->erase((*apptype)->name);
>
> (*apptype)->sgAmfApptSGTypes.clear();
> delete *apptype;
> @@ -54,29 +54,30 @@
> {
> unsigned int rc;
> osafassert(app_type != nullptr);
> - TRACE("'%s'", app_type->name.value);
> + TRACE("'%s'", app_type->name.c_str());
>
> - rc = app_type_db->insert(Amf::to_string(&app_type->name), app_type);
> + rc = app_type_db->insert(app_type->name, app_type);
> osafassert(rc == NCSCC_RC_SUCCESS);
> }
>
> -static int is_config_valid(const SaNameT *dn, const SaImmAttrValuesT_2
> **attributes,
> +static int is_config_valid(const std::string& dn, const SaImmAttrValuesT_2
> **attributes,
> const CcbUtilOperationData_t *opdata)
> {
> int i = 0;
> unsigned j;
> - char *parent;
> + std::string::size_type parent;
> AVD_AMF_SG_TYPE *sg_type;
> const SaImmAttrValuesT_2 *attr;
>
> - if ((parent = strchr((char*)dn->value, ',')) == nullptr) {
> - report_ccb_validation_error(opdata, "No parent to '%s' ",
> dn->value);
> + parent = dn.find(',');
> + if (parent == std::string::npos) {
> + report_ccb_validation_error(opdata, "No parent to '%s' ",
> dn.c_str());
> return 0;
> }
>
> /* AppType should be children to AppBaseType */
> - if (strncmp(++parent, "safAppType=", 11) != 0) {
> - report_ccb_validation_error(opdata, "Wrong parent '%s' to '%s'
> ", parent, dn->value);
> + if (dn.compare(parent + 1, 11, "safAppType=") != 0) {
> + report_ccb_validation_error(opdata, "Wrong parent '%s' to '%s'
> ", dn.substr(0, parent).c_str(), dn.c_str());
> return 0;
> }
>
> @@ -108,7 +109,7 @@
> return 1;
> }
>
> -static AVD_APP_TYPE *apptype_create(SaNameT *dn, const SaImmAttrValuesT_2
> **attributes)
> +static AVD_APP_TYPE *apptype_create(const std::string& dn, const
> SaImmAttrValuesT_2 **attributes)
> {
> int i = 0;
> unsigned int j;
> @@ -116,7 +117,7 @@
> AVD_APP_TYPE *app_type;
> const SaImmAttrValuesT_2 *attr;
>
> - TRACE_ENTER2("'%s'", dn->value);
> + TRACE_ENTER2("'%s'", dn.c_str());
>
> app_type = new AVD_APP_TYPE(dn);
>
> @@ -128,7 +129,7 @@
> osafassert(attr->attrValuesNumber > 0);
>
> for (j = 0; j < attr->attrValuesNumber; j++) {
> - app_type->sgAmfApptSGTypes.push_back(*((SaNameT
> *)attr->attrValues[j]));
> + app_type->sgAmfApptSGTypes.push_back(Amf::to_string((SaNameT
> *)attr->attrValues[j]));
> }
>
> rc = 0;
> @@ -148,26 +149,28 @@
> AVD_APP *app;
> bool app_exist = false;
> CcbUtilOperationData_t *t_opData;
> + const std::string object_name(Amf::to_string(&opdata->objectName));
>
> - TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId,
> opdata->objectName.value);
> + TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId, object_name.c_str());
>
> switch (opdata->operationType) {
> case CCBUTIL_CREATE:
> - if (is_config_valid(&opdata->objectName,
> opdata->param.create.attrValues, opdata))
> + if (is_config_valid(object_name,
> opdata->param.create.attrValues, opdata))
> rc = SA_AIS_OK;
> break;
> case CCBUTIL_MODIFY:
> report_ccb_validation_error(opdata, "Modification of
> SaAmfAppType not supported");
> break;
> case CCBUTIL_DELETE:
> - app_type = avd_apptype_get(&opdata->objectName);
> + app_type = avd_apptype_get(object_name);
> if (nullptr != app_type->list_of_app) {
> /* check whether there exists a delete operation for
> * each of the App in the app_type list in the current
> CCB
> */
> app = app_type->list_of_app;
> while (app != nullptr) {
> - t_opData =
> ccbutil_getCcbOpDataByDN(opdata->ccbId, &app->name);
> + const SaNameTWrapper app_name(app->name);
> + t_opData =
> ccbutil_getCcbOpDataByDN(opdata->ccbId, app_name);
> if ((t_opData == nullptr) ||
> (t_opData->operationType != CCBUTIL_DELETE)) {
> app_exist = true;
> break;
> @@ -175,7 +178,7 @@
> app = app->app_type_list_app_next;
> }
> if (app_exist == true) {
> - report_ccb_validation_error(opdata,
> "SaAmfAppType '%s' is in use", app_type->name.value);
> + report_ccb_validation_error(opdata,
> "SaAmfAppType '%s' is in use", app_type->name.c_str());
> goto done;
> }
> }
> @@ -198,7 +201,8 @@
>
> switch (opdata->operationType) {
> case CCBUTIL_CREATE:
> - app_type = apptype_create(&opdata->objectName,
> opdata->param.create.attrValues);
> + app_type = apptype_create(Amf::to_string(&opdata->objectName),
> + opdata->param.create.attrValues);
> osafassert(app_type);
> apptype_add_to_model(app_type);
> break;
> @@ -217,7 +221,7 @@
> SaAisErrorT rc = SA_AIS_ERR_INVALID_PARAM, error;
> SaImmSearchHandleT searchHandle;
> SaImmSearchParametersT_2 searchParam;
> - SaNameT dn;
> + SaNameT dn_name;
> const SaImmAttrValuesT_2 **attributes;
> const char *className = "SaAmfAppType";
> AVD_APP_TYPE *app_type;
> @@ -237,12 +241,13 @@
> goto done1;
> }
>
> - while (immutil_saImmOmSearchNext_2(searchHandle, &dn,
> (SaImmAttrValuesT_2 ***)&attributes) == SA_AIS_OK) {
> - if (!is_config_valid(&dn, attributes, nullptr))
> + while (immutil_saImmOmSearchNext_2(searchHandle, &dn_name,
> (SaImmAttrValuesT_2 ***)&attributes) == SA_AIS_OK) {
> + std::string dn(Amf::to_string(&dn_name));
> + if (!is_config_valid(dn, attributes, nullptr))
> goto done2;
>
> - if ((app_type = avd_apptype_get(&dn)) == nullptr ) {
> - if ((app_type = apptype_create(&dn, attributes)) ==
> nullptr)
> + if ((app_type = avd_apptype_get(dn)) == nullptr ) {
> + if ((app_type = apptype_create(dn, attributes)) ==
> nullptr)
> goto done2;
>
> apptype_add_to_model(app_type);
> diff --git a/osaf/services/saf/amf/amfd/clm.cc
> b/osaf/services/saf/amf/amfd/clm.cc
> --- a/osaf/services/saf/amf/amfd/clm.cc
> +++ b/osaf/services/saf/amf/amfd/clm.cc
> @@ -228,13 +228,14 @@
> for (i = 0; i < notificationBuffer->numberOfItems; i++)
> {
> notifItem = ¬ificationBuffer->notification[i];
> + const std::string
> node_name(Amf::to_string(¬ifItem->clusterNode.nodeName));
> switch(step) {
> case SA_CLM_CHANGE_VALIDATE:
> if(notifItem->clusterChange == SA_CLM_NODE_LEFT) {
> node =
> avd_node_find_nodeid(notifItem->clusterNode.nodeId);
> if (node == nullptr) {
> LOG_IN("%s: CLM node '%s' is not an AMF
> cluster member",
> - __FUNCTION__,
> notifItem->clusterNode.nodeName.value);
> + __FUNCTION__,
> node_name.c_str());
> goto done;
> }
> /* store the invocation for clm response */
> @@ -251,7 +252,7 @@
> node =
> avd_node_find_nodeid(notifItem->clusterNode.nodeId);
> if (node == nullptr) {
> LOG_IN("%s: CLM node '%s' is not an AMF cluster
> member",
> - __FUNCTION__,
> notifItem->clusterNode.nodeName.value);
> + __FUNCTION__, node_name.c_str());
> goto done;
> }
> if ( notifItem->clusterChange == SA_CLM_NODE_LEFT ||
> @@ -274,7 +275,7 @@
> node =
> avd_node_find_nodeid(notifItem->clusterNode.nodeId);
> if (node == nullptr) {
> LOG_IN("%s: CLM node '%s' is not an AMF
> cluster member",
> - __FUNCTION__,
> notifItem->clusterNode.nodeName.value);
> + __FUNCTION__,
> node_name.c_str());
> goto done;
> }
> TRACE(" Node Left: rootCauseEntity %s for node
> %u", rootCauseEntity->value,
> @@ -336,10 +337,9 @@
> for (std::map<std::string, AVD_AVND
> *>::const_iterator it = node_name_db->begin();
> it != node_name_db->end();
> it++) {
> node = it->second;
> - if (0 ==
> strncmp((char*)node->saAmfNodeClmNode.value,
> -
> (char*)notifItem->clusterNode.nodeName.value,
> -
> notifItem->clusterNode.nodeName.length))
> - break;
> + if
> (node->saAmfNodeClmNode.compare(node_name) == 0) {
> + break;
> + }
> }
> if ( node != nullptr ) {
> memcpy(&(node->node_info),
> &(notifItem->clusterNode),
> 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
> @@ -218,7 +218,7 @@
> goto done;
> }
>
> - avd_cluster->saAmfCluster = dn;
> + avd_cluster->saAmfCluster = Amf::to_string(&dn);
>
> /* Cluster should be root object */
> if (strchr((char *)dn.value, ',') != nullptr) {
> 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
> @@ -45,9 +45,10 @@
> void avd_comp_db_add(AVD_COMP *comp)
> {
> unsigned int rc;
> + const std::string comp_name(Amf::to_string(&comp->comp_info.name));
>
> - if (comp_db->find(Amf::to_string(&comp->comp_info.name)) == nullptr) {
> - rc = comp_db->insert(Amf::to_string(&comp->comp_info.name),
> comp);
> + if (comp_db->find(comp_name) == nullptr) {
> + rc = comp_db->insert(comp_name, comp);
> osafassert(rc == NCSCC_RC_SUCCESS);
> }
> }
> @@ -89,15 +90,15 @@
> }
>
> //
> -AVD_COMP::AVD_COMP(const SaNameT *dn) {
> +AVD_COMP::AVD_COMP(const std::string& dn) {
> initialize();
> -
> - memcpy(&comp_info.name.value, dn->value, dn->length);
> - comp_info.name.length = dn->length;
> + memset(&comp_info.name, 0, sizeof(comp_info.name));
> + memcpy(&comp_info.name.value, dn.c_str(), dn.length());
> + comp_info.name.length = dn.length();
> }
>
> //
> -AVD_COMP *avd_comp_new(const SaNameT *dn)
> +AVD_COMP *avd_comp_new(const std::string& dn)
> {
> AVD_COMP *comp;
>
> @@ -125,26 +126,26 @@
>
> if ((comp->saAmfCompPresenceState ==
> SA_AMF_PRESENCE_TERMINATION_FAILED) &&
> (pres_state == SA_AMF_PRESENCE_UNINSTANTIATED)){
> - avd_alarm_clear(&comp->comp_info.name,
> + avd_alarm_clear(Amf::to_string(&comp->comp_info.name),
> SA_AMF_NTFID_COMP_CLEANUP_FAILED,
> SA_NTF_SOFTWARE_ERROR);
> }
>
> if ((comp->saAmfCompPresenceState ==
> SA_AMF_PRESENCE_INSTANTIATION_FAILED) &&
> (pres_state == SA_AMF_PRESENCE_UNINSTANTIATED)){
> - avd_alarm_clear(&comp->comp_info.name,
> + avd_alarm_clear(Amf::to_string(&comp->comp_info.name),
> SA_AMF_NTFID_COMP_INSTANTIATION_FAILED,
> SA_NTF_SOFTWARE_ERROR);
> }
>
>
> comp->saAmfCompPresenceState = pres_state;
> - avd_saImmOiRtObjectUpdate(&comp->comp_info.name,
> "saAmfCompPresenceState",
> + avd_saImmOiRtObjectUpdate(Amf::to_string(&comp->comp_info.name),
> "saAmfCompPresenceState",
> SA_IMM_ATTR_SAUINT32T, &comp->saAmfCompPresenceState);
> m_AVSV_SEND_CKPT_UPDT_ASYNC_UPDT(avd_cb, comp,
> AVSV_CKPT_COMP_PRES_STATE);
>
> if (comp->saAmfCompPresenceState ==
> SA_AMF_PRESENCE_INSTANTIATION_FAILED)
> - avd_send_comp_inst_failed_alarm(&comp->comp_info.name,
> &node->name);
> +
> avd_send_comp_inst_failed_alarm(Amf::to_string(&comp->comp_info.name),
> node->name);
> else if (comp->saAmfCompPresenceState ==
> SA_AMF_PRESENCE_TERMINATION_FAILED)
> - avd_send_comp_clean_failed_alarm(&comp->comp_info.name,
> &node->name);
> +
> avd_send_comp_clean_failed_alarm(Amf::to_string(&comp->comp_info.name),
> node->name);
>
> if ((comp->su->sg_of_su->saAmfSGAutoRepair == true) &&
> (node->saAmfNodeAutoRepair == true) &&
> @@ -158,9 +159,9 @@
> avd_pres_state_name[pres_state]);
> saflog(LOG_NOTICE, amfSvcUsrName,
> "Ordering reboot of '%s' as repair action",
> - node->name.value);
> + node->name.c_str());
> LOG_NO("Node Failfast for '%s' as '%s' enters Term/Inst Failed
> state",
> - node->name.value,comp->comp_info.name.value);
> + node->name.c_str(),comp->comp_info.name.value);
> avd_d2n_reboot_snd(node);
> }
> TRACE_LEAVE();
> @@ -173,7 +174,7 @@
> comp->comp_info.name.value,
> avd_oper_state_name[comp->saAmfCompOperState],
> avd_oper_state_name[oper_state]);
>
> comp->saAmfCompOperState = oper_state;
> - avd_saImmOiRtObjectUpdate(&comp->comp_info.name, "saAmfCompOperState",
> + avd_saImmOiRtObjectUpdate(Amf::to_string(&comp->comp_info.name),
> "saAmfCompOperState",
> SA_IMM_ATTR_SAUINT32T, &comp->saAmfCompOperState);
> m_AVSV_SEND_CKPT_UPDT_ASYNC_UPDT(avd_cb, comp,
> AVSV_CKPT_COMP_OPER_STATE);
> TRACE_LEAVE();
> @@ -190,7 +191,7 @@
> avd_readiness_state_name[comp->saAmfCompReadinessState],
> avd_readiness_state_name[readiness_state]);
> comp->saAmfCompReadinessState = readiness_state;
> if (comp->su->get_surestart() == false)
> - avd_saImmOiRtObjectUpdate(&comp->comp_info.name,
> "saAmfCompReadinessState",
> +
> avd_saImmOiRtObjectUpdate(Amf::to_string(&comp->comp_info.name),
> "saAmfCompReadinessState",
> SA_IMM_ATTR_SAUINT32T,
> &comp->saAmfCompReadinessState);
> m_AVSV_SEND_CKPT_UPDT_ASYNC_UPDT(avd_cb, comp,
> AVSV_CKPT_COMP_READINESS_STATE);
> TRACE_LEAVE();
> @@ -205,9 +206,9 @@
>
> /* alarm & notifications */
> if(proxy_status == SA_AMF_PROXY_STATUS_UNPROXIED)
> -
> avd_send_comp_proxy_status_unproxied_alarm(&comp->comp_info.name);
> +
> avd_send_comp_proxy_status_unproxied_alarm(Amf::to_string(&comp->comp_info.name));
> else if(proxy_status == SA_AMF_PROXY_STATUS_PROXIED)
> - avd_send_comp_proxy_status_proxied_ntf(&comp->comp_info.name,
> +
> avd_send_comp_proxy_status_proxied_ntf(Amf::to_string(&comp->comp_info.name),
>
> SA_AMF_PROXY_STATUS_UNPROXIED,
>
> SA_AMF_PROXY_STATUS_PROXIED);
>
> @@ -229,7 +230,7 @@
> */
> static void comp_add_to_model(AVD_COMP *comp)
> {
> - SaNameT dn;
> + std::string dn;
> AVD_SU *su = comp->su;
>
> TRACE_ENTER2("%s", comp->comp_info.name.value);
> @@ -240,11 +241,11 @@
> goto done;
> }
>
> - avsv_sanamet_init(&comp->comp_info.name, &dn, "safSu");
> - su = comp->su = su_db->find(Amf::to_string(&dn));
> + avsv_sanamet_init(Amf::to_string(&comp->comp_info.name), dn, "safSu");
> + su = comp->su = su_db->find(dn);
>
> avd_comp_db_add(comp);
> - comp->comp_type =
> comptype_db->find(Amf::to_string(&comp->saAmfCompType));
> + comp->comp_type = comptype_db->find(comp->saAmfCompType);
> osafassert(comp->comp_type);
> avd_comptype_add_comp(comp);
> su->add_comp(comp);
> @@ -290,7 +291,7 @@
> (node->node_state == AVD_AVND_STATE_NCS_INIT)) {
> if (avd_snd_su_msg(avd_cb, su) != NCSCC_RC_SUCCESS) {
> LOG_ER("SU '%s', Comp '%s': avd_snd_su_msg
> failed %s", __FUNCTION__,
> - su->name.value,
> comp->comp_info.name.value);
> + su->name.c_str(),
> comp->comp_info.name.value);
> goto done;
> }
> }
> @@ -302,13 +303,13 @@
> avd_comp_oper_state_set(comp, SA_AMF_OPERATIONAL_ENABLED);
>
> /* Set runtime cached attributes. */
> - avd_saImmOiRtObjectUpdate(&comp->comp_info.name,
> "saAmfCompReadinessState",
> + avd_saImmOiRtObjectUpdate(Amf::to_string(&comp->comp_info.name),
> "saAmfCompReadinessState",
> SA_IMM_ATTR_SAUINT32T, &comp->saAmfCompReadinessState);
>
> - avd_saImmOiRtObjectUpdate(&comp->comp_info.name, "saAmfCompOperState",
> + avd_saImmOiRtObjectUpdate(Amf::to_string(&comp->comp_info.name),
> "saAmfCompOperState",
> SA_IMM_ATTR_SAUINT32T, &comp->saAmfCompOperState);
>
> - avd_saImmOiRtObjectUpdate(&comp->comp_info.name,
> "saAmfCompPresenceState",
> + avd_saImmOiRtObjectUpdate(Amf::to_string(&comp->comp_info.name),
> "saAmfCompPresenceState",
> SA_IMM_ATTR_SAUINT32T, &comp->saAmfCompPresenceState);
>
> m_AVSV_SEND_CKPT_UPDT_ASYNC_ADD(avd_cb, comp,
> AVSV_CKPT_AVD_COMP_CONFIG);
> @@ -323,20 +324,20 @@
> *
> * @return int
> */
> -static int is_config_valid(const SaNameT *dn, const SaImmAttrValuesT_2
> **attributes, CcbUtilOperationData_t *opdata)
> +static int is_config_valid(const std::string& dn, const SaImmAttrValuesT_2
> **attributes, CcbUtilOperationData_t *opdata)
> {
> SaAisErrorT rc;
> SaNameT aname;
> - char *parent;
> + std::string::size_type pos;
> SaUint32T value;
>
> - if ((parent = strchr((char*)dn->value, ',')) == nullptr) {
> - report_ccb_validation_error(opdata, "No parent to '%s' ",
> dn->value);
> + if ((pos = dn.find(',')) == std::string::npos) {
> + report_ccb_validation_error(opdata, "No parent to '%s' ",
> dn.c_str());
> return 0;
> }
>
> - if (strncmp(++parent, "safSu=", 6) != 0) {
> - report_ccb_validation_error(opdata, "Wrong parent '%s' to '%s'
> ", parent, dn->value);
> + if (dn.compare(pos + 1, 6, "safSu=") != 0) {
> + report_ccb_validation_error(opdata, "Wrong parent '%s' to '%s'
> ", dn.substr(pos +1).c_str(), dn.c_str());
> return 0;
> }
>
> @@ -360,19 +361,19 @@
> if (rc == SA_AIS_OK) {
> if ((value < SA_AMF_NO_RECOMMENDATION) || (value >
> SA_AMF_NODE_FAILFAST)) {
> report_ccb_validation_error(opdata,
> "Illegal/unsupported saAmfCompRecoveryOnError value %u for '%s'",
> - value, dn->value);
> + value, dn.c_str());
> return 0;
> }
>
> if (value == SA_AMF_NO_RECOMMENDATION)
> LOG_NO("Invalid configuration,
> saAmfCompRecoveryOnError=NO_RECOMMENDATION(%u) for '%s'",
> - value, dn->value);
> + value, dn.c_str());
> }
>
> rc =
> immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCompDisableRestart"),
> attributes, 0, &value);
> if ((rc == SA_AIS_OK) && (value > SA_TRUE)) {
> report_ccb_validation_error(opdata, "Illegal
> saAmfCompDisableRestart value %u for '%s'",
> - value, dn->value);
> + value, dn.c_str());
> return 0;
> }
>
> @@ -486,40 +487,42 @@
> return 1;
> }
>
> -static AVD_COMP *comp_create(const SaNameT *dn, const SaImmAttrValuesT_2
> **attributes)
> +static AVD_COMP *comp_create(const std::string& dn, const SaImmAttrValuesT_2
> **attributes)
> {
> int rc = -1;
> AVD_COMP *comp;
> char *cmd_argv;
> const char *str;
> const AVD_COMP_TYPE *comptype;
> + SaNameT comp_type;
> SaAisErrorT error;
>
> - TRACE_ENTER2("'%s'", dn->value);
> + TRACE_ENTER2("'%s'", dn.c_str());
>
> /*
> ** If called at new active at failover, the object is found in the DB
> ** but needs to get configuration attributes initialized.
> */
> - if (nullptr == (comp = comp_db->find(Amf::to_string(dn)))) {
> + if (nullptr == (comp = comp_db->find(dn))) {
> if ((comp = avd_comp_new(dn)) == nullptr)
> goto done;
> }
> else
> TRACE("already created, refreshing config...");
>
> - error = immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCompType"),
> attributes, 0, &comp->saAmfCompType);
> + error = immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCompType"),
> attributes, 0, &comp_type);
> osafassert(error == SA_AIS_OK);
> + comp->saAmfCompType = Amf::to_string(&comp_type);
>
> - if ((comptype =
> comptype_db->find(Amf::to_string(&comp->saAmfCompType))) == nullptr) {
> - LOG_ER("saAmfCompType '%s' does not exist",
> comp->saAmfCompType.value);
> + if ((comptype = comptype_db->find(comp->saAmfCompType)) == nullptr) {
> + LOG_ER("saAmfCompType '%s' does not exist",
> comp->saAmfCompType.c_str());
> goto done;
> }
>
> /* TODO clean this up! */
> comp->comp_info.category =
> avsv_amfcompcategory_to_avsvcomptype(comptype->saAmfCtCompCategory);
> if (comp->comp_info.category == AVSV_COMP_TYPE_INVALID) {
> - LOG_ER("Comp category %x invalid for '%s'",
> comp->comp_info.category, comp->saAmfCompType.value);
> + LOG_ER("Comp category %x invalid for '%s'",
> comp->comp_info.category, comp->saAmfCompType.c_str());
> goto done;
> }
>
> @@ -679,7 +682,7 @@
> *
> * @return int
> */
> -SaAisErrorT avd_comp_config_get(const SaNameT *su_name, AVD_SU *su)
> +SaAisErrorT avd_comp_config_get(const std::string& su_name, AVD_SU *su)
> {
> SaAisErrorT rc, error = SA_AIS_ERR_FAILED_OPERATION;
> SaImmSearchHandleT searchHandle;
> @@ -722,7 +725,7 @@
> searchParam.searchOneAttr.attrValueType = SA_IMM_ATTR_SASTRINGT;
> searchParam.searchOneAttr.attrValue = &className;
>
> - if ((rc = immutil_saImmOmSearchInitialize_2(avd_cb->immOmHandle,
> su_name,
> + if ((rc = immutil_saImmOmSearchInitialize_o2(avd_cb->immOmHandle,
> su_name.c_str(),
> SA_IMM_SUBTREE, SA_IMM_SEARCH_ONE_ATTR |
> SA_IMM_SEARCH_GET_SOME_ATTR,
> &searchParam, configAttributes, &searchHandle)) != SA_AIS_OK) {
>
> @@ -733,22 +736,22 @@
> while ((rc = immutil_saImmOmSearchNext_2(searchHandle, &comp_name,
> (SaImmAttrValuesT_2 ***)&attributes)) == SA_AIS_OK) {
>
> - if (!is_config_valid(&comp_name, attributes, nullptr))
> + if (!is_config_valid(Amf::to_string(&comp_name), attributes,
> nullptr))
> goto done2;
>
> - if ((comp = comp_create(&comp_name, attributes)) == nullptr)
> + if ((comp = comp_create(Amf::to_string(&comp_name),
> attributes)) == nullptr)
> goto done2;
>
> num_of_comp_in_su ++;
> comp_add_to_model(comp);
>
> - if (avd_compcstype_config_get(&comp_name, comp) != SA_AIS_OK)
> + if (avd_compcstype_config_get(Amf::to_string(&comp_name), comp)
> != SA_AIS_OK)
> goto done2;
> }
>
> /* If there are no component in the SU, we treat it as invalid
> configuration. */
> if (0 == num_of_comp_in_su) {
> - LOG_ER("There is no component configured for SU '%s'",
> su_name->value);
> + LOG_ER("There is no component configured for SU '%s'",
> su_name.c_str());
> goto done2;
> }
>
> @@ -775,9 +778,10 @@
> const SaNameT *objectName, SaImmAdminOperationIdT opId,
> const SaImmAdminOperationParamsT_2 **params)
> {
> - TRACE_ENTER2("%llu, '%s', %llu", invocation, objectName->value,
> opId);
> + const std::string object_name(Amf::to_string(objectName));
> + TRACE_ENTER2("%llu, '%s', %llu", invocation, object_name.c_str(),
> opId);
>
> - AVD_COMP *comp = comp_db->find(Amf::to_string(objectName));
> + AVD_COMP *comp = comp_db->find(object_name);
> osafassert(comp != nullptr);
>
> switch (opId) {
> @@ -785,28 +789,28 @@
> case SA_AMF_ADMIN_RESTART:
> if (comp->admin_pend_cbk.invocation != 0) {
> report_admin_op_error(immOiHandle, invocation,
> SA_AIS_ERR_TRY_AGAIN, nullptr,
> - "Component undergoing admin operation
> '%s'", objectName->value);
> + "Component undergoing admin operation
> '%s'", object_name.c_str());
> } else if ((comp->su->sg_of_su->sg_ncs_spec == true) &&
> (comp->su->sg_of_su->sg_redundancy_model ==
> SA_AMF_2N_REDUNDANCY_MODEL)) {
> report_admin_op_error(immOiHandle, invocation,
> SA_AIS_ERR_BAD_OPERATION, nullptr,
> "Not allowed on comp of middleware
> 2N SU : %s, op_id: %llu",
> - objectName->value, opId);
> + object_name.c_str(), opId);
> }
> else if (comp->su->pend_cbk.invocation != 0) {
> report_admin_op_error(immOiHandle, invocation,
> SA_AIS_ERR_TRY_AGAIN, nullptr,
> - "SU undergoing admin operation '%s'",
> objectName->value);
> + "SU undergoing admin operation '%s'",
> object_name.c_str());
> }
> else if (comp->su->su_on_node->admin_node_pend_cbk.invocation
> != 0) {
> report_admin_op_error(immOiHandle, invocation,
> SA_AIS_ERR_TRY_AGAIN, nullptr,
> - "Node undergoing admin operation '%s'",
> objectName->value);
> + "Node undergoing admin operation '%s'",
> object_name.c_str());
> }
> else if (comp->saAmfCompPresenceState !=
> SA_AMF_PRESENCE_INSTANTIATED) {
> report_admin_op_error(immOiHandle, invocation,
> SA_AIS_ERR_BAD_OPERATION, nullptr,
> - "Component not instantiated '%s'",
> objectName->value);
> + "Component not instantiated '%s'",
> object_name.c_str());
> }
> else if (comp->saAmfCompOperState ==
> SA_AMF_OPERATIONAL_DISABLED) {
> report_admin_op_error(immOiHandle, invocation,
> SA_AIS_ERR_BAD_OPERATION, nullptr,
> - "Component disabled, first repair su or
> check node status'%s'", objectName->value);
> + "Component disabled, first repair su or
> check node status'%s'", object_name.c_str());
> } else {
> comp->admin_pend_cbk.admin_oper =
> static_cast<SaAmfAdminOperationIdT>(opId);
> comp->admin_pend_cbk.invocation = invocation;
> @@ -830,11 +834,11 @@
> AMFND will take care of reassignment.*/
>
> /* prepare the admin op req message and queue
> it */
> - if (avd_admin_op_msg_snd(&comp->comp_info.name,
> AVSV_SA_AMF_COMP,
> + if
> (avd_admin_op_msg_snd(Amf::to_string(&comp->comp_info.name), AVSV_SA_AMF_COMP,
>
> static_cast<SaAmfAdminOperationIdT>(opId),
> comp->su->su_on_node)
> != NCSCC_RC_SUCCESS) {
> report_admin_op_error(immOiHandle,
> invocation, SA_AIS_ERR_TIMEOUT, nullptr,
> - "Admin op request send
> failed '%s'", objectName->value);
> + "Admin op request send
> failed '%s'", object_name.c_str());
> comp->admin_pend_cbk.admin_oper =
> static_cast<SaAmfAdminOperationIdT>(0);
> comp->admin_pend_cbk.invocation = 0;
> }
> @@ -856,19 +860,20 @@
> static SaAisErrorT comp_rt_attr_cb(SaImmOiHandleT immOiHandle,
> const SaNameT *objectName, const SaImmAttrNameT *attributeNames)
> {
> - AVD_COMP *comp = comp_db->find(Amf::to_string(objectName));
> + const std::string object_name(Amf::to_string(objectName));
> + AVD_COMP *comp = comp_db->find(object_name);
> SaImmAttrNameT attributeName;
> int i = 0;
>
> - TRACE_ENTER2("'%s'", objectName->value);
> + TRACE_ENTER2("'%s'", object_name.c_str());
> osafassert(comp != nullptr);
>
> while ((attributeName = attributeNames[i++]) != nullptr) {
> if (!strcmp("saAmfCompRestartCount", attributeName)) {
> - avd_saImmOiRtObjectUpdate_sync(objectName,
> attributeName,
> + avd_saImmOiRtObjectUpdate_sync(object_name,
> attributeName,
> SA_IMM_ATTR_SAUINT32T,
> &comp->saAmfCompRestartCount);
> } else if (!strcmp("saAmfCompCurrProxyName", attributeName)) {
> - avd_saImmOiRtObjectUpdate_sync(objectName,
> attributeName,
> + avd_saImmOiRtObjectUpdate_sync(object_name,
> attributeName,
> SA_IMM_ATTR_SANAMET,
> &comp->saAmfCompCurrProxyName);
> /* TODO */
> } else if (!strcmp("saAmfCompCurrProxiedNames", attributeName))
> {
> @@ -928,18 +933,18 @@
> it != compcstype_db->end(); it++) {
> AVD_COMPCS_TYPE *compcstype = it->second;
> if (compcstype->comp == comp) {
> - SaNameT cstype_name;
> + std::string cstype_name;
> AVD_CTCS_TYPE *ctcstype = nullptr;
> AVD_CS_TYPE *cst = nullptr;
> -
> get_child_dn_from_ass_dn(&compcstype->name, &cstype_name);
> +
> get_child_dn_from_ass_dn(compcstype->name, cstype_name);
> //First check if this cstype exists in
> the sustem.
> - if ((cst =
> cstype_db->find(Amf::to_string(&cstype_name))) == nullptr) {
> + if ((cst =
> cstype_db->find(cstype_name)) == nullptr) {
> LOG_WA("cstype of '%s' is not
> preseint in AMF database",
> -
> compcstype->name.value);
> +
> compcstype->name.c_str());
> continue;
> }
> //ctcstype relationship should exists
> with all the cstypes.
> - if ((ctcstype = get_ctcstype(&dn,
> &cstype_name)) == nullptr) {
> + if ((ctcstype =
> get_ctcstype(Amf::to_string(&dn), cstype_name)) == nullptr) {
>
> report_ccb_validation_error(opdata, "ctcstype relationship "
> "between new
> comptype and cstype from"
> "component's
> compcstype(s) does not exist");
> @@ -1215,7 +1220,7 @@
>
> switch (opdata->operationType) {
> case CCBUTIL_CREATE:
> - if (is_config_valid(&opdata->objectName,
> opdata->param.create.attrValues, opdata))
> + if (is_config_valid(Amf::to_string(&opdata->objectName),
> opdata->param.create.attrValues, opdata))
> rc = SA_AIS_OK;
> break;
> case CCBUTIL_MODIFY:
> @@ -1252,7 +1257,7 @@
>
> comp = comp_db->find(Amf::to_string(&opdata->objectName));
> param.name = comp->comp_info.name;
> - comp_type = comptype_db->find(Amf::to_string(&comp->saAmfCompType));
> + comp_type = comptype_db->find(comp->saAmfCompType);
>
> su_node_ptr = comp->su->get_node_ptr();
>
> @@ -1280,18 +1285,18 @@
> if (!strcmp(attribute->attrName, "saAmfCompType")) {
>
> SaNameT *dn = (SaNameT*) value;
> - const std::string
> oldType(Amf::to_string(&comp->saAmfCompType));
> + const std::string oldType(comp->saAmfCompType);
> if (oldType.compare(Amf::to_string(dn)) == 0) {
> // ignore 'change' if it's being set to the
> same value
> - TRACE("saAmfCompType '%s' unchanged for '%s'",
> comp->saAmfCompType.value,
> + TRACE("saAmfCompType '%s' unchanged for '%s'",
> comp->saAmfCompType.c_str(),
> opdata->objectName.value);
> continue;
> }
>
> - TRACE("saAmfCompType modified from '%s' to '%s' for
> '%s'", comp->saAmfCompType.value, dn->value,
> + TRACE("saAmfCompType modified from '%s' to '%s' for
> '%s'", comp->saAmfCompType.c_str(), dn->value,
> opdata->objectName.value);
> avd_comptype_remove_comp(comp);
> - comp->saAmfCompType = *dn;
> + comp->saAmfCompType = Amf::to_string(dn);
> comp->comp_type = comptype_db->find(Amf::to_string(dn));
> avd_comptype_add_comp(comp);
> param.attr_id = saAmfCompType_ID;
> @@ -1616,14 +1621,14 @@
>
> } else if (!strcmp(attribute->attrName, "saAmfCompProxyCsi")) {
> if (value_is_deleted)
> - memset(&comp->comp_proxy_csi, 0,
> sizeof(comp->comp_proxy_csi));
> + comp->comp_proxy_csi = "";
> else
> - comp->comp_proxy_csi = *((SaNameT *)value);
> + comp->comp_proxy_csi = Amf::to_string((SaNameT
> *)value);
> } else if (!strcmp(attribute->attrName,
> "saAmfCompContainerCsi")) {
> if (value_is_deleted)
> - memset(&comp->comp_proxy_csi, 0,
> sizeof(comp->comp_container_csi));
> + comp->comp_proxy_csi = "";
> else
> - comp->comp_container_csi = *((SaNameT *)value);
> + comp->comp_container_csi =
> Amf::to_string((SaNameT *)value);
> } else {
> osafassert(0);
> }
> @@ -1674,7 +1679,7 @@
>
> switch (opdata->operationType) {
> case CCBUTIL_CREATE:
> - comp = comp_create(&opdata->objectName,
> opdata->param.create.attrValues);
> + comp = comp_create(Amf::to_string(&opdata->objectName),
> opdata->param.create.attrValues);
> osafassert(comp);
> comp_add_to_model(comp);
> break;
> @@ -1699,12 +1704,12 @@
> *
> * @return AVD_COMP*
> */
> -AVD_COMP *avd_comp_get_or_create(const SaNameT *dn)
> +AVD_COMP *avd_comp_get_or_create(const std::string& dn)
> {
> - AVD_COMP *comp = comp_db->find(Amf::to_string(dn));
> + AVD_COMP *comp = comp_db->find(dn);
>
> if (!comp) {
> - TRACE("'%s' does not exist, creating it", dn->value);
> + TRACE("'%s' does not exist, creating it", dn.c_str());
> comp = avd_comp_new(dn);
> osafassert(comp != nullptr);
> avd_comp_db_add(comp);
> @@ -1775,7 +1780,7 @@
> */
> bool AVD_COMP::saaware() const
> {
> - AVD_COMP_TYPE *comptype =
> comptype_db->find(Amf::to_string(&saAmfCompType));
> + AVD_COMP_TYPE *comptype = comptype_db->find(saAmfCompType);
> return (IS_COMP_SAAWARE(comptype->saAmfCtCompCategory));
> }
>
> 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
> @@ -32,37 +32,26 @@
> AmfDb<std::string, AVD_COMPCS_TYPE> *compcstype_db = nullptr;;
>
> //
> -// TODO(HANO) Temporary use this function instead of strdup which uses
> malloc.
> -// Later on remove this function and use std::string instead
> -#include <cstring>
> -static char *StrDup(const char *s)
> -{
> - char *c = new char[strlen(s) + 1];
> - std::strcpy(c,s);
> - return c;
> -}
> -
> -//
> AVD_COMPCS_TYPE::AVD_COMPCS_TYPE() {
> }
>
> //
> -AVD_COMPCS_TYPE::AVD_COMPCS_TYPE(const SaNameT *dn) {
> - memcpy(name.value, dn->value, dn->length);
> - name.length = dn->length;
> +AVD_COMPCS_TYPE::AVD_COMPCS_TYPE(const std::string& dn) :
> + name(dn)
> +{
> }
>
> void avd_compcstype_db_add(AVD_COMPCS_TYPE *cst)
> {
> unsigned int rc;
>
> - if (compcstype_db->find(Amf::to_string(&cst->name)) == nullptr) {
> - rc = compcstype_db->insert(Amf::to_string(&cst->name),cst);
> + if (compcstype_db->find(cst->name) == nullptr) {
> + rc = compcstype_db->insert(cst->name, cst);
> osafassert(rc == NCSCC_RC_SUCCESS);
> }
> }
>
> -AVD_COMPCS_TYPE *avd_compcstype_new(const SaNameT *dn)
> +AVD_COMPCS_TYPE *avd_compcstype_new(const std::string& dn)
> {
> AVD_COMPCS_TYPE *compcstype;
>
> @@ -75,10 +64,10 @@
> {
> /* Check comp link to see if it has been added already */
> if (cst->comp == nullptr) {
> - SaNameT dn;
> + std::string dn;
> avd_compcstype_db_add(cst);
> - avsv_sanamet_init(&cst->name, &dn, "safComp=");
> - cst->comp = comp_db->find(Amf::to_string(&dn));
> + avsv_sanamet_init(cst->name, dn, "safComp=");
> + cst->comp = comp_db->find(dn);
> }
> }
>
> @@ -98,13 +87,14 @@
> * row status is active.
> **************************************************************************/
>
> -AVD_COMPCS_TYPE * avd_compcstype_find_match(const SaNameT *cstype_name,
> const AVD_COMP *comp)
> +AVD_COMPCS_TYPE * avd_compcstype_find_match(const std::string& cstype_name,
> const AVD_COMP *comp)
> {
> AVD_COMPCS_TYPE *cst = nullptr;
> SaNameT dn;
> + const SaNameTWrapper cstype(cstype_name);
>
> TRACE_ENTER();
> - avsv_create_association_class_dn(cstype_name, &comp->comp_info.name,
> "safSupportedCsType", &dn);
> + avsv_create_association_class_dn(cstype, &comp->comp_info.name,
> "safSupportedCsType", &dn);
> TRACE("'%s'", dn.value);
> cst = compcstype_db->find(Amf::to_string(&dn));
> TRACE_LEAVE();
> @@ -117,35 +107,33 @@
> *
> * @return int
> */
> -static int is_config_valid(const SaNameT *dn, CcbUtilOperationData_t *opdata)
> +static int is_config_valid(const std::string& dn, CcbUtilOperationData_t
> *opdata)
> {
> - SaNameT comp_name;
> - const SaNameT *comptype_name;
> - SaNameT ctcstype_name = {0};
> - char *parent;
> + std::string comp_name;
> + std::string comptype_name;
> + std::string ctcstype_name;
> + std::string::size_type parent;
> AVD_COMP *comp;
> - char *cstype_name = StrDup((char*)dn->value);
> - char *p;
> + std::string cstype_name;
> + std::string::size_type comma;
>
> + TRACE_ENTER2("%s", dn.c_str());
> +
> /* This is an association class, the parent (SaAmfComp) should come
> after the second comma */
> - if ((parent = strchr((char*)dn->value, ',')) == nullptr) {
> - report_ccb_validation_error(opdata, "No parent to '%s' ",
> dn->value);
> + if ((parent = dn.find(',')) == std::string::npos) {
> + report_ccb_validation_error(opdata, "No parent to '%s' ",
> dn.c_str());
> goto free_cstype_name;
> }
>
> - parent++;
> -
> /* Second comma should be the parent */
> - if ((parent = strchr(parent, ',')) == nullptr) {
> - report_ccb_validation_error(opdata, "No parent to '%s' ",
> dn->value);
> + if ((parent = dn.find(',', parent + 1)) == std::string::npos) {
> + report_ccb_validation_error(opdata, "No parent to '%s' ",
> dn.c_str());
> goto free_cstype_name;
> }
>
> - parent++;
> -
> /* Should be children to SaAmfComp */
> - if (strncmp(parent, "safComp=", 8) != 0) {
> - report_ccb_validation_error(opdata, "Wrong parent '%s'",
> parent);
> + if (dn.compare(parent + 1, 8, "safComp=") != 0) {
> + report_ccb_validation_error(opdata, "Wrong parent '%s'",
> dn.c_str());
> goto free_cstype_name;
> }
>
> @@ -154,88 +142,100 @@
> ** to create the SaAmfCompCsType instance later.
> */
>
> - avsv_sanamet_init(dn, &comp_name, "safComp=");
> - comp = comp_db->find(Amf::to_string(&comp_name));
> + avsv_sanamet_init(dn, comp_name, "safComp=");
> + comp = comp_db->find(comp_name);
> +
> + TRACE("find %s", comp_name.c_str());
>
> if (comp != nullptr)
> - comptype_name = &comp->saAmfCompType;
> + comptype_name = comp->saAmfCompType;
> else {
> CcbUtilOperationData_t *tmp;
>
> if (opdata == nullptr) {
> - report_ccb_validation_error(opdata, "'%s' does not
> exist in model", comp_name.value);
> + report_ccb_validation_error(opdata, "'%s' does not
> exist in model", comp_name.c_str());
> goto free_cstype_name;
> }
>
> - if ((tmp = ccbutil_getCcbOpDataByDN(opdata->ccbId, &comp_name))
> == nullptr) {
> - LOG_ER("'%s'does not exist in existing model or in
> CCB", comp_name.value);
> + const SaNameTWrapper name(comp_name);
> + if ((tmp = ccbutil_getCcbOpDataByDN(opdata->ccbId, name)) ==
> nullptr) {
> + LOG_ER("'%s'does not exist in existing model or in
> CCB", comp_name.c_str());
> osafassert(0);
> goto free_cstype_name;
> }
>
> - comptype_name =
> immutil_getNameAttr(tmp->param.create.attrValues, "saAmfCompType", 0);
> + const SaNameT* comptype =
> immutil_getNameAttr(tmp->param.create.attrValues, "saAmfCompType", 0);
> + comptype_name = Amf::to_string(comptype);
> }
> - osafassert(comptype_name);
> + osafassert(comptype_name.empty() == false);
> +
> + comma = dn.find(',');
> + osafassert(comma != std::string::npos);
> + comma = dn.find(',', comma + 1);
> + osafassert(comma != std::string::npos);
> +
> + cstype_name = dn.substr(0, comma);
>
> - p = strchr(cstype_name, ',') + 1;
> - p = strchr(p, ',');
> - *p = '\0';
> + ctcstype_name = cstype_name + "," + comptype_name;
>
> - ctcstype_name.length = sprintf((char*)ctcstype_name.value, "%s,%s",
> cstype_name, comptype_name->value);
> -
> - if (ctcstype_db->find(Amf::to_string(&ctcstype_name)) == nullptr) {
> + // ctcstype_name looks like:
> + //
> safSupportedCsType=safVersion=4.0.0\,safCSType=AMFWDOG-OpenSAF,safVersion=4.0.0,safCompType=OpenSafCompTypeAMFWDOG
> + if (ctcstype_db->find(ctcstype_name) == nullptr) {
> if (opdata == nullptr) {
> - report_ccb_validation_error(opdata, "'%s' does not
> exist in model", ctcstype_name.value);
> + report_ccb_validation_error(opdata, "'%s' does not
> exist in model", ctcstype_name.c_str());
> goto free_cstype_name;
> }
>
> - if (ccbutil_getCcbOpDataByDN(opdata->ccbId, &ctcstype_name) ==
> nullptr) {
> + const SaNameTWrapper ctcstype(ctcstype_name);
> + if (ccbutil_getCcbOpDataByDN(opdata->ccbId, ctcstype) ==
> nullptr) {
> report_ccb_validation_error(opdata, "'%s' does not
> exist in existing model or in CCB",
> - ctcstype_name.value);
> + ctcstype_name.c_str());
> goto free_cstype_name;
> }
> }
>
> - delete [] cstype_name;
> + TRACE_LEAVE();
> return 1;
>
> free_cstype_name:
> - delete [] cstype_name;
> + TRACE_LEAVE();
> return 0;
> }
>
> -static AVD_COMPCS_TYPE *compcstype_create(const SaNameT *dn, const
> SaImmAttrValuesT_2 **attributes)
> +static AVD_COMPCS_TYPE *compcstype_create(const std::string& dn, const
> SaImmAttrValuesT_2 **attributes)
> {
> int rc = -1;
> AVD_COMPCS_TYPE *compcstype;
> AVD_CTCS_TYPE *ctcstype;
> - SaNameT ctcstype_name = {0};
> - char *cstype_name = StrDup((char*)dn->value);
> - char *p;
> - SaNameT comp_name;
> + std::string ctcstype_name;
> + std::string cstype_name(dn);
> + std::string::size_type pos;
> + std::string comp_name;
> AVD_COMP *comp;
> SaUint32T num_max_act_csi, num_max_std_csi;
>
> - TRACE_ENTER2("'%s'", dn->value);
> + TRACE_ENTER2("'%s'", dn.c_str());
>
> /*
> ** If called at new active at failover, the object is found in the DB
> ** but needs to get configuration attributes initialized.
> */
> - if ((nullptr == (compcstype = compcstype_db->find(Amf::to_string(dn))))
> &&
> + if ((nullptr == (compcstype = compcstype_db->find(dn))) &&
> ((compcstype = avd_compcstype_new(dn)) == nullptr))
> goto done;
>
> - avsv_sanamet_init(dn, &comp_name, "safComp=");
> - comp = comp_db->find(Amf::to_string(&comp_name));
> + avsv_sanamet_init(dn, comp_name, "safComp=");
> + comp = comp_db->find(comp_name);
>
> - p = strchr(cstype_name, ',') + 1;
> - p = strchr(p, ',');
> - *p = '\0';
> - ctcstype_name.length = sprintf((char*)ctcstype_name.value,
> - "%s,%s", cstype_name, comp->comp_type->name.value);
> + pos = cstype_name.find(',');
> + osafassert(pos != std::string::npos);
> + pos = dn.find(',', pos + 1);
> + osafassert(pos != std::string::npos);
> + cstype_name = cstype_name.substr(0, pos);
>
> - ctcstype = ctcstype_db->find(Amf::to_string(&ctcstype_name));
> + ctcstype_name = cstype_name + "," + comp->comp_type->name;
> +
> + ctcstype = ctcstype_db->find(ctcstype_name);
>
> if
> (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCompNumMaxActiveCSIs"),
> attributes, 0,
> &num_max_act_csi) != SA_AIS_OK) {
> @@ -261,8 +261,7 @@
>
> done:
> if (rc != 0)
> - compcstype_db->erase(Amf::to_string(&compcstype->name));
> - delete [] cstype_name;
> + compcstype_db->erase(compcstype->name);
>
> TRACE_LEAVE();
> return compcstype;
> @@ -277,7 +276,7 @@
> *
> * @return int
> */
> -SaAisErrorT avd_compcstype_config_get(SaNameT *comp_name, AVD_COMP *comp)
> +SaAisErrorT avd_compcstype_config_get(const std::string& name, AVD_COMP
> *comp)
> {
> SaAisErrorT error;
> SaImmSearchHandleT searchHandle;
> @@ -288,14 +287,13 @@
> AVD_COMPCS_TYPE *compcstype;
> SaImmAttrNameT attributeNames[] =
> {const_cast<SaImmAttrNameT>("saAmfCompNumMaxActiveCSIs"),
>
> const_cast<SaImmAttrNameT>("saAmfCompNumMaxStandbyCSIs"), nullptr};
> -
> TRACE_ENTER();
>
> searchParam.searchOneAttr.attrName =
> const_cast<SaImmAttrNameT>("SaImmAttrClassName");
> searchParam.searchOneAttr.attrValueType = SA_IMM_ATTR_SASTRINGT;
> searchParam.searchOneAttr.attrValue = &className;
>
> - error = immutil_saImmOmSearchInitialize_2(avd_cb->immOmHandle,
> comp_name, SA_IMM_SUBTREE,
> + error = immutil_saImmOmSearchInitialize_o2(avd_cb->immOmHandle,
> name.c_str(), SA_IMM_SUBTREE,
> SA_IMM_SEARCH_ONE_ATTR | SA_IMM_SEARCH_GET_SOME_ATTR,
> &searchParam,
> attributeNames, &searchHandle);
>
> @@ -307,12 +305,12 @@
> while ((error = immutil_saImmOmSearchNext_2(searchHandle, &dn,
> (SaImmAttrValuesT_2 ***)&attributes)) == SA_AIS_OK) {
>
> - if (!is_config_valid(&dn, nullptr)) {
> + if (!is_config_valid(Amf::to_string(&dn), nullptr)) {
> error = SA_AIS_ERR_FAILED_OPERATION;
> goto done2;
> }
>
> - if ((compcstype = compcstype_create(&dn, attributes)) ==
> nullptr) {
> + if ((compcstype = compcstype_create(Amf::to_string(&dn),
> attributes)) == nullptr) {
> error = SA_AIS_ERR_FAILED_OPERATION;
> goto done2;
> }
> @@ -332,12 +330,13 @@
> {
> SaAisErrorT rc = SA_AIS_ERR_BAD_OPERATION;
> AVD_COMPCS_TYPE *cst;
> + std::string comp_name;
>
> TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId,
> opdata->objectName.value);
>
> switch (opdata->operationType) {
> case CCBUTIL_CREATE: {
> - if (is_config_valid(&opdata->objectName, opdata))
> + if (is_config_valid(Amf::to_string(&opdata->objectName),
> opdata))
> rc = SA_AIS_OK;
> break;
> }
> @@ -346,14 +345,13 @@
> break;
> case CCBUTIL_DELETE:
> AVD_COMP *comp;
> - SaNameT comp_name;
> AVD_SU_SI_REL *curr_susi;
> AVD_COMP_CSI_REL *compcsi;
>
> cst = compcstype_db->find(Amf::to_string(&opdata->objectName));
> osafassert(cst);
> - avsv_sanamet_init(&opdata->objectName, &comp_name, "safComp=");
> - comp = comp_db->find(Amf::to_string(&comp_name));
> + avsv_sanamet_init(Amf::to_string(&opdata->objectName),
> comp_name, "safComp=");
> + comp = comp_db->find(comp_name);
> for (curr_susi = comp->su->list_of_susi; curr_susi != nullptr;
> curr_susi = curr_susi->su_next)
> for (compcsi = curr_susi->list_of_csicomp; compcsi;
> compcsi = compcsi->susi_csicomp_next) {
> if (compcsi->comp == comp) {
> @@ -380,14 +378,14 @@
>
> switch (opdata->operationType) {
> case CCBUTIL_CREATE:
> - cst = compcstype_create(&opdata->objectName,
> opdata->param.create.attrValues);
> + cst = compcstype_create(Amf::to_string(&opdata->objectName),
> opdata->param.create.attrValues);
> osafassert(cst);
> compcstype_add_to_model(cst);
> break;
> case CCBUTIL_DELETE:
> cst = compcstype_db->find(Amf::to_string(&opdata->objectName));
> if (cst != nullptr) {
> - compcstype_db->erase(Amf::to_string(&cst->name));
> + compcstype_db->erase(cst->name);
> delete cst;
> }
> break;
> @@ -410,10 +408,10 @@
>
> while ((attributeName = attributeNames[i++]) != nullptr) {
> if (!strcmp("saAmfCompNumCurrActiveCSIs", attributeName)) {
> - rc = avd_saImmOiRtObjectUpdate_sync(objectName,
> attributeName,
> + rc =
> avd_saImmOiRtObjectUpdate_sync(Amf::to_string(objectName), attributeName,
> SA_IMM_ATTR_SAUINT32T,
> &cst->saAmfCompNumCurrActiveCSIs);
> } else if (!strcmp("saAmfCompNumCurrStandbyCSIs",
> attributeName)) {
> - avd_saImmOiRtObjectUpdate(objectName, attributeName,
> + avd_saImmOiRtObjectUpdate(Amf::to_string(objectName),
> attributeName,
> SA_IMM_ATTR_SAUINT32T,
> &cst->saAmfCompNumCurrStandbyCSIs);
> } else if (!strcmp("saAmfCompAssignedCsi", attributeName)) {
> /* TODO */
> 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
> @@ -34,14 +34,14 @@
>
> static void comptype_db_add(AVD_COMP_TYPE *compt)
> {
> - unsigned int rc =
> comptype_db->insert(Amf::to_string(&compt->name),compt);
> + unsigned int rc = comptype_db->insert(compt->name,compt);
> osafassert (rc == NCSCC_RC_SUCCESS);
> }
>
> static void comptype_delete(AVD_COMP_TYPE *avd_comp_type)
> {
> osafassert(nullptr == avd_comp_type->list_of_comp);
> - comptype_db->erase(Amf::to_string(&avd_comp_type->name));
> + comptype_db->erase(avd_comp_type->name);
> delete avd_comp_type;
> }
>
> @@ -78,26 +78,27 @@
> }
>
> //
> -AVD_COMP_TYPE::AVD_COMP_TYPE(const SaNameT *dn) {
> - memcpy(&name.value, dn->value, dn->length);
> - name.length = dn->length;
> +AVD_COMP_TYPE::AVD_COMP_TYPE(const std::string& dn) :
> + name(dn)
> +{
> }
>
> -static AVD_COMP_TYPE *comptype_create(const SaNameT *dn, const
> SaImmAttrValuesT_2 **attributes)
> +static AVD_COMP_TYPE *comptype_create(const std::string& dn, const
> SaImmAttrValuesT_2 **attributes)
> {
> AVD_COMP_TYPE *compt;
> const char *str;
> SaAisErrorT error;
> + SaNameT ct_sw_bundle;
>
> - TRACE_ENTER2("'%s'", dn->value);
> + TRACE_ENTER2("'%s'", dn.c_str());
>
> compt = new AVD_COMP_TYPE(dn);
>
> error =
> immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCtCompCategory"),
> attributes, 0, &compt->saAmfCtCompCategory);
> osafassert(error == SA_AIS_OK);
>
> - (void)immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCtSwBundle"),
> attributes, 0, &compt->saAmfCtSwBundle);
> -
> + (void)immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCtSwBundle"),
> attributes, 0, &ct_sw_bundle);
> + compt->saAmfCtSwBundle = Amf::to_string(&ct_sw_bundle);
> if ((str = immutil_getStringAttr(attributes, "saAmfCtDefCmdEnv", 0)) !=
> nullptr)
> strcpy(compt->saAmfCtDefCmdEnv, str);
>
> (void)immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCtDefClcCliTimeout"),
> attributes, 0, &compt->saAmfCtDefClcCliTimeout);
> @@ -139,7 +140,7 @@
> if (compt->saAmfCtDefRecoveryOnError == SA_AMF_NO_RECOMMENDATION) {
> compt->saAmfCtDefRecoveryOnError = SA_AMF_COMPONENT_FAILOVER;
> LOG_NO("COMPONENT_FAILOVER(%u) used instead of
> NO_RECOMMENDATION(%u) for '%s'",
> - SA_AMF_COMPONENT_FAILOVER, SA_AMF_NO_RECOMMENDATION,
> dn->value);
> + SA_AMF_COMPONENT_FAILOVER, SA_AMF_NO_RECOMMENDATION,
> dn.c_str());
> }
>
>
> (void)immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCtDefDisableRestart"),
> attributes, 0, &compt->saAmfCtDefDisableRestart);
> @@ -390,13 +391,13 @@
> if (config_is_valid(&dn, attributes, nullptr) == false)
> goto done2;
> if ((comp_type = comptype_db->find(Amf::to_string(&dn))) ==
> nullptr) {
> - if ((comp_type = comptype_create(&dn, attributes)) ==
> nullptr)
> + if ((comp_type = comptype_create(Amf::to_string(&dn),
> attributes)) == nullptr)
> goto done2;
>
> comptype_db_add(comp_type);
> }
>
> - if (avd_ctcstype_config_get(&dn, comp_type) != SA_AIS_OK)
> + if (avd_ctcstype_config_get(Amf::to_string(&dn), comp_type) !=
> SA_AIS_OK)
> goto done2;
> }
>
> @@ -434,7 +435,7 @@
> AVD_COMP *comp = comp_type->list_of_comp;
> while (comp != nullptr) {
> node_set.insert(comp->su->su_on_node);
> - TRACE("comp name %s on node %s", comp->comp_info.name.value,
> comp->su->su_on_node->name.value);
> + TRACE("comp name %s on node %s", comp->comp_info.name.value,
> comp->su->su_on_node->name.c_str());
> comp = comp->comp_type_list_comp_next;
> }
>
> @@ -452,7 +453,7 @@
> if (!strcmp(attribute->attrName,
> "saAmfCtDefCallbackTimeout")) {
> SaTimeT *param_val = (SaTimeT
> *)attribute->attrValues[0];
> TRACE("saAmfCtDefCallbackTimeout to '%llu' for
> compType '%s' on node '%s'", *param_val,
> - opdata->objectName.value,
> (*it)->name.value);
> + opdata->objectName.value,
> (*it)->name.c_str());
> param.value_len = sizeof(*param_val);
> memcpy(param.value, param_val, param.value_len);
> param.attr_id = saAmfCtDefCallbackTimeout_ID;
> @@ -460,7 +461,7 @@
> } else if (!strcmp(attribute->attrName,
> "saAmfCtDefClcCliTimeout")) {
> SaTimeT *param_val = (SaTimeT
> *)attribute->attrValues[0];
> TRACE("saAmfCtDefClcCliTimeout to '%llu' for
> compType '%s' on node '%s'", *param_val,
> - opdata->objectName.value,
> (*it)->name.value);
> + opdata->objectName.value,
> (*it)->name.c_str());
> param.value_len = sizeof(*param_val);
> memcpy(param.value, param_val, param.value_len);
> param.attr_id = saAmfCtDefClcCliTimeout_ID;
> @@ -468,7 +469,7 @@
> } else if (!strcmp(attribute->attrName,
> "saAmfCtDefQuiescingCompleteTimeout")) {
> SaTimeT *param_val = (SaTimeT
> *)attribute->attrValues[0];
> TRACE("saAmfCtDefQuiescingCompleteTimeout to
> '%llu' for compType '%s' on node '%s'", *param_val,
> - opdata->objectName.value,
> (*it)->name.value);
> + opdata->objectName.value,
> (*it)->name.c_str());
> param.value_len = sizeof(*param_val);
> memcpy(param.value, param_val, param.value_len);
> param.attr_id =
> saAmfCtDefQuiescingCompleteTimeout_ID;
> @@ -483,7 +484,7 @@
> param_val = *(SaUint32T
> *)attribute->attrValues[0];
> }
> TRACE("saAmfCtDefInstantiationLevel to '%u' for
> compType '%s' on node '%s'", param_val,
> - opdata->objectName.value,
> (*it)->name.value);
> + opdata->objectName.value,
> (*it)->name.c_str());
> param.value_len = sizeof(param_val);
> memcpy(param.value, ¶m_val,
> param.value_len);
> param.attr_id = saAmfCtDefInstantiationLevel_ID;
> @@ -493,7 +494,7 @@
> } else if (!strcmp(attribute->attrName,
> "saAmfCtDefRecoveryOnError")) {
> SaAmfRecommendedRecoveryT *param_val =
> (SaAmfRecommendedRecoveryT *)attribute->attrValues[0];
> TRACE("saAmfCtDefRecoveryOnError to '%u' for
> compType '%s' on node '%s'", *param_val,
> - opdata->objectName.value,
> (*it)->name.value);
> + opdata->objectName.value,
> (*it)->name.c_str());
> param.value_len = sizeof(*param_val);
> memcpy(param.value, param_val, param.value_len);
> param.attr_id = saAmfCtDefRecoveryOnError_ID;
> @@ -508,7 +509,7 @@
> param_val = *(SaBoolT
> *)attribute->attrValues[0];
> }
> TRACE("saAmfCtDefDisableRestart to '%u' for
> compType '%s' on node '%s'", param_val,
> - opdata->objectName.value,
> (*it)->name.value);
> + opdata->objectName.value,
> (*it)->name.c_str());
> param.value_len = sizeof(param_val);
> memcpy(param.value, ¶m_val,
> param.value_len);
> param.attr_id = saAmfCtDefDisableRestart_ID;
> @@ -529,7 +530,7 @@
>
> switch (opdata->operationType) {
> case CCBUTIL_CREATE:
> - comp_type = comptype_create(&opdata->objectName,
> + comp_type = comptype_create(Amf::to_string(&opdata->objectName),
> opdata->param.create.attrValues);
> osafassert(comp_type);
> comptype_db_add(comp_type);
> @@ -710,7 +711,7 @@
> comp = comp->comp_type_list_comp_next;
> }
> if (comp_exist == true) {
> - report_ccb_validation_error(opdata,
> "SaAmfCompType '%s' is in use",comp_type->name.value);
> + report_ccb_validation_error(opdata,
> "SaAmfCompType '%s' is in use",comp_type->name.c_str());
> goto done;
> }
> }
> 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
> @@ -27,7 +27,7 @@
> AmfDb<std::string, AVD_CSI> *csi_db = nullptr;
>
> //
> -AVD_COMP* AVD_CSI::find_assigned_comp(const SaNameT *cstype,
> +AVD_COMP* AVD_CSI::find_assigned_comp(const std::string& cstype,
> const AVD_SU_SI_REL *sisu,
> const std::vector<AVD_COMP*>
> &list_of_comp) {
> auto iter = list_of_comp.begin();
> @@ -61,7 +61,7 @@
> void avd_csi_delete(AVD_CSI *csi)
> {
> AVD_CSI_ATTR *temp;
> - TRACE_ENTER2("%s", csi->name.value);
> + TRACE_ENTER2("%s", csi->name.c_str());
>
> /* Delete CSI attributes */
> temp = csi->list_attributes;
> @@ -73,8 +73,8 @@
> avd_cstype_remove_csi(csi);
> csi->si->remove_csi(csi);
>
> - csi_db->erase(Amf::to_string(&csi->name));
> -
> + csi_db->erase(csi->name);
> +
> if (csi->saAmfCSIDependencies != nullptr) {
> AVD_CSI_DEPS *csi_dep;
> AVD_CSI_DEPS *next_csi_dep;
> @@ -94,12 +94,12 @@
> void csi_cmplt_delete(AVD_CSI *csi, bool ckpt)
> {
> AVD_PG_CSI_NODE *curr;
> - TRACE_ENTER2("%s", csi->name.value);
> + TRACE_ENTER2("%s", csi->name.c_str());
> if (!ckpt) {
> /* inform the avnds that track this csi */
> for (curr = (AVD_PG_CSI_NODE
> *)m_NCS_DBLIST_FIND_FIRST(&csi->pg_node_list);
> curr != nullptr; curr = (AVD_PG_CSI_NODE
> *)m_NCS_DBLIST_FIND_NEXT(&curr->csi_dll_node)) {
> - avd_snd_pg_upd_msg(avd_cb, curr->node, 0,
> static_cast<SaAmfProtectionGroupChangesT>(0), &csi->name);
> + avd_snd_pg_upd_msg(avd_cb, curr->node, 0,
> static_cast<SaAmfProtectionGroupChangesT>(0), csi->name);
> }
> }
>
> @@ -117,20 +117,25 @@
> *
> * @return int
> */
> -static int is_config_valid(const SaNameT *dn, const SaImmAttrValuesT_2
> **attributes, CcbUtilOperationData_t *opdata)
> +static int is_config_valid(const std::string& dn, const SaImmAttrValuesT_2
> **attributes, CcbUtilOperationData_t *opdata)
> {
> SaAisErrorT rc;
> SaNameT aname;
> - const char *parent;
> + std::string parent;
> unsigned int values_number;
>
> - if ((parent = avd_getparent((const char*)dn->value)) == nullptr) {
> - report_ccb_validation_error(opdata, "No parent to '%s' ",
> dn->value);
> + TRACE_ENTER2("%s", dn.c_str());
> +
> + parent = avd_getparent(dn);
> + if (parent.empty() == true ) {
> + report_ccb_validation_error(opdata, "No parent to '%s' ",
> dn.c_str());
> + TRACE_LEAVE();
> return 0;
> }
>
> - if (strncmp(parent, "safSi=", 6) != 0) {
> - LOG_ER("Wrong parent '%s' to '%s' ", parent, dn->value);
> + if (parent.compare(0, 6, "safSi=") != 0) {
> + LOG_ER("Wrong parent '%s' to '%s' ", parent.c_str(),
> dn.c_str());
> + TRACE_LEAVE();
> return 0;
> }
>
> @@ -141,11 +146,13 @@
> /* CS type does not exist in current model, check CCB if passed
> as param */
> if (opdata == nullptr) {
> report_ccb_validation_error(opdata, "'%s' does not
> exist in model", aname.value);
> + TRACE_LEAVE();
> return 0;
> }
>
> if (ccbutil_getCcbOpDataByDN(opdata->ccbId, &aname) == nullptr)
> {
> report_ccb_validation_error(opdata, "'%s' does not
> exist in existing model or in CCB", aname.value);
> + TRACE_LEAVE();
> return 0;
> }
> }
> @@ -155,46 +162,54 @@
> (values_number > 0)) {
>
> unsigned int i;
> - SaNameT saAmfCSIDependency;
> - const char *dep_parent;
> + std::string csi_dependency;
> + std::string dep_parent;
>
> for (i = 0; i < values_number; i++) {
> - rc =
> immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCSIDependencies"),
> attributes, i, &saAmfCSIDependency);
> + SaNameT tmp_dependency;
> + rc =
> immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCSIDependencies"),
> attributes, i, &tmp_dependency);
> osafassert(rc == SA_AIS_OK);
> + csi_dependency = Amf::to_string(&tmp_dependency);
>
> - if (strncmp((char*)dn->value,
> (char*)saAmfCSIDependency.value, sizeof(dn->value)) == 0) {
> + if (dn.compare(csi_dependency) == 0) {
> report_ccb_validation_error(opdata, "'%s'
> validation failed - dependency configured to"
> - " itself!", dn->value);
> + " itself!", dn.c_str());
> + TRACE_LEAVE();
> return 0;
> }
>
> - if (csi_db->find(Amf::to_string(&saAmfCSIDependency))
> == nullptr) {
> + if (csi_db->find(csi_dependency) == nullptr) {
> /* CSI does not exist in current model, check
> CCB if passed as param */
> if (opdata == nullptr) {
> /* initial loading, check IMM */
> - if
> (!object_exist_in_imm(&saAmfCSIDependency)) {
> + if (object_exist_in_imm(csi_dependency)
> == false) {
>
> report_ccb_validation_error(opdata, "'%s' validation failed - '%s' does not"
> " exist",
> - dn->value,
> saAmfCSIDependency.value);
> + dn.c_str(),
> csi_dependency.c_str());
> + TRACE_LEAVE();
> return 0;
> }
> - } else if
> (ccbutil_getCcbOpDataByDN(opdata->ccbId, &saAmfCSIDependency) == nullptr) {
> + } else if
> (ccbutil_getCcbOpDataByDN(opdata->ccbId, &tmp_dependency) == nullptr) {
> report_ccb_validation_error(opdata,
> "'%s' validation failed - '%s' does not exist"
> " in existing model or
> in CCB",
> - dn->value,
> saAmfCSIDependency.value);
> + dn.c_str(),
> csi_dependency.c_str());
> + TRACE_LEAVE();
> return 0;
> }
> }
>
> - if ((dep_parent = avd_getparent((const
> char*)saAmfCSIDependency.value)) == nullptr) {
> + dep_parent = avd_getparent(csi_dependency);
> + if (dep_parent.empty() == true) {
> report_ccb_validation_error(opdata, "'%s'
> validation failed - invalid "
> - "saAmfCSIDependency '%s'",
> dn->value, saAmfCSIDependency.value);
> + "saAmfCSIDependency '%s'",
> dn.c_str(), csi_dependency.c_str());
> + TRACE_LEAVE();
> return 0;
> }
>
> - if (strncmp(parent, dep_parent, sizeof(dn->value)) !=
> 0) {
> + if (parent.compare(dep_parent) != 0) {
> report_ccb_validation_error(opdata, "'%s'
> validation failed - dependency to CSI in other"
> - " SI is not allowed",
> dn->value);
> + " SI is not allowed",
> dn.c_str());
> + TRACE_LEAVE();
> return 0;
> }
> }
> @@ -203,27 +218,31 @@
> /* Verify that the SI can contain this CSI */
> {
> AVD_SI *avd_si;
> - SaNameT si_name;
> + std::string si_name;
>
> - avsv_sanamet_init(dn, &si_name, "safSi");
> + avsv_sanamet_init(dn, si_name, "safSi");
>
> - if (nullptr != (avd_si = avd_si_get(&si_name))) {
> + if (nullptr != (avd_si = avd_si_get(si_name))) {
> /* Check for any admin operations undergoing. This is
> valid during dyn add*/
> if((opdata != nullptr) && (AVD_SG_FSM_STABLE !=
> avd_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)",
> - avd_si->sg_of_si->name.value,
> avd_si->sg_of_si->sg_fsm_state);
> + avd_si->sg_of_si->name.c_str(),
> avd_si->sg_of_si->sg_fsm_state);
> + TRACE_LEAVE();
> return 0;
> }
> } else {
> if (opdata == nullptr) {
> - report_ccb_validation_error(opdata, "'%s' does
> not exist in model", si_name.value);
> + report_ccb_validation_error(opdata, "'%s' does
> not exist in model", si_name.c_str());
> + TRACE_LEAVE();
> return 0;
> }
>
> - if (ccbutil_getCcbOpDataByDN(opdata->ccbId, &si_name)
> == nullptr) {
> + const SaNameTWrapper si(si_name);
> + if (ccbutil_getCcbOpDataByDN(opdata->ccbId, si) ==
> nullptr) {
> report_ccb_validation_error(opdata, "'%s' does
> not exist in existing model or in CCB",
> - si_name.value);
> + si_name.c_str());
> + TRACE_LEAVE();
> return 0;
> }
> }
> @@ -241,6 +260,7 @@
> }
> #endif
> }
> + TRACE_LEAVE();
> return 1;
> }
> /**
> @@ -262,8 +282,7 @@
> */
> for (temp_csi_dep = csi->saAmfCSIDependencies; temp_csi_dep != nullptr;
> temp_csi_dep = temp_csi_dep->csi_dep_next) {
> - if (0 == memcmp(&new_csi_dep->csi_dep_name_value,
> - &temp_csi_dep->csi_dep_name_value,
> sizeof(SaNameT))) {
> + if
> (new_csi_dep->csi_dep_name_value.compare(temp_csi_dep->csi_dep_name_value) ==
> 0) {
> csi_added = true;
> }
> }
> @@ -279,13 +298,13 @@
> /**
> * Removes a CSI dep from the saAmfCSIDependencies list and free the memory
> */
> -static void csi_remove_csidep(AVD_CSI *csi, const SaNameT *required_dn)
> +static void csi_remove_csidep(AVD_CSI *csi, const std::string& required_dn)
> {
> AVD_CSI_DEPS *prev = nullptr;
> AVD_CSI_DEPS *curr;
>
> for (curr = csi->saAmfCSIDependencies; curr != nullptr; curr =
> curr->csi_dep_next) {
> - if (memcmp(required_dn, &curr->csi_dep_name_value,
> sizeof(SaNameT)) == 0) {
> + if (required_dn.compare(curr->csi_dep_name_value) == 0) {
> break;
> }
> prev = curr;
> @@ -303,9 +322,8 @@
> }
>
> //
> -AVD_CSI::AVD_CSI(const SaNameT* csi_name) {
> - memcpy(&name.value, csi_name->value, csi_name->length);
> - name.length = csi_name->length;
> +AVD_CSI::AVD_CSI(const std::string& csi_name) :
> + name(csi_name) {
> }
> /**
> * @brief creates new csi and adds csi node to the csi_db
> @@ -314,15 +332,15 @@
> *
> * @return pointer to AVD_CSI
> */
> -AVD_CSI *csi_create(const SaNameT *csi_name)
> +AVD_CSI *csi_create(const std::string& csi_name)
> {
> AVD_CSI *csi;
>
> - TRACE_ENTER2("'%s'", csi_name->value);
> + TRACE_ENTER2("'%s'", csi_name.c_str());
>
> csi = new AVD_CSI(csi_name);
>
> - if (csi_db->insert(Amf::to_string(&csi->name), csi) != NCSCC_RC_SUCCESS)
> + if (csi_db->insert(csi->name, csi) != NCSCC_RC_SUCCESS)
> osafassert(0);
>
> TRACE_LEAVE();
> @@ -335,21 +353,24 @@
> *
> * @return pointer to AVD_CSI
> */
> -static void csi_get_attr_and_add_to_model(AVD_CSI *csi, const
> SaImmAttrValuesT_2 **attributes, const SaNameT *si_name)
> +static void csi_get_attr_and_add_to_model(AVD_CSI *csi, const
> SaImmAttrValuesT_2 **attributes, const std::string& si_name)
> {
> int rc = -1;
> unsigned int values_number = 0;
> SaAisErrorT error;
> + SaNameT cs_type;
>
> - TRACE_ENTER2("'%s'", csi->name.value);
> + TRACE_ENTER2("'%s'", csi->name.c_str());
>
> /* initialize the pg node-list */
> csi->pg_node_list.order = NCS_DBLIST_ANY_ORDER;
> csi->pg_node_list.cmp_cookie = avsv_dblist_uns32_cmp;
> csi->pg_node_list.free_cookie = 0;
>
> - error = immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCSType"),
> attributes, 0, &csi->saAmfCSType);
> + error = immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCSType"),
> attributes, 0, &cs_type);
> osafassert(error == SA_AIS_OK);
> + csi->saAmfCSType = Amf::to_string(&cs_type);
> +
>
> if
> ((immutil_getAttrValuesNumber(const_cast<SaImmAttrNameT>("saAmfCSIDependencies"),
> attributes, &values_number) == SA_AIS_OK)) {
> if (values_number == 0) {
> @@ -360,17 +381,22 @@
> unsigned int i;
> bool found;
> AVD_CSI_DEPS *new_csi_dep = nullptr;
> +
> + TRACE("checking dependencies");
>
> for (i = 0; i < values_number; i++) {
> + TRACE("i %u", i);
> new_csi_dep = new AVD_CSI_DEPS();
> + SaNameT temp_name;
> 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);
> + &temp_name) != SA_AIS_OK) {
> + LOG_ER("Get saAmfCSIDependencies FAILED
> for '%s'", csi->name.c_str());
> // make sure we don't leak any memory if
> // saAmfCSIDependencies can't be read
> delete new_csi_dep;
> goto done;
> }
> + new_csi_dep->csi_dep_name_value =
> Amf::to_string(&temp_name);
> found = csi_add_csidep(csi,new_csi_dep);
> if (found == true)
> delete new_csi_dep;
> @@ -378,10 +404,11 @@
> }
> } else {
> csi->rank = 1;
> - TRACE_ENTER2("DEP not configured, marking rank 1. Csi'%s',
> Rank'%u'",csi->name.value,csi->rank);
> + TRACE_ENTER2("DEP not configured, marking rank 1. Csi'%s',
> Rank'%u'",csi->name.c_str(),csi->rank);
> }
>
> - csi->cstype = cstype_db->find(Amf::to_string(&csi->saAmfCSType));
> + TRACE("find %s", csi->saAmfCSType.c_str());
> + csi->cstype = cstype_db->find(csi->saAmfCSType);
> csi->si = avd_si_get(si_name);
>
> avd_cstype_add_csi(csi);
> @@ -406,12 +433,12 @@
> *
> * @return int
> */
> -SaAisErrorT avd_csi_config_get(const SaNameT *si_name, AVD_SI *si)
> +SaAisErrorT avd_csi_config_get(const std::string& si_name, AVD_SI *si)
> {
> SaAisErrorT error = SA_AIS_ERR_FAILED_OPERATION;
> SaImmSearchHandleT searchHandle;
> SaImmSearchParametersT_2 searchParam;
> - SaNameT csi_name;
> + char* temp_csi_name;
> const SaImmAttrValuesT_2 **attributes;
> const char *className = "SaAmfCSI";
> AVD_CSI *csi;
> @@ -420,7 +447,7 @@
> searchParam.searchOneAttr.attrValueType = SA_IMM_ATTR_SASTRINGT;
> searchParam.searchOneAttr.attrValue = &className;
>
> - if (immutil_saImmOmSearchInitialize_2(avd_cb->immOmHandle, si_name,
> SA_IMM_SUBTREE,
> + if (immutil_saImmOmSearchInitialize_o2(avd_cb->immOmHandle,
> si_name.c_str(), SA_IMM_SUBTREE,
> SA_IMM_SEARCH_ONE_ATTR | SA_IMM_SEARCH_GET_ALL_ATTR,
> &searchParam,
> nullptr, &searchHandle) != SA_AIS_OK) {
>
> @@ -428,18 +455,19 @@
> goto done1;
> }
>
> - while (immutil_saImmOmSearchNext_2(searchHandle, &csi_name,
> (SaImmAttrValuesT_2 ***)&attributes) == SA_AIS_OK) {
> - if (!is_config_valid(&csi_name, attributes, nullptr))
> + while (immutil_saImmOmSearchNext_o2(searchHandle, &temp_csi_name,
> (SaImmAttrValuesT_2 ***)&attributes) == SA_AIS_OK) {
> + const std::string csi_name(temp_csi_name);
> + if (!is_config_valid(csi_name, attributes, nullptr))
> goto done2;
>
> - if ((csi = csi_db->find(Amf::to_string(&csi_name))) == nullptr)
> + if ((csi = csi_db->find(csi_name)) == nullptr)
> {
> - csi = csi_create(&csi_name);
> + csi = csi_create(csi_name);
>
> csi_get_attr_and_add_to_model(csi, attributes, si_name);
> }
>
> - if (avd_csiattr_config_get(&csi_name, csi) != SA_AIS_OK) {
> + if (avd_csiattr_config_get(csi_name, csi) != SA_AIS_OK) {
> error = SA_AIS_ERR_FAILED_OPERATION;
> goto done2;
> }
> @@ -471,7 +499,7 @@
> static SaAisErrorT csi_ccb_completed_create_hdlr(CcbUtilOperationData_t
> *opdata)
> {
> SaAisErrorT rc = SA_AIS_ERR_BAD_OPERATION;
> - SaNameT si_name;
> + std::string si_name;
> AVD_SI *avd_si;
> AVD_COMP *t_comp;
> AVD_SU_SI_REL *t_sisu;
> @@ -480,14 +508,14 @@
>
> TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId,
> opdata->objectName.value);
>
> - if (!is_config_valid(&opdata->objectName,
> opdata->param.create.attrValues, opdata))
> + if (!is_config_valid(Amf::to_string(&opdata->objectName),
> opdata->param.create.attrValues, opdata))
> goto done;
>
> rc = immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCSType"),
> opdata->param.create.attrValues, 0, &cstype_name);
> osafassert(rc == SA_AIS_OK);
>
> - avsv_sanamet_init(&opdata->objectName, &si_name, "safSi");
> - avd_si = avd_si_get(&si_name);
> + avsv_sanamet_init(Amf::to_string(&opdata->objectName), si_name,
> "safSi");
> + avd_si = avd_si_get(si_name);
>
> if (nullptr != avd_si) {
> /* Check whether si has been assigned to any SU. */
> @@ -497,7 +525,7 @@
> if (t_sisu->csi_add_rem == true) {
> LOG_NO("CSI create of '%s' in queue:
> pending assignment"
> " for '%s'",
> -
> opdata->objectName.value, t_sisu->su->name.value);
> +
> opdata->objectName.value, t_sisu->su->name.c_str());
> }
> t_sisu = t_sisu->si_next;
> }/* while(t_sisu) */
> @@ -515,13 +543,13 @@
> compcsi = compcsi->susi_csicomp_next;
> }
>
> - t_comp =
> su->find_unassigned_comp_that_provides_cstype(&cstype_name);
> + t_comp =
> su->find_unassigned_comp_that_provides_cstype(Amf::to_string(&cstype_name));
>
> /* Component not found.*/
> if (nullptr == t_comp) {
> /* This means that all the components
> are assigned, let us assigned it to assigned
> component.*/
> - t_comp =
> AVD_CSI::find_assigned_comp(&cstype_name, t_sisu, su->list_of_comp);
> + t_comp =
> AVD_CSI::find_assigned_comp(Amf::to_string(&cstype_name), t_sisu,
> su->list_of_comp);
> }
> if (nullptr == t_comp) {
> report_ccb_validation_error(opdata,
> "Compcsi doesn't exist or "
> @@ -587,22 +615,23 @@
> goto done;
>
> }
> - const SaNameT *required_dn = (SaNameT*)
> attr_mod->modAttr.attrValues[0];
> - const AVD_CSI *required_csi =
> csi_db->find(Amf::to_string(required_dn));
> + const SaNameT *tmp_required_dn = (SaNameT*)
> attr_mod->modAttr.attrValues[0];
> + const std::string
> required_dn(Amf::to_string(tmp_required_dn));
> + const AVD_CSI *required_csi = csi_db->find(required_dn);
>
> // Required CSI must exist in current model
> if (required_csi == nullptr) {
> report_ccb_validation_error(opdata,
> - "CSI '%s' does not exist",
> required_dn->value);
> + "CSI '%s' does not exist",
> required_dn.c_str());
> goto done;
> }
>
> // Required CSI must be contained in the same SI
> - const char *si_dn = strchr((char*)required_dn->value,
> ',') + 1;
> + const char *si_dn = strchr((char*)required_dn.c_str(),
> ',') + 1;
> if (strstr((char*)opdata->objectName.value, si_dn) ==
> nullptr) {
> report_ccb_validation_error(opdata,
> "'%s' is not in the same SI as
> '%s'",
> - opdata->objectName.value,
> required_dn->value);
> + opdata->objectName.value,
> required_dn.c_str());
> goto done;
> }
>
> @@ -616,32 +645,30 @@
>
> // check cyclic dependencies by scanning the
> deps of the required CSI
> for (csi_dep =
> required_csi->saAmfCSIDependencies; csi_dep; csi_dep = csi_dep->csi_dep_next)
> {
> - if
> (strcmp((char*)csi_dep->csi_dep_name_value.value,
> -
> (char*)opdata->objectName.value) == 0) {
> + if
> (csi_dep->csi_dep_name_value.compare((char*)opdata->objectName.value) == 0) {
> // the required CSI requires
> this CSI
>
> report_ccb_validation_error(opdata,
> "cyclic
> dependency between '%s' and '%s'",
> -
> opdata->objectName.value, required_dn->value);
> +
> opdata->objectName.value, required_dn.c_str());
> goto done;
> }
> }
>
> // don't allow adding the same dep again
> for (csi_dep = csi->saAmfCSIDependencies;
> csi_dep; csi_dep = csi_dep->csi_dep_next) {
> - if
> (strcmp((char*)csi_dep->csi_dep_name_value.value,
> -
> (char*)required_dn->value) == 0) {
> + if
> (csi_dep->csi_dep_name_value.compare((char*)required_dn.c_str()) == 0) {
> // dep already exist, should we
> return OK instead?
>
> report_ccb_validation_error(opdata,
> "dependency
> between '%s' and '%s' already exist",
> -
> opdata->objectName.value, required_dn->value);
> +
> opdata->objectName.value, required_dn.c_str());
> goto done;
> }
> }
>
> // disallow dep between same CSIs
> - if (strcmp((char*)csi->name.value,
> (char*)required_dn->value) == 0) {
[HansN] static_cast<char*> can be used
> + if
> (csi->name.compare((char*)required_dn.c_str()) == 0) {
> report_ccb_validation_error(opdata,
> - "dependency for '%s' to
> itself", csi->name.value);
> + "dependency for '%s' to
> itself", csi->name.c_str());
> goto done;
> }
> } else if (attr_mod->modType ==
> SA_IMM_ATTR_VALUES_DELETE) {
> @@ -700,7 +727,7 @@
>
> 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);
> + csi->si->sg_of_si->name.c_str(),
> csi->si->sg_of_si->sg_fsm_state);
> rc = SA_AIS_ERR_BAD_OPERATION;
> goto done;
> }
> @@ -712,7 +739,7 @@
> /* SI is unlocked and this is the last csi to be
> deleted, then donot allow it. */
> if (csi->si->list_of_csi->si_list_of_csi_next ==
> nullptr) {
> report_ccb_validation_error(opdata, " csi('%s')
> is the last csi in si('%s'). Lock SI and"
> - " then delete csi.",
> csi->name.value, csi->si->name.value);
> + " then delete csi.",
> csi->name.c_str(), csi->si->name.c_str());
> rc = SA_AIS_ERR_BAD_OPERATION;
> goto done;
> }
> @@ -721,7 +748,7 @@
> if (t_sisu->csi_add_rem == true) {
> LOG_NO("CSI remove of '%s' rejected:
> pending "
> "assignment for '%s'",
> - csi->name.value,
> t_sisu->su->name.value);
> + csi->name.c_str(),
> t_sisu->su->name.c_str());
> if (avd_cb->avail_state_avd ==
> SA_AMF_HA_ACTIVE) {
> rc = SA_AIS_ERR_BAD_OPERATION;
> goto done;
> @@ -732,7 +759,7 @@
> }
> } else {
> if (csi->list_compcsi != nullptr) {
> - report_ccb_validation_error(opdata, "SaAmfCSI '%s' is
> in use", csi->name.value);
> + report_ccb_validation_error(opdata, "SaAmfCSI '%s' is
> in use", csi->name.c_str());
> rc = SA_AIS_ERR_BAD_OPERATION;
> goto done;
> }
> @@ -799,7 +826,7 @@
> goto done;
> }
>
> - TRACE_ENTER2("'%s'", csi ? csi->name.value : nullptr);
> + TRACE_ENTER2("'%s'", csi ? csi->name.c_str() : nullptr);
>
> /* Check whether si has been assigned to any SU. */
> if ((nullptr != csi->si->list_of_sisu) &&
> @@ -825,13 +852,13 @@
> if ((SA_AMF_HA_ACTIVE == t_sisu->state) && (true ==
> first_sisu)) {
> first_sisu = false;
> if (avd_snd_susi_msg(avd_cb, t_sisu->su,
> t_sisu, AVSV_SUSI_ACT_DEL, true, t_csicomp) != NCSCC_RC_SUCCESS) {
> - LOG_ER("susi send failure for su'%s'
> and si'%s'", t_sisu->su->name.value, t_sisu->si->name.value);
> + LOG_ER("susi send failure for su'%s'
> and si'%s'", t_sisu->su->name.c_str(), t_sisu->si->name.c_str());
> goto done;
> }
>
> }
> t_sisu->csi_add_rem = static_cast<SaBoolT>(true);
> - t_sisu->comp_name = t_csicomp->comp->comp_info.name;
> + t_sisu->comp_name =
> Amf::to_string(&t_csicomp->comp->comp_info.name);
> t_sisu->csi_name = t_csicomp->csi->name;
> m_AVSV_SEND_CKPT_UPDT_ASYNC_UPDT(avd_cb, t_sisu,
> AVSV_CKPT_AVD_SI_ASS);
> t_sisu = t_sisu->si_next;
> @@ -878,11 +905,11 @@
> if (!strcmp(attr_mod->modAttr.attrName, "saAmfCSType")) {
> AVD_CS_TYPE *csi_type;
> SaNameT cstype_name = *(SaNameT*)
> attr_mod->modAttr.attrValues[0];
> - TRACE("saAmfCSType modified from '%s' to '%s' for
> Csi'%s'", csi->saAmfCSType.value,
> - cstype_name.value, csi->name.value);
> + TRACE("saAmfCSType modified from '%s' to '%s' for
> Csi'%s'", csi->saAmfCSType.c_str(),
> + cstype_name.value, csi->name.c_str());
> csi_type =
> cstype_db->find(Amf::to_string(&cstype_name));
> avd_cstype_remove_csi(csi);
> - csi->saAmfCSType = cstype_name;
> + csi->saAmfCSType = Amf::to_string(&cstype_name);
> csi->cstype = csi_type;
> avd_cstype_add_csi(csi);
> } else if (!strcmp(attr_mod->modAttr.attrName,
> "saAmfCSIDependencies")) {
> @@ -890,7 +917,7 @@
> assert(attr_mod->modAttr.attrValuesNumber == 1);
> si->remove_csi(csi);
> AVD_CSI_DEPS *new_csi_dep = new AVD_CSI_DEPS();
> - new_csi_dep->csi_dep_name_value = *((SaNameT*)
> attr_mod->modAttr.attrValues[0]);
> + new_csi_dep->csi_dep_name_value =
> Amf::to_string((SaNameT*) attr_mod->modAttr.attrValues[0]);
> bool already_exist = csi_add_csidep(csi,
> new_csi_dep);
> if (already_exist)
> delete new_csi_dep;
> @@ -899,7 +926,7 @@
> } else if (attr_mod->modType ==
> SA_IMM_ATTR_VALUES_DELETE) {
> assert(attr_mod->modAttr.attrValuesNumber == 1);
> const SaNameT *required_dn = (SaNameT*)
> attr_mod->modAttr.attrValues[0];
> - csi_remove_csidep(csi, required_dn);
> + csi_remove_csidep(csi,
> Amf::to_string(required_dn));
>
> //Mark rank of all the CSIs to 0.
> for (AVD_CSI *tmp_csi =
> csi->si->list_of_csi; tmp_csi;
> @@ -942,10 +969,10 @@
> possibility that before getting ccb apply callback
> we might get compcsi create checkpoint and csi will
> be created as part of checkpoint processing */
> - csi = csi_create(&opdata->objectName);
> + csi = csi_create(Amf::to_string(&opdata->objectName));
> }
> csi_get_attr_and_add_to_model(csi, opdata->param.create.attrValues,
> - opdata->param.create.parentName);
> + Amf::to_string(opdata->param.create.parentName));
>
> if (avd_cb->avail_state_avd != SA_AMF_HA_ACTIVE)
> goto done;
> @@ -977,7 +1004,7 @@
> for(t_sisu = csi->si->list_of_sisu; t_sisu != nullptr; t_sisu =
> t_sisu->si_next) {
> if (t_sisu->csi_add_rem == true) {
> LOG_NO("CSI create '%s' delayed: pending
> assignment for '%s'",
> - csi->name.value,
> t_sisu->su->name.value);
> + csi->name.c_str(),
> t_sisu->su->name.c_str());
> goto done;
> }
> }
> @@ -997,17 +1024,17 @@
> compcsi = compcsi->susi_csicomp_next;
> }
>
> - t_comp =
> t_sisu->su->find_unassigned_comp_that_provides_cstype(&csi->saAmfCSType);
> + t_comp =
> t_sisu->su->find_unassigned_comp_that_provides_cstype(csi->saAmfCSType);
>
> /* Component not found.*/
> if (nullptr == t_comp) {
> /* This means that all the components are
> assigned, let us assigned it to assigned
> component.*/
> - t_comp =
> AVD_CSI::find_assigned_comp(&csi->saAmfCSType, t_sisu,
> t_sisu->su->list_of_comp);
> + t_comp =
> AVD_CSI::find_assigned_comp(csi->saAmfCSType, t_sisu,
> t_sisu->su->list_of_comp);
> }
> if (nullptr == t_comp) {
> LOG_ER("Compcsi doesn't exist or
> MaxActiveCSI/MaxStandbyCSI have reached for csi '%s'",
> - csi->name.value);
> + csi->name.c_str());
> goto done;
> }
>
> @@ -1032,7 +1059,7 @@
>
> }
> t_sisu->csi_add_rem = static_cast<SaBoolT>(true);
> - t_sisu->comp_name = compcsi->comp->comp_info.name;
> + t_sisu->comp_name =
> Amf::to_string(&compcsi->comp->comp_info.name);
> t_sisu->csi_name = compcsi->csi->name;
> m_AVSV_SEND_CKPT_UPDT_ASYNC_UPDT(avd_cb, t_sisu,
> AVSV_CKPT_AVD_SI_ASS);
> t_sisu = t_sisu->si_next;
> @@ -1078,7 +1105,7 @@
> * @param comp_dn
> */
> static void avd_create_csiassignment_in_imm(SaAmfHAStateT ha_state,
> - const SaNameT *csi_dn, const SaNameT *comp_dn)
> + const std::string& csi_dn, const std::string& _comp_dn)
> {
> SaNameT dn;
> SaAmfHAReadinessStateT saAmfCSICompHAReadinessState =
> SA_AMF_HARS_READY_FOR_ASSIGNMENT;
> @@ -1104,6 +1131,7 @@
> nullptr
> };
>
> + const SaNameTWrapper comp_dn(_comp_dn);
> avsv_create_association_class_dn(comp_dn, nullptr, "safCSIComp", &dn);
>
> TRACE("Adding %s", dn.value);
> @@ -1120,7 +1148,7 @@
> return nullptr;
> }
>
> - TRACE_ENTER2("Comp'%s' and Csi'%s'", comp->comp_info.name.value,
> csi->name.value);
> + TRACE_ENTER2("Comp'%s' and Csi'%s'", comp->comp_info.name.value,
> csi->name.c_str());
>
> /* do not add if already in there */
> for (compcsi = susi->list_of_csicomp; compcsi; compcsi =
> compcsi->susi_csicomp_next) {
> @@ -1151,7 +1179,7 @@
> susi->list_of_csicomp = compcsi;
> }
> if (create_in_imm)
> - avd_create_csiassignment_in_imm(susi->state, &csi->name,
> &comp->comp_info.name);
> + avd_create_csiassignment_in_imm(susi->state, csi->name,
> Amf::to_string(&comp->comp_info.name));
> done:
> TRACE_LEAVE();
> return compcsi;
> @@ -1162,14 +1190,16 @@
> * @param comp_dn
> * @param csi_dn
> */
> -static void avd_delete_csiassignment_from_imm(const SaNameT *comp_dn, const
> SaNameT *csi_dn)
> +static void avd_delete_csiassignment_from_imm(const std::string& comp_dn,
> const std::string& csi_dn)
> {
> - SaNameT dn;
> + SaNameT dn;
> + const SaNameTWrapper comp(comp_dn);
> + const SaNameTWrapper csi(csi_dn);
>
> - avsv_create_association_class_dn(comp_dn, csi_dn, "safCSIComp", &dn);
> + avsv_create_association_class_dn(comp, csi, "safCSIComp", &dn);
> TRACE("Deleting %s", dn.value);
>
> - avd_saImmOiRtObjectDelete(&dn);
> + avd_saImmOiRtObjectDelete(Amf::to_string(&dn));
> }
>
>
> /*****************************************************************************
> @@ -1224,7 +1254,7 @@
> susi->list_of_csicomp = lcomp_csi->susi_csicomp_next;
> lcomp_csi->susi_csicomp_next = nullptr;
> prev_compcsi = nullptr;
> -
> avd_delete_csiassignment_from_imm(&lcomp_csi->comp->comp_info.name,
> &lcomp_csi->csi->name);
> +
> avd_delete_csiassignment_from_imm(Amf::to_string(&lcomp_csi->comp->comp_info.name),
> lcomp_csi->csi->name);
> delete lcomp_csi;
>
> }
> @@ -1252,7 +1282,7 @@
> {
> AVD_COMP_CSI_REL *t_compcsi, *t_compcsi_susi, *prev_compcsi = nullptr;
>
> - TRACE_ENTER2("Csi'%s', compcsi_cnt'%u'", comp_csi->csi->name.value,
> comp_csi->csi->compcsi_cnt);
> + TRACE_ENTER2("Csi'%s', compcsi_cnt'%u'", comp_csi->csi->name.c_str(),
> comp_csi->csi->compcsi_cnt);
>
> /* Find the comp-csi in susi. */
> t_compcsi_susi = susi->list_of_csicomp;
> @@ -1293,8 +1323,8 @@
> comp_csi->csi->compcsi_cnt--;
>
> if (!ckpt)
> - avd_snd_pg_upd_msg(avd_cb, comp_csi->comp->su->su_on_node,
> comp_csi, SA_AMF_PROTECTION_GROUP_REMOVED, 0);
> - avd_delete_csiassignment_from_imm(&comp_csi->comp->comp_info.name,
> &comp_csi->csi->name);
> + avd_snd_pg_upd_msg(avd_cb, comp_csi->comp->su->su_on_node,
> comp_csi, SA_AMF_PROTECTION_GROUP_REMOVED, std::string(""));
> +
> avd_delete_csiassignment_from_imm(Amf::to_string(&comp_csi->comp->comp_info.name),
> comp_csi->csi->name);
> delete comp_csi;
>
> TRACE_LEAVE();
> @@ -1394,7 +1424,7 @@
> spons_csi = spons_csi->csi_dep_next) {
> bool is_sponsor_assigned = false;
>
> - AVD_CSI *tmp_csi =
> csi_db->find(Amf::to_string(&spons_csi->csi_dep_name_value));
> + AVD_CSI *tmp_csi =
> csi_db->find(spons_csi->csi_dep_name_value);
>
> //Check if this sponsor csi is assigned to any comp in this su.
> for (AVD_COMP_CSI_REL *compcsi = tmp_csi->list_compcsi; compcsi;
> 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
> @@ -227,7 +227,7 @@
> *
> * @return int
> */
> -SaAisErrorT avd_csiattr_config_get(const SaNameT *csi_name, AVD_CSI *csi)
> +SaAisErrorT avd_csiattr_config_get(const std::string& csi_name, AVD_CSI *csi)
> {
> SaAisErrorT error;
> SaImmSearchHandleT searchHandle;
> @@ -242,7 +242,7 @@
> searchParam.searchOneAttr.attrValueType = SA_IMM_ATTR_SASTRINGT;
> searchParam.searchOneAttr.attrValue = &className;
>
> - if ((error = immutil_saImmOmSearchInitialize_2(avd_cb->immOmHandle,
> csi_name,
> + if ((error = immutil_saImmOmSearchInitialize_o2(avd_cb->immOmHandle,
> csi_name.c_str(),
> SA_IMM_SUBTREE, SA_IMM_SEARCH_ONE_ATTR |
> SA_IMM_SEARCH_GET_ALL_ATTR,
> &searchParam, nullptr, &searchHandle)) != SA_AIS_OK) {
>
> 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
> @@ -24,35 +24,24 @@
>
> AmfDb<std::string, AVD_CS_TYPE> *cstype_db = nullptr;
>
> -//
> -// TODO(HANO) Temporary use this function instead of strdup which uses
> malloc.
> -// Later on remove this function and use std::string instead
> -#include <cstring>
> -static char *StrDup(const char *s)
> -{
> - char *c = new char[strlen(s) + 1];
> - std::strcpy(c,s);
> - return c;
> -}
> -
> static void cstype_add_to_model(AVD_CS_TYPE *cst)
> {
> - uint32_t rc = cstype_db->insert(Amf::to_string(&cst->name),cst);
> + uint32_t rc = cstype_db->insert(cst->name,cst);
> osafassert(rc == NCSCC_RC_SUCCESS);
> }
>
> //
> -AVD_CS_TYPE::AVD_CS_TYPE(const SaNameT *dn) {
> - memcpy(&name.value, dn->value, dn->length);
> - name.length = dn->length;
> +AVD_CS_TYPE::AVD_CS_TYPE(const std::string& dn) :
> + name(dn)
> +{
> }
>
> -static AVD_CS_TYPE *cstype_create(const SaNameT *dn, const
> SaImmAttrValuesT_2 **attributes)
> +static AVD_CS_TYPE *cstype_create(const std::string& dn, const
> SaImmAttrValuesT_2 **attributes)
> {
> AVD_CS_TYPE *cst;
> SaUint32T values_number;
>
> - TRACE_ENTER2("'%s'", dn->value);
> + TRACE_ENTER2("'%s'", dn.c_str());
>
> cst = new AVD_CS_TYPE(dn);
>
> @@ -60,9 +49,9 @@
> (values_number > 0)) {
> unsigned int i;
>
> - cst->saAmfCSAttrName = new SaStringT[values_number + 1]();
> - for (i = 0; i < values_number; i++)
> - cst->saAmfCSAttrName[i] =
> StrDup(immutil_getStringAttr(attributes, "saAmfCSAttrName", i));
> + for (i = 0; i < values_number; i++) {
> +
> cst->saAmfCSAttrName.push_back(immutil_getStringAttr(attributes,
> "saAmfCSAttrName", i));
> + }
> }
>
> TRACE_LEAVE();
> @@ -75,24 +64,17 @@
> */
> static void cstype_delete(AVD_CS_TYPE *cst)
> {
> - char *p;
> - int i = 0;
> -
> - cstype_db->erase(Amf::to_string(&cst->name));
> -
> - if (cst->saAmfCSAttrName != nullptr) {
> - while ((p = cst->saAmfCSAttrName[i++]) != nullptr) {
> - delete [] p;
> - }
> - }
> - delete [] cst->saAmfCSAttrName;
> + cstype_db->erase(cst->name);
> + cst->saAmfCSAttrName.clear();
> delete cst;
> }
>
> void avd_cstype_add_csi(AVD_CSI *csi)
> {
> + TRACE_ENTER();
> csi->csi_list_cs_type_next = csi->cstype->list_of_csi;
> csi->cstype->list_of_csi = csi;
> + TRACE_LEAVE();
> }
>
> void avd_cstype_remove_csi(AVD_CSI *csi)
> @@ -175,7 +157,7 @@
> goto done2;
>
> if ((cst = cstype_db->find(Amf::to_string(&dn))) == nullptr){
> - if ((cst = cstype_create(&dn, attributes)) == nullptr)
> + if ((cst = cstype_create(Amf::to_string(&dn),
> attributes)) == nullptr)
> goto done2;
>
> cstype_add_to_model(cst);
> @@ -222,8 +204,9 @@
> * each of the CSI in the cs_type list in the current
> CCB
> */
> csi = cst->list_of_csi;
> - while (csi != nullptr) {
> - t_opData =
> ccbutil_getCcbOpDataByDN(opdata->ccbId, &csi->name);
> + while (csi != nullptr) {
> + const SaNameTWrapper csi_name(csi->name);
> + t_opData =
> ccbutil_getCcbOpDataByDN(opdata->ccbId, csi_name);
> if ((t_opData == nullptr) ||
> (t_opData->operationType != CCBUTIL_DELETE)) {
> csi_exist = true;
> break;
> @@ -231,7 +214,7 @@
> csi = csi->csi_list_cs_type_next;
> }
> if (csi_exist == true) {
> - report_ccb_validation_error(opdata,
> "SaAmfCSType '%s' is in use", cst->name.value);
> + report_ccb_validation_error(opdata,
> "SaAmfCSType '%s' is in use", cst->name.c_str());
> goto done;
> }
> }
> @@ -255,7 +238,7 @@
>
> switch (opdata->operationType) {
> case CCBUTIL_CREATE:
> - cst = cstype_create(&opdata->objectName,
> opdata->param.create.attrValues);
> + cst = cstype_create(Amf::to_string(&opdata->objectName),
> opdata->param.create.attrValues);
> osafassert(cst);
> cstype_add_to_model(cst);
> break;
> 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
> @@ -29,57 +29,58 @@
>
> static void ctcstype_db_add(AVD_CTCS_TYPE *ctcstype)
> {
> - unsigned int rc =
> ctcstype_db->insert(Amf::to_string(&ctcstype->name),ctcstype);
> + unsigned int rc = ctcstype_db->insert(ctcstype->name,ctcstype);
> osafassert(rc == NCSCC_RC_SUCCESS);
> }
>
> -static int is_config_valid(const SaNameT *dn, const SaImmAttrValuesT_2
> **attributes, CcbUtilOperationData_t *opdata)
> +static int is_config_valid(const std::string& dn, const SaImmAttrValuesT_2
> **attributes, CcbUtilOperationData_t *opdata)
> {
> SaUint32T uint32;
> - char *parent;
> - SaNameT cstype_dn;
> + std::string::size_type parent;
> + std::string cstype_dn;
>
> - if (get_child_dn_from_ass_dn(dn, &cstype_dn) != 0) {
> - report_ccb_validation_error(opdata, "malformed DN '%s'",
> dn->value);
> + if (get_child_dn_from_ass_dn(dn, cstype_dn) != 0) {
> + report_ccb_validation_error(opdata, "malformed DN '%s'",
> dn.c_str());
> return 0;
> }
>
> - if (cstype_db->find(Amf::to_string(&cstype_dn)) == nullptr) {
> + if (cstype_db->find(cstype_dn) == nullptr) {
> if (opdata == nullptr) {
> report_ccb_validation_error(opdata,
> "SaAmfCSType object '%s' does not exist in
> model",
> - cstype_dn.value);
> + cstype_dn.c_str());
> return 0;
> }
>
> - if (ccbutil_getCcbOpDataByDN(opdata->ccbId, &cstype_dn) ==
> nullptr) {
> + const SaNameTWrapper cstype(cstype_dn);
> + if (ccbutil_getCcbOpDataByDN(opdata->ccbId, cstype) == nullptr)
> {
> report_ccb_validation_error(opdata,
> "SaAmfCSType object '%s' does not exist in
> model or CCB",
> - cstype_dn.value);
> + cstype_dn.c_str());
> return 0;
> }
> }
>
> /* Second comma should be parent */
> - if ((parent = strchr((char*)dn->value, ',')) == nullptr) {
> - report_ccb_validation_error(opdata, "No parent to '%s' ",
> dn->value);
> + if ((parent = dn.find(',')) == std::string::npos) {
> + report_ccb_validation_error(opdata, "No parent to '%s' ",
> dn.c_str());
> return 0;
> }
>
> - if ((parent = strchr(++parent, ',')) == nullptr) {
> - report_ccb_validation_error(opdata, "No parent to '%s' ",
> dn->value);
> + if ((parent = dn.find(',', parent + 1)) == std::string::npos) {
> + report_ccb_validation_error(opdata, "No parent to '%s' ",
> dn.c_str());
> return 0;
> }
>
> /* Should be children to SaAmfCompType */
> - if (strncmp(++parent, "safVersion=", 11) != 0) {
> - report_ccb_validation_error(opdata, "Wrong parent '%s'",
> parent);
> + if (dn.compare(parent + 1, 11, "safVersion=") != 0) {
> + report_ccb_validation_error(opdata, "Wrong parent '%s'",
> dn.c_str());
> return 0;
> }
>
> if
> ((immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCtCompCapability"),
> attributes, 0, &uint32) == SA_AIS_OK) &&
> (uint32 > SA_AMF_COMP_NON_PRE_INSTANTIABLE)) {
> - report_ccb_validation_error(opdata, "Invalid
> saAmfCtCompCapability %u for '%s'", uint32, dn->value);
> + report_ccb_validation_error(opdata, "Invalid
> saAmfCtCompCapability %u for '%s'", uint32, dn.c_str());
> return 0;
> }
>
> @@ -87,24 +88,22 @@
> }
>
> //
> -AVD_CTCS_TYPE::AVD_CTCS_TYPE(const SaNameT *dn) {
> - memcpy(&name.value, dn->value, dn->length);
> - name.length = dn->length;
> +AVD_CTCS_TYPE::AVD_CTCS_TYPE(const std::string& dn) :
> + name(dn)
> +{
> }
>
> //
> -static AVD_CTCS_TYPE *ctcstype_create(const SaNameT *dn, const
> SaImmAttrValuesT_2 **attributes)
> +static AVD_CTCS_TYPE *ctcstype_create(const std::string& dn, const
> SaImmAttrValuesT_2 **attributes)
> {
> AVD_CTCS_TYPE *ctcstype;
> int rc = -1;
> SaAisErrorT error;
>
> - TRACE_ENTER2("'%s'", dn->value);
> + TRACE_ENTER2("'%s'", dn.c_str());
>
> ctcstype = new AVD_CTCS_TYPE(dn);
>
> -
> -
> error =
> immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCtCompCapability"),
> attributes, 0, &ctcstype->saAmfCtCompCapability);
> osafassert(error == SA_AIS_OK);
>
> @@ -126,7 +125,7 @@
> return ctcstype;
> }
>
> -SaAisErrorT avd_ctcstype_config_get(const SaNameT *comp_type_dn,
> AVD_COMP_TYPE *comp_type)
> +SaAisErrorT avd_ctcstype_config_get(const std::string& comp_type_dn,
> AVD_COMP_TYPE *comp_type)
> {
> SaAisErrorT error = SA_AIS_ERR_FAILED_OPERATION;
> SaImmSearchHandleT searchHandle;
> @@ -142,7 +141,7 @@
> searchParam.searchOneAttr.attrValueType = SA_IMM_ATTR_SASTRINGT;
> searchParam.searchOneAttr.attrValue = &className;
>
> - if (immutil_saImmOmSearchInitialize_2(avd_cb->immOmHandle, comp_type_dn,
> + if (immutil_saImmOmSearchInitialize_o2(avd_cb->immOmHandle,
> comp_type_dn.c_str(),
> SA_IMM_SUBTREE, SA_IMM_SEARCH_ONE_ATTR |
> SA_IMM_SEARCH_GET_ALL_ATTR,
> &searchParam, nullptr, &searchHandle) != SA_AIS_OK) {
>
> @@ -151,11 +150,11 @@
> }
>
> while (immutil_saImmOmSearchNext_2(searchHandle, &dn,
> (SaImmAttrValuesT_2 ***)&attributes) == SA_AIS_OK) {
> - if (!is_config_valid(&dn, attributes, nullptr))
> + if (!is_config_valid(Amf::to_string(&dn), attributes, nullptr))
> goto done2;
>
> if ((ctcstype = ctcstype_db->find(Amf::to_string(&dn))) ==
> nullptr ) {
> - if ((ctcstype = ctcstype_create(&dn, attributes)) ==
> nullptr)
> + if ((ctcstype = ctcstype_create(Amf::to_string(&dn),
> attributes)) == nullptr)
> goto done2;
>
> ctcstype_db_add(ctcstype);
> @@ -179,7 +178,7 @@
>
> switch (opdata->operationType) {
> case CCBUTIL_CREATE:
> - if (is_config_valid(&opdata->objectName,
> opdata->param.create.attrValues, opdata))
> + if (is_config_valid(Amf::to_string(&opdata->objectName),
> opdata->param.create.attrValues, opdata))
> rc = SA_AIS_OK;
> break;
> case CCBUTIL_MODIFY:
> @@ -205,14 +204,14 @@
>
> switch (opdata->operationType) {
> case CCBUTIL_CREATE:
> - ctcstype = ctcstype_create(&opdata->objectName,
> opdata->param.create.attrValues);
> + ctcstype = ctcstype_create(Amf::to_string(&opdata->objectName),
> opdata->param.create.attrValues);
> osafassert(ctcstype);
> ctcstype_db_add(ctcstype);
> break;
> case CCBUTIL_DELETE:
> ctcstype =
> ctcstype_db->find(Amf::to_string(&opdata->objectName));
> if (ctcstype != nullptr) {
> - ctcstype_db->erase(Amf::to_string(&ctcstype->name));
> + ctcstype_db->erase(ctcstype->name);
> delete ctcstype;
> }
> break;
> @@ -224,11 +223,13 @@
> TRACE_LEAVE();
> }
>
> -AVD_CTCS_TYPE *get_ctcstype(const SaNameT *comptype_name, const SaNameT
> *cstype_name)
> +AVD_CTCS_TYPE *get_ctcstype(const std::string& comptype_name, const
> std::string& cstype_name)
> {
> SaNameT dn;
> + const SaNameTWrapper comptype(comptype_name);
> + const SaNameTWrapper cstype(cstype_name);
> AVD_CTCS_TYPE *ctcs_type = nullptr;
> - avsv_create_association_class_dn(cstype_name, comptype_name,
> + avsv_create_association_class_dn(cstype, comptype,
> "safSupportedCsType", &dn);
> ctcs_type = ctcstype_db->find(Amf::to_string(&dn));
> return ctcs_type;
>
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel