[IOT-2324]warning fix 2
authorOleksandr Dmytrenko <o.dmytrenko@samsung.com>
Thu, 18 May 2017 10:52:39 +0000 (13:52 +0300)
committerDmitriy Zhuravlev <d.zhuravlev@samsung.com>
Sat, 20 May 2017 06:42:20 +0000 (06:42 +0000)
Warning fix in resource/csdk/security/provisioning

Change-Id: I3791fa427b04ac80a7e0847d4b13e6b121f74aa5
Signed-off-by: Oleksandr Dmytrenko <o.dmytrenko@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/20039
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dmitriy Zhuravlev <d.zhuravlev@samsung.com>
resource/csdk/security/provisioning/sample/autoprovisioningclient.c
resource/csdk/security/provisioning/sample/cloud/cloudDiscovery.c
resource/csdk/security/provisioning/sample/provisioningclient.c
resource/csdk/security/provisioning/src/pmutility.c
resource/csdk/security/provisioning/src/secureresourceprovider.c
resource/csdk/security/provisioning/unittest/ocprovisioningmanager.cpp
resource/csdk/security/provisioning/unittest/secureresourceprovider.cpp

index 282f875..2dee720 100644 (file)
@@ -78,9 +78,6 @@ static const char* TEST_CERT_ROLE1 = "IoTivity-test-role1";
 static const char* TEST_CERT_ROLE2 = "IoTivity-test-role2";
 static const char* TEST_CERT_AUTHORITY = "IoTivity-test-OBT-authority-name";
 
-static OicUuid_t WILDCARD_SUBJECT_ID = { "*" };
-static size_t WILDCARD_SUBJECT_ID_LEN = 1;
-
 // |g_ctx| means provision manager application context and
 // the following, includes |un/own_list|, could be variables, which |g_ctx| has,
 // for accessing all function(s) for these, they are declared on global domain
@@ -101,7 +98,6 @@ static bool g_successCB; /* Set to true by the callback to indicate success. */
 // function declaration(s) for calling them before implementing
 static OCProvisionDev_t* getDevInst(const OCProvisionDev_t*, const int);
 static int printDevList(const OCProvisionDev_t*);
-static size_t printUuidList(const OCUuidList_t*);
 static size_t printResultList(const OCProvisionResult_t*, const size_t);
 static void printUuid(const OicUuid_t*);
 static int saveUuid(const OCProvisionResult_t* rslt_lst, const size_t rslt_cnt);
@@ -399,54 +395,6 @@ static int discoverAllDevices(void)
     return 0;
 }
 
-static int discoverUnownedDevices(void)
-{
-    // delete unowned device list before updating it
-    if(g_unown_list)
-    {
-        OCDeleteDiscoveredDevices(g_unown_list);
-        g_unown_list = NULL;
-    }
-
-    // call |OCDiscoverUnownedDevices| API
-    printf("   Discovering Only Unowned Devices on Network..\n");
-    if(OC_STACK_OK != OCDiscoverUnownedDevices(DISCOVERY_TIMEOUT, &g_unown_list))
-    {
-        OIC_LOG(ERROR, TAG, "OCDiscoverUnownedDevices API error");
-        return -1;
-    }
-
-    // display the discovered unowned list
-    printf("   > Discovered Unowned Devices\n");
-    g_unown_cnt = printDevList(g_unown_list);
-
-    return 0;
-}
-
-static int discoverOwnedDevices(void)
-{
-    // delete owned device list before updating it
-    if(g_own_list)
-    {
-        OCDeleteDiscoveredDevices(g_own_list);
-        g_own_list = NULL;
-    }
-
-    // call |OCDiscoverOwnedDevices| API
-    printf("   Discovering Only Owned Devices on Network..\n");
-    if(OC_STACK_OK != OCDiscoverOwnedDevices(DISCOVERY_TIMEOUT, &g_own_list))
-    {
-        OIC_LOG(ERROR, TAG, "OCDiscoverOwnedDevices API error");
-        return -1;
-    }
-
-    // display the discovered owned list
-    printf("   > Discovered Owned Devices\n");
-    g_own_cnt = printDevList(g_own_list);
-
-    return 0;
-}
-
 static int registerDevices(void)
 {
     // check |unown_list| for registering devices
@@ -509,7 +457,7 @@ static int provisionTrustAnchor(int dev_num)
     g_doneCB = false;
     OicSecCredType_t type = SIGNED_ASYMMETRIC_KEY;
 
-    rst = OCProvisionTrustCertChain((void*)g_ctx, type, caCredId, targetDevice, &provisionTrustChainCB);
+    rst = OCProvisionTrustCertChain((void*)g_ctx, type, caCredId, targetDevice, (OCProvisionResultCB)&provisionTrustChainCB);
     if(OC_STACK_OK != rst)
     {
         OIC_LOG_V(ERROR, TAG, "OCProvisionTrustCertChain returned error: %d", rst);
@@ -564,7 +512,7 @@ static int getCsr(int dev_num, char** csr)
     if(rst != OC_STACK_OK)
     {
         OIC_LOG(ERROR, TAG, "Failed to validate CSR signature");
-        OICFreeAndSetToNull(&g_csr);
+        OICFreeAndSetToNull((void**)&g_csr);
         return -1;
     }
 
@@ -574,12 +522,12 @@ static int getCsr(int dev_num, char** csr)
         if (*csr == NULL)
         {
             OIC_LOG(ERROR, TAG, "OICStrdup failed");
-            OICFreeAndSetToNull(&g_csr);
+            OICFreeAndSetToNull((void**)&g_csr);
             return -1;
         }
     }
 
-    OICFreeAndSetToNull(&g_csr);
+    OICFreeAndSetToNull((void**)&g_csr);
 
     printf("   > Get CSR SUCCEEDED\n");
 
@@ -1280,7 +1228,7 @@ static int testRoleProvisioning(int dev_num)
         OIC_LOG_V(ERROR, TAG, "%s Failed to provision role certificate", __func__);
         goto exit;
     }
