1. Change OCDeleteProvisionResults() parameters
authorWoochul Shim <woochul.shim@samsung.com>
Thu, 3 Sep 2015 03:55:13 +0000 (12:55 +0900)
committerSachin Agrawal <sachin.agrawal@intel.com>
Fri, 4 Sep 2015 23:41:24 +0000 (23:41 +0000)
   - double pointer -> single pointer

2. Remove segmentation fault from unittest of provisioning
   - due to the mismatched extern definition of AddDevice

3. Change invalid usage of OC_LOG
   - OC_LOG(ERROR, ERROR, ...) -> OC_LOG(ERROR, TAG)

Change-Id: I58e627a72d43fafe98bf32120ca8354968ec1f05
Signed-off-by: Woochul Shim <woochul.shim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2361
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Sachin Agrawal <sachin.agrawal@intel.com>
resource/csdk/security/provisioning/include/ocprovisioningmanager.h
resource/csdk/security/provisioning/include/pmutility.h
resource/csdk/security/provisioning/sample/provisioningclient.c
resource/csdk/security/provisioning/src/ocprovisioningmanager.c
resource/csdk/security/provisioning/src/pmutility.c
resource/csdk/security/provisioning/unittest/pmutilitytest.cpp

index f7169c1..8a51f0a 100644 (file)
@@ -135,9 +135,9 @@ OCStackResult OCProvisionCredentials(void *ctx, OicSecCredType_t type, size_t ke
 /**\r
  * API to delete memory allocated to linked list created by OCDiscover_XXX_Devices API.\r
  *\r
- * @param[in] ppList Pointer to OCProvisionDev_t which should be deleted.\r
+ * @param[in] pList Pointer to OCProvisionDev_t which should be deleted.\r
  */\r
-void OCDeleteDiscoveredDevices(OCProvisionDev_t **ppList);\r
+void OCDeleteDiscoveredDevices(OCProvisionDev_t *pList);\r
 \r
 /**\r
  * API to delete memory allocated to OCProvisionResult_t list in callback function.\r
index ce2f69d..0904b13 100644 (file)
@@ -53,7 +53,7 @@ OCStackResult PMDeviceDiscovery(unsigned short waittime, bool isOwned, OCProvisi
  *
  * @param[in] pList         List of OCProvisionDev_t.
  */
-void DeleteDeviceList(OCProvisionDev_t **pList);
+void DeleteDeviceList(OCProvisionDev_t *pList);
 
 
 /**
index ee16b58..c1073e7 100644 (file)
@@ -566,8 +566,8 @@ int main()
 error:
     deleteACL(gAcl1);
     deleteACL(gAcl2);
-    OCDeleteDiscoveredDevices(&pDeviceList);
-    OCDeleteDiscoveredDevices(&pOwnedList);
+    OCDeleteDiscoveredDevices(pDeviceList);
+    OCDeleteDiscoveredDevices(pOwnedList);
 
     return 0;
 }
index cdef12d..df8f62c 100644 (file)
@@ -117,9 +117,9 @@ OCStackResult OCDoOwnershipTransfer(void* ctx,
  *
  * @param[in] pList Pointer to OCProvisionDev_t which should be deleted.
  */
-void OCDeleteDiscoveredDevices(OCProvisionDev_t **ppList)
+void OCDeleteDiscoveredDevices(OCProvisionDev_t *pList)
 {
-    DeleteDeviceList(ppList);
+    DeleteDeviceList(pList);
 }
 
 /**
index eac476a..fdde580 100644 (file)
@@ -87,7 +87,7 @@ OCProvisionDev_t* GetDevice(OCProvisionDev_t **ppDevicesList, const char* addr,
  * @return OC_STACK_OK for success and errorcode otherwise.
  */
 OCStackResult AddDevice(OCProvisionDev_t **ppDevicesList, const char* addr, const uint16_t port,
-                               OCTransportAdapter adapter, OCConnectivityType connType, OicSecDoxm_t *doxm)
+                        OCTransportAdapter adapter, OCConnectivityType connType, OicSecDoxm_t *doxm)
 {
     if (NULL == addr)
     {
@@ -128,8 +128,8 @@ OCStackResult AddDevice(OCProvisionDev_t **ppDevicesList, const char* addr, cons
  *
  * @return OC_STACK_OK for success and errorcode otherwise.
  */
-OCStackResult UpdateSecurePortOfDevice(OCProvisionDev_t **ppDevicesList, const char *addr, uint16_t port,
-                                        uint16_t securePort)
+OCStackResult UpdateSecurePortOfDevice(OCProvisionDev_t **ppDevicesList, const char *addr,
+                                       uint16_t port, uint16_t securePort)
 {
     OCProvisionDev_t *ptr = GetDevice(ppDevicesList, addr, port);
 
@@ -147,16 +147,16 @@ OCStackResult UpdateSecurePortOfDevice(OCProvisionDev_t **ppDevicesList, const c
 /**
  * This function deletes list of provision target devices
  *
- * @param[in] pList         List of OCProvisionDev_t.
+ * @param[in] pDevicesList         List of OCProvisionDev_t.
  */
-void DeleteDeviceList(OCProvisionDev_t **ppDevicesList)
+void DeleteDeviceList(OCProvisionDev_t *pDevicesList)
 {
-    if(*ppDevicesList)
+    if(pDevicesList)
     {
         OCProvisionDev_t *del = NULL, *tmp = NULL;
-        LL_FOREACH_SAFE(*ppDevicesList, del, tmp)
+        LL_FOREACH_SAFE(pDevicesList, del, tmp)
         {
-            LL_DELETE(*ppDevicesList, del);
+            LL_DELETE(pDevicesList, del);
 
             DeleteDoxmBinData(del->doxm);
             DeletePstatBinData(del->pstat);
@@ -286,23 +286,23 @@ bool PMGenerateQuery(bool isSecure,
                                          prefix, address, port, uri);
                     break;
                 default:
-                    OC_LOG(ERROR, ERROR, "Unknown address format.");
+                    OC_LOG(ERROR, TAG, "Unknown address format.");
                     return false;
             }
             if(snRet >= bufferSize)
             {
-                OC_LOG(ERROR, INFO, "PMGenerateQuery : URI is too long");
+                OC_LOG(ERROR, TAG, "PMGenerateQuery : URI is too long");
                 return false;
             }
             break;
         // TODO: We need to verify tinyDTLS in below cases
         case CT_ADAPTER_GATT_BTLE:
         case CT_ADAPTER_RFCOMM_BTEDR:
-            OC_LOG(ERROR, ERROR, "Not supported connectivity adapter.");
+            OC_LOG(ERROR, TAG, "Not supported connectivity adapter.");
             return false;
             break;
         default:
-            OC_LOG(ERROR, ERROR, "Unknown connectivity adapter.");
+            OC_LOG(ERROR, TAG, "Unknown connectivity adapter.");
             return false;
     }
 
index 378c606..31bdd53 100644 (file)
@@ -28,8 +28,9 @@ using namespace std;
 extern "C" {
 #endif
 
-extern OCStackResult AddDevice(OCProvisionDev_t **ppList, const char* addr, const uint16_t port,
-                               OCTransportAdapter adapter, OicSecDoxm_t *doxm);
+extern OCStackResult AddDevice(OCProvisionDev_t **ppDevicesList, const char* addr,
+                               const uint16_t port, OCTransportAdapter adapter,
+                               OCConnectivityType connType, OicSecDoxm_t *doxm);
 #ifdef __cplusplus
 }
 #endif
@@ -45,32 +46,29 @@ TEST(ProvisionListTest, Addition)
     int cnt =0;
 
     // The first addition
-    res = AddDevice(&gList, "10.20.30.40", 5684, OC_DEFAULT_ADAPTER, pDoxm);
+    res = AddDevice(&gList, "10.20.30.40", 5684, OC_DEFAULT_ADAPTER, CT_IP_USE_V4, pDoxm);
     EXPECT_TRUE(OC_STACK_OK == res);
     EXPECT_TRUE(NULL != gList);
 
     LL_FOREACH(gList,el){ ++cnt; };
-    //LL_COUNT(gList, el, cnt);
     EXPECT_TRUE(1 == cnt);
 
     // Same node must not be inserted
-    res = AddDevice(&gList, "10.20.30.40", 5684, OC_ADAPTER_IP, pDoxm);
+    res = AddDevice(&gList, "10.20.30.40", 5684, OC_ADAPTER_IP, CT_IP_USE_V4, pDoxm);
     EXPECT_TRUE(OC_STACK_OK == res);
     EXPECT_TRUE(NULL != gList);
 
     cnt = 0;
     LL_FOREACH(gList,el){ ++cnt; };
-    //LL_COUNT(gList, el, cnt);
     EXPECT_TRUE(1 == cnt);
 
     // Differnet node must be inserted
-    res = AddDevice(&gList, "110.120.130.140", 6789, OC_DEFAULT_ADAPTER, pDoxm);
+    res = AddDevice(&gList, "110.120.130.140", 6789, OC_DEFAULT_ADAPTER, CT_IP_USE_V4, pDoxm);
     EXPECT_TRUE(OC_STACK_OK == res);
     EXPECT_TRUE(NULL != gList);
 
     cnt = 0;
     LL_FOREACH(gList,el){ ++cnt; };
-    //LL_COUNT(gList, el, cnt);
     EXPECT_TRUE(2 == cnt);
 }
 
@@ -81,10 +79,9 @@ TEST(ProvisionListTest, Deletion)
     int cnt =0;
 
     // Delete whole
-    DeleteDeviceList(&gList);
+    DeleteDeviceList(gList);
     gList = NULL;
 
     LL_FOREACH(gList,el){ ++cnt; };
-    //LL_COUNT(gList, el, cnt);
     EXPECT_TRUE(0 == cnt);
 }
\ No newline at end of file