osaf/services/saf/amf/amfd/app.cc     |  27 ++++++++++++---------------
 osaf/services/saf/amf/amfd/apptype.cc |  13 ++++---------
 2 files changed, 16 insertions(+), 24 deletions(-)


* Unnecessary header file (HFA)
* Logically dead code (DEADCODE)
* Dereference null return value (NULL_RETURNS)
* Uninitialized scalar variable (UNINIT)
* Unused pointer value (UNUSED_VALUE)

* Also remove check for NULL return value from avd_app_new() as this is no 
longer required

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
@@ -20,7 +20,6 @@
 
 #include <util.h>
 #include <app.h>
-#include <cluster.h>
 #include <imm.h>
 #include <si.h>
 
@@ -219,8 +218,7 @@
 
 AVD_APP *avd_app_create(const SaNameT *dn, const SaImmAttrValuesT_2 
**attributes)
 {
-       int rc = -1;
-       AVD_APP *app;
+       AVD_APP *app = NULL;
        SaAisErrorT error;
 
        TRACE_ENTER2("'%s'", dn->value);
@@ -229,11 +227,12 @@
        ** If called at new active at failover, the object is found in the DB
        ** but needs to get configuration attributes initialized.
        */
-       if (NULL == (app = avd_app_get(dn))) {
-               if ((app = avd_app_new(dn)) == NULL)
-                       goto done;
-       } else
+       app = avd_app_get(dn);
+       if (app == NULL) {
+               app = avd_app_new(dn);
+       } else {
                TRACE("already created, refreshing config...");
+       }
 
        error = immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfAppType"), 
attributes, 0, &app->saAmfAppType);
        osafassert(error == SA_AIS_OK);
@@ -243,14 +242,6 @@
                app->saAmfApplicationAdminState = SA_AMF_ADMIN_UNLOCKED;
        }
 
-       rc = 0;
-
-done:
-       if (rc != 0) {
-               avd_app_delete(app);
-               app = NULL;
-       }
-
        return app;
 }
 
@@ -315,6 +306,8 @@
        case CCBUTIL_MODIFY: {
                const SaImmAttrModificationT_2 *attr_mod;
                app = avd_app_get(&opdata->objectName);
+               // app should be present in app_db
+               osafassert(app);
 
                while ((attr_mod = opdata->param.modify.attrMods[i++]) != NULL) 
{
                        const SaImmAttrValuesT_2 *attribute = 
&attr_mod->modAttr;
@@ -325,6 +318,7 @@
                                avd_apptype_remove_app(app);
                                app->saAmfAppType = 
*((SaNameT*)attribute->attrValues[0]);
                                app->app_type = 
avd_apptype_get(&app->saAmfAppType);
+                               osafassert(app->app_type);
                                avd_apptype_add_app(app);
                                break;
                        }
@@ -335,6 +329,8 @@
        }
        case CCBUTIL_DELETE:
                app = avd_app_get(&opdata->objectName);
+               // app should be present in app_db
+               osafassert(app);
                /* by this time all the SGs and SIs under this 
                 * app object should have been *DELETED* just  
                 * do a sanity check here
@@ -494,6 +490,7 @@
 void avd_app_constructor(void)
 {
        NCS_PATRICIA_PARAMS patricia_params;
+       memset(&patricia_params, 0, sizeof(NCS_PATRICIA_PARAMS));
 
        patricia_params.key_size = sizeof(SaNameT);
        osafassert(ncs_patricia_tree_init(&app_db, &patricia_params) == 
NCSCC_RC_SUCCESS);
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
@@ -18,9 +18,7 @@
 
 #include <logtrace.h>
 #include <app.h>
-#include <cluster.h>
 #include <imm.h>
-#include <si.h>
 #include <util.h>
 
 static NCS_PATRICIA_TREE apptype_db;
@@ -106,7 +104,6 @@
 {
        int i = 0;
        unsigned int j;
-       int rc = -1;
        AVD_APP_TYPE *app_type;
        const SaImmAttrValuesT_2 *attr;
 
@@ -131,11 +128,6 @@
                app_type->sgAmfApptSGTypes[j] = *((SaNameT 
*)attr->attrValues[j]);
        }
 
-       rc = 0;
-
-       if (rc != 0)
-               apptype_delete(&app_type);
-
        return app_type;
 }
 
@@ -159,6 +151,8 @@
                break;
        case CCBUTIL_DELETE:
                app_type = avd_apptype_get(&opdata->objectName);
+               // app_type should be present in apptype_db
+               osafassert(app_type);
                if (NULL != 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
@@ -239,7 +233,7 @@
                if (!is_config_valid(&dn, attributes, NULL))
                        goto done2;
 
-               if ((app_type = avd_apptype_get(&dn)) == NULL ) {
+               if (avd_apptype_get(&dn) == NULL) {
                        if ((app_type = apptype_create(&dn, attributes)) == 
NULL)
                                goto done2;
 
@@ -292,6 +286,7 @@
 void avd_apptype_constructor(void)
 {
        NCS_PATRICIA_PARAMS patricia_params;
+       memset(&patricia_params, 0, sizeof(NCS_PATRICIA_PARAMS));
 
        patricia_params.key_size = sizeof(SaNameT);
        osafassert(ncs_patricia_tree_init(&apptype_db, &patricia_params) == 
NCSCC_RC_SUCCESS);

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to