-    OICFreeAndSetToNull(&roleCert);
+    OICFreeAndSetToNull((void**)&roleCert);
 
     /* The second will have the authority field set */
     ret = createCertFromCSR(g_caKeyPem, g_caCertPem, csr, TEST_CERT_ROLE2, TEST_CERT_AUTHORITY, &roleCert);
@@ -1728,28 +1676,6 @@ static int printDevList(const OCProvisionDev_t* dev_lst)
     return lst_cnt;
 }
 
-static size_t printUuidList(const OCUuidList_t* uid_lst)
-{
-    if (!uid_lst)
-    {
-        printf("     Device List is Empty..\n\n");
-        return 0;
-    }
-
-    OCUuidList_t* lst = (OCUuidList_t*)uid_lst;
-    size_t lst_cnt = 0;
-    for (; lst; )
-    {
-        printf("     [%zu] ", ++lst_cnt);
-        printUuid((const OicUuid_t*)&lst->dev);
-        printf("\n");
-        lst = lst->next;
-    }
-    printf("\n");
-
-    return lst_cnt;
-}
-
 static size_t printResultList(const OCProvisionResult_t* rslt_lst, const size_t rslt_cnt)
 {
     if (!rslt_lst || (0 == rslt_cnt))
@@ -1841,8 +1767,8 @@ void shutdownProvisionClient()
     OCDeleteDiscoveredDevices(g_own_list);  // after here |g_own_list| points to nothing
     OCDeleteDiscoveredDevices(g_unown_list);  // after here |g_unown_list| points to nothing
 
-    OICFreeAndSetToNull(&g_svr_fname);
-    OICFreeAndSetToNull(&g_prvn_fname);
+    OICFreeAndSetToNull((void**)&g_svr_fname);
+    OICFreeAndSetToNull((void**)&g_prvn_fname);
 }
 
 static int initDiscoverRegisterAllDevices()
index 977d151..34376fd 100644 (file)
@@ -1,24 +1,22 @@
-/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- */
+//******************************************************************
+//
+// Copyright 2016 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 #include "ocstack.h"
 #include "logger.h"
 #include "ocpayload.h"
index 8d9d180..04277a7 100644 (file)
@@ -1121,7 +1121,7 @@ static int provisionCert(void)
     g_doneCB = false;
     OicSecCredType_t type = SIGNED_ASYMMETRIC_KEY;
 
