EasySetup:Fix for static analyzer reported issues 33/21233/4
authorHarry <h.marappa@samsung.com>
Tue, 4 Jul 2017 13:07:48 +0000 (18:37 +0530)
committerPhil Coval <philippe.coval@osg.samsung.com>
Fri, 21 Jul 2017 09:31:53 +0000 (09:31 +0000)
Removal of never used methods and catching exceptions by reference.

Change-Id: I10d3c83ce5b14174b6f82a49897738c98a461af7
Signed-off-by: Harry <h.marappa@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/21233
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Senthil Kumar G S <senthil.gs@samsung.com>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
service/easy-setup/enrollee/unittests/ESEnrolleeTest.cpp
service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/jni/JniEasySetup.cpp
service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/jni/JniEsUtils.cpp
service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/jni/JniRemoteEnrollee.cpp
service/easy-setup/mediator/richsdk/src/EnrolleeSecurity.cpp

index b041d1f..9e305b0 100644 (file)
@@ -325,6 +325,7 @@ TEST_F(EasysetupEnrolleeTest, DevicePropertyIsWellConstructedInResponsePayload)
                 }
             }
         });
+
     ESResult ret = startEnrollee();
     ret = setDeviceProperty();
 
@@ -333,7 +334,7 @@ TEST_F(EasysetupEnrolleeTest, DevicePropertyIsWellConstructedInResponsePayload)
     std::unique_lock< std::mutex > lock{ mutexForCondition };
     responseCon.wait_for(lock, g_waitForResponse);
 
-    EXPECT_EQ(ret, ES_OK);
+    EXPECT_TRUE(isWellConstructed);
 
     ESTerminateEnrollee();
 }
@@ -356,6 +357,7 @@ TEST_F(EasysetupEnrolleeTest, ProvisioningPropertiesIsWellConstructedInResponseP
                 }
             }
         });
+
     ESResult ret = startEnrollee();
     ret = setDeviceProperty();
     ret = ESSetState(ES_STATE_CONNECTED_TO_ENROLLER);
@@ -366,7 +368,7 @@ TEST_F(EasysetupEnrolleeTest, ProvisioningPropertiesIsWellConstructedInResponseP
     std::unique_lock< std::mutex > lock{ mutexForCondition };
     responseCon.wait_for(lock, g_waitForResponse);
 
-    EXPECT_EQ(ret, ES_OK);
+    EXPECT_TRUE(isWellConstructed);
 
     ESTerminateEnrollee();
 }
@@ -448,7 +450,6 @@ TEST_F(EasysetupEnrolleeTest, GetWifiRsrcTest)
     mocks.ExpectCallFunc(onGetWifiRsrc).Do(
         [& isRepFlag](const OCRepresentation& /*rep*/)
         {
-
             isRepFlag = true;
         });
 
@@ -458,7 +459,7 @@ TEST_F(EasysetupEnrolleeTest, GetWifiRsrcTest)
     std::unique_lock< std::mutex > lock{ mutexForCondition };
     responseCon.wait_for(lock, g_waitForResponse);
 
-    EXPECT_EQ(ret, ES_OK);
+    EXPECT_TRUE(isRepFlag);
 
     ESTerminateEnrollee();
 }
@@ -478,7 +479,7 @@ TEST_F(EasysetupEnrolleeTest, GetCloudRsrcTest)
     std::unique_lock< std::mutex > lock{ mutexForCondition };
     responseCon.wait_for(lock, g_waitForResponse);
 
-    EXPECT_EQ(ret, ES_OK);
+    EXPECT_TRUE(isRepFlag);
 
     ESTerminateEnrollee();
 }
@@ -500,7 +501,7 @@ TEST_F(EasysetupEnrolleeTest, GetDevConfTest)
     std::unique_lock< std::mutex > lock{ mutexForCondition };
     responseCon.wait_for(lock, g_waitForResponse);
 
-    EXPECT_EQ(ret, ES_OK);
+    EXPECT_TRUE(isRepFlag);
 
     ESTerminateEnrollee();
 }
@@ -521,7 +522,7 @@ TEST_F(EasysetupEnrolleeTest, PutRequestTest)
     std::unique_lock< std::mutex > lock{ mutexForCondition };
     responseCon.wait_for(lock, g_waitForResponse);
 
-    EXPECT_EQ(ret, ES_OK);
+    EXPECT_TRUE(isRepFlag);
 
     ESTerminateEnrollee();
 }
index 4332919..2b67e7e 100644 (file)
@@ -76,11 +76,11 @@ Java_org_iotivity_service_easysetup_mediator_EasySetup_nativeCreateRemoteEnrolle
         JniRemoteEnrollee *jniRemoteEnrollee = new JniRemoteEnrollee(nativeRemoteEnrollee);
         ESSetHandle<JniRemoteEnrollee>(env, jRemoteEnrollee, jniRemoteEnrollee);
     }
-    catch (ESBadRequestException exception)
+    catch (ESBadRequestException &exception)
     {
         ES_LOGE("JniEasySetup::nativeCreateRemoteEnrollee Unable to create the Native EnrolleeDevice");
         //throw the exception to java layer
-        throwESException( env,  exception.what());
+        throwESException(env,  exception.what());
     }
 
     ES_LOGI("JniEasySetup::nativeCreateRemoteEnrollee exit");
index 106c18e..14a7f8e 100644 (file)
@@ -31,82 +31,3 @@ void throwESException(JNIEnv *env, std::string reason)
     env->Throw((jthrowable)ex);
 }
 