-    OCStackResult rst = OCProvisionTrustCertChain((void*)g_ctx, type, g_caCredId, targetDevice, &provisionTrustChainCB);
+    OCStackResult rst = OCProvisionTrustCertChain((void*)g_ctx, type, g_caCredId, targetDevice, (OCProvisionResultCB)&provisionTrustChainCB);
     if (OC_STACK_OK != rst)
     {
         OIC_LOG_V(ERROR, TAG, "OCProvisionTrustCertChain returned error: %d", rst);
@@ -1161,14 +1161,14 @@ static int provisionCert(void)
     if (OC_STACK_OK != rst)
     {
         OIC_LOG(ERROR, TAG, "Failed to validate CSR signature");
-        OICFreeAndSetToNull(&g_csr);
+        OICFreeAndSetToNull((void**)&g_csr);
         return -1;
     }
 
     printf("   > Creating a certificate for the device..\n");
     char* deviceCert;
     int ret = createIdentityCertFromCSR(g_caKeyPem, g_caCertPem, g_csr, &deviceCert);
-    OICFreeAndSetToNull(&g_csr);
+    OICFreeAndSetToNull((void**)&g_csr);
     if (ret != 0)
     {
         OIC_LOG(ERROR, TAG, "Failed to generate certificate");
@@ -1346,7 +1346,7 @@ static int provisionDirectPairing(void)
     printf("   Atempt Direct-Pairing Provisioning (PIN : [%s])..\n", (char*)pconf.pin.val);
     OCStackResult rst = OCProvisionDirectPairing((void*) g_ctx,
                                        getDevInst((const OCProvisionDev_t*) g_own_list, dev_num),
-                                       &pconf, provisionDPCB);
+                                       &pconf, (OCProvisionResultCB)provisionDPCB);
     if(OC_STACK_OK != rst)
     {
         OIC_LOG_V(ERROR, TAG, "OCProvisionDirectPairing API error: %d", rst);
index f57095a..6224074 100644 (file)
@@ -49,8 +49,6 @@
 
 #include "srmutility.h"
 
-static const unsigned int USECS_PER_MSEC = 1000;
-
 #define TAG ("OIC_PM_UTILITY")
 
 typedef struct _DiscoveryInfo{
index 0305fee..f47b618 100644 (file)
@@ -1355,7 +1355,7 @@ static OCStackResult SendDeleteCredentialRequest(void* ctx,
                     //coaps://0.0.0.0:5684/oic/sec/cred?subjectid=(Canonical ENCODED UUID)
     const char *srpUri = SRP_FORM_DELETE_CREDENTIAL;
 #ifdef __WITH_TLS__
-    if(CA_ADAPTER_TCP == destDev->endpoint.adapter)
+    if((int)CA_ADAPTER_TCP == (int)destDev->endpoint.adapter)
     {
         srpUri = SRP_FORM_DELETE_CREDENTIAL_TCP;
     }
@@ -2905,7 +2905,7 @@ static void registerResultForGetCSRResourceCB(GetCsrData_t *getCsrData,
      */
     OCPMGetCsrResult_t* currentEntry = &getCsrData->resArr[getCsrData->numOfResults];
     OIC_LOG_V(INFO, TAG, "Inside registerResultForGetCSRResourceCB "
-        "getCsrData->numOfResults is %d\n", getCsrData->numOfResults);
+        "getCsrData->numOfResults is %zu\n", getCsrData->numOfResults);
     memcpy(currentEntry->deviceId.id,
         getCsrData->deviceInfo->doxm->deviceID.id, UUID_LENGTH);
     currentEntry->res = stackresult;
@@ -3050,7 +3050,7 @@ static void registerResultForGetRolesResourceCB(GetRolesData_t *getRolesData,
      */
     OCPMGetRolesResult_t* currentEntry = &getRolesData->resArr[getRolesData->numOfResults];
     OIC_LOG_V(INFO, TAG, "Inside registerResultForGetCSRResourceCB "
-        "getRolesData->numOfResults is %d\n", getRolesData->numOfResults);
+        "getRolesData->numOfResults is %zu\n", getRolesData->numOfResults);
     memcpy(currentEntry->deviceId.id,
         getRolesData->deviceInfo->doxm->deviceID.id, UUID_LENGTH);
     currentEntry->res = stackresult;
index e87fad0..a7ae14a 100644 (file)
@@ -39,6 +39,7 @@ static OicSecDoxm_t defaultDoxm1 =
     {{0}},            /* OicUuid_t deviceID */
     false,                  /* bool dpc */
     {{0}},            /* OicUuid_t owner */
+    {{0}}           /* rownerID */
 };
 
 static OicSecDoxm_t defaultDoxm2 =
@@ -53,6 +54,7 @@ static OicSecDoxm_t defaultDoxm2 =
     {{0}},            /* OicUuid_t deviceID */
     false,                  /* bool dpc */
     {{0}},            /* OicUuid_t owner */
+    {{0}}           /* rownerID */
 };
 
 static void provisioningCB (void* UNUSED1, size_t UNUSED2, OCProvisionResult_t *UNUSED3, bool UNUSED4)
index dbfb11a..8bf1435 100644 (file)
@@ -41,6 +41,7 @@ static OicSecDoxm_t defaultDoxm1 =
     {{0}},            /* OicUuid_t deviceID */
     false,                  /* bool dpc */
     {{0}},            /* OicUuid_t owner */
+    {{0}}           /* rownerID */
 };
 
 static OicSecDoxm_t defaultDoxm2 =
@@ -55,6 +56,7 @@ static OicSecDoxm_t defaultDoxm2 =
     {{0}},            /* OicUuid_t deviceID */
     false,                  /* bool dpc */
     {{0}},            /* OicUuid_t owner */
+    {{0}}           /* rownerID */
 };
 
 static void provisioningCB (void* UNUSED1, size_t UNUSED2, OCProvisionResult_t *UNUSED3, bool UNUSED4)