-OCConnectivityType  getOCConnectivityTypeFromInt(int connectivityType)
-{
-    switch (connectivityType)
-    {
-        case CT_DEFAULT:
-            return CT_DEFAULT;
-        case CT_ADAPTER_IP:
-            return CT_ADAPTER_IP;
-
-            //May be need to add more types, if easy setup service support more transport.
-    }
-    return CT_DEFAULT;
-}
-
-WIFI_AUTHTYPE getWifiAuthTypeFromInt(int authType)
-{
-    switch (authType)
-    {
-        case 0:
-            return WIFI_AUTHTYPE::NONE_AUTH;
-        case 1:
-            return WIFI_AUTHTYPE::WEP;
-        case 2:
-            return WIFI_AUTHTYPE::WPA_PSK;
-        case 3:
-            return WIFI_AUTHTYPE::WPA2_PSK;
-    }
-    return NONE_AUTH;
-}
-
-WIFI_ENCTYPE getWifiEncTypeFromInt(int encType)
-{
-    switch (encType)
-    {
-        case 0:
-            return WIFI_ENCTYPE::NONE_ENC;
-        case 1:
-            return WIFI_ENCTYPE::WEP_64;
-        case 2:
-            return WIFI_ENCTYPE::WEP_128;
-        case 3:
-            return WIFI_ENCTYPE::TKIP;
-        case 4:
-            return WIFI_ENCTYPE::AES;
-        case 5:
-            return WIFI_ENCTYPE::TKIP_AES;
-    }
-    return NONE_ENC;
-}
-
-int convertNativeWifiFreqToInt(WIFI_FREQ wifiFreq)
-{
-    switch (wifiFreq)
-    {
-        case WIFI_FREQ::WIFI_24G:
-            return 0;
-        case WIFI_FREQ::WIFI_5G:
-            return 1;
-        case WIFI_FREQ::WIFI_BOTH:
-            return 2;
-    }
-}
-
-int convertNativeWifiModeToInt(WIFI_MODE wifiMode)
-{
-    switch (wifiMode)
-    {
-        case WIFI_MODE::WIFI_11A:
-            return 0;
-        case WIFI_MODE::WIFI_11B:
-            return 1;
-        case WIFI_MODE::WIFI_11G:
-            return 2;
-        case WIFI_MODE::WIFI_11N:
-            return 3;
-        case WIFI_MODE::WIFI_11AC:
-            return 4;
-    }
-}
\ No newline at end of file
index 851aeab..06bbc42 100644 (file)
@@ -68,11 +68,11 @@ void JniRemoteEnrollee::getStatus(JNIEnv *env, jobject jListener)
     {
         m_sharedResource->getStatus(getEnrolleeStatusCallback);
     }
-    catch (ESBadRequestException exception)
+    catch (ESBadRequestException &exception)
     {
         ES_LOGE("JNI getStatus :: Exception occured");
         //throw the exception to java
-        throwESException( env,  exception.what());
+        throwESException(env, exception.what());
     }
 }
 
@@ -91,11 +91,11 @@ void JniRemoteEnrollee::getConfiguration(JNIEnv *env, jobject jListener)
     {
         m_sharedResource->getConfiguration(getConfigurationStatusCallback);
     }
-    catch (ESBadRequestException exception)
+    catch (ESBadRequestException &exception)
     {
         ES_LOGE("JNI getConfiguration :: Exception occured");
         //throw the exception to java
-        throwESException( env,  exception.what());
+        throwESException(env, exception.what());
     }
 }
 
@@ -114,11 +114,11 @@ void JniRemoteEnrollee::provisionSecurity(JNIEnv *env, jobject jListener)
     {
         m_sharedResource->provisionSecurity(secProvStatusCallback);
     }
-    catch (ESBadRequestException exception)
+    catch (ESBadRequestException &exception)
     {
         ES_LOGE("JNI provisionSecurity :: Exception occured");
         //throw the exception to java
-        throwESException( env,  exception.what());
+        throwESException(env, exception.what());
     }
 }
 
@@ -146,11 +146,11 @@ void JniRemoteEnrollee::provisionDeviceProperties(JNIEnv *env,
     {
         m_sharedResource->provisionDeviceProperties(deviceProp, devicePropProvStatusCallback);
     }
-    catch (ESBadRequestException exception)
+    catch (ESBadRequestException &exception)
     {
         ES_LOGE("JNI provisionDeviceProperties :: Exception occured");
         //throw the exception to java
-        throwESException( env,  exception.what());
+        throwESException(env, exception.what());
     }
 }
 
@@ -188,7 +188,7 @@ void JniRemoteEnrollee::provisionCloudProperties(JNIEnv *env,
     {
         m_sharedResource->provisionCloudProperties(cloudProp, cloudPropProvStatusCallback);
     }
-    catch (ESBadRequestException exception)
+    catch (ESBadRequestException &exception)
     {
         ES_LOGE("JNI startProvisioning :: Exception occured");
         //throw the exception to java
index 956fa1b..fc7e294 100644 (file)
@@ -1053,12 +1053,10 @@ namespace OIC
         {
             OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "isOwnedDeviceRegisteredInDB IN");
 
-            OCStackResult res = OC_STACK_ERROR;
-
             OCUuidList_t *uuidList = NULL;
             size_t numOfDevices = 0;
 
-            res = PDMGetOwnedDevices(&uuidList, &numOfDevices);
+            OCStackResult res = PDMGetOwnedDevices(&uuidList, &numOfDevices);
             if (OC_STACK_OK != res)
             {
                 OIC_LOG(ERROR, ENROLEE_SECURITY_TAG, "Error while getting info from DB");