Clean up compiler warnings found in provisioningclient
authorGeorge Nash <george.nash@intel.com>
Tue, 21 Feb 2017 23:40:57 +0000 (15:40 -0800)
committerKevin Kane <kkane@microsoft.com>
Wed, 8 Mar 2017 21:00:24 +0000 (21:00 +0000)
Compiler warnings fixed are:
 - unused-parameter fixed by using OC_UNUSED macro
 - type-limits fixed by changing the return type from size_t to off_t
   that is returned by the ftello function.
 - sign-compare fixed by replacing int with size_t where needed
 - format= fixed by replacing %d in printf and scanf with PRIuPTR or SCNuPTR
   from the cinttypes header.

Change-Id: I070ea24193b95ed65d8e3ea914ba8f5b69986f84
Signed-off-by: George Nash <george.nash@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17447
Reviewed-by: Kevin Kane <kkane@microsoft.com>
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
resource/provisioning/examples/provisioningclient.cpp

index d38f6b8..d7e8e29 100644 (file)
@@ -24,6 +24,7 @@
 #include <string>
 #include <map>
 #include <cstdlib>
+#include <cinttypes>
 #include <pthread.h>
 #include <mutex>
 #include <condition_variable>
@@ -121,6 +122,7 @@ void moveTransferredDevice()
 
 void OnInputPinCB(OicUuid_t deviceId, char* pinBuf, size_t bufSize)
 {
+    OC_UNUSED(deviceId);
     if(pinBuf)
     {
         std::cout <<"INPUT PIN : ";
@@ -447,7 +449,7 @@ static int InputACL(OicSecAcl_t *acl)
             printf("         Enter Number of resource type for [%s]: ", rsrc->href);
             for(int ret=0; 1!=ret; )
             {
-                ret = scanf("%d", &arrLen);
+                ret = scanf("%" SCNuPTR, &arrLen);
                 for( ; 0x20<=getchar(); );  // for removing overflow garbages
                                             // '0x20<=code' is character region
             }
@@ -466,9 +468,9 @@ static int InputACL(OicSecAcl_t *acl)
             goto error;
         }
 
-        for(int i = 0; i < arrLen; i++)
+        for(size_t i = 0; i < arrLen; i++)
         {
-            printf("         Enter ResourceType[%d] Name (e.g. core.led): ", i+1);
+            printf("         Enter ResourceType[%" PRIuPTR "] Name (e.g. core.led): ", i+1);
             for(int ret=0; 1!=ret; )
             {
                 ret = scanf("%64ms", &rsrc_in);  // '128' is ACL_RESRC_MAX_LEN
@@ -489,7 +491,7 @@ static int InputACL(OicSecAcl_t *acl)
             printf("         Enter Number of interface name for [%s]: ", rsrc->href);
             for(int ret=0; 1!=ret; )
             {
-                ret = scanf("%d", &arrLen);
+                ret = scanf("%" SCNuPTR, &arrLen);
                 for( ; 0x20<=getchar(); );  // for removing overflow garbages
                                             // '0x20<=code' is character region
             }
@@ -508,9 +510,9 @@ static int InputACL(OicSecAcl_t *acl)
             goto error;
         }
 
-        for(int i = 0; i < arrLen; i++)
+        for(size_t i = 0; i < arrLen; i++)
         {
-            printf("         Enter interfnace[%d] Name (e.g. oic.if.baseline): ", i+1);
+            printf("         Enter interfnace[%" PRIuPTR "] Name (e.g. oic.if.baseline): ", i+1);
             for(int ret=0; 1!=ret; )
             {
                 ret = scanf("%64ms", &rsrc_in);  // '128' is ACL_RESRC_MAX_LEN
@@ -817,6 +819,7 @@ PVDP_ERROR:
 
 OCStackResult displayMutualVerifNumCB(uint8_t mutualVerifNum[MUTUAL_VERIF_NUM_LEN])
 {
+    OC_UNUSED(mutualVerifNum);
     OIC_LOG(INFO, TAG, "IN displayMutualVerifNumCB");
     OIC_LOG(INFO, TAG, "############ mutualVerifNum ############");
     OIC_LOG_BUFFER(INFO, TAG, mutualVerifNum, MUTUAL_VERIF_NUM_LEN);
@@ -868,7 +871,7 @@ static int saveTrustCert(void)
 
     if (fp)
     {
-        size_t fsize;
+        off_t fsize;
         if (fseeko(fp, 0, SEEK_END) == 0 && (fsize = ftello(fp)) >= 0)
         {
             trustCertChainArray.data = (uint8_t*)OICCalloc(1, fsize);
@@ -880,8 +883,7 @@ static int saveTrustCert(void)
                 return -1;
             }
             rewind(fp);
-            fsize = fread(trustCertChainArray.data, 1, fsize, fp);
-            if(0 == fsize)
+            if (0 == fread(trustCertChainArray.data, 1, fsize, fp))
             {
                 OIC_LOG(ERROR,TAG,"Read error");
             }
@@ -901,8 +903,11 @@ static int saveTrustCert(void)
     return 0;
 }
 
-void certChainCallBack(uint16_t credId, uint8_t *trustCertChain,size_t chainSize)
+void certChainCallBack(uint16_t credId, uint8_t *trustCertChain, size_t chainSize)
 {
+    OC_UNUSED(credId);
+    OC_UNUSED(trustCertChain);
+    OC_UNUSED(chainSize);
     OIC_LOG_V(INFO, TAG, "trustCertChain Changed for credId %u", credId);
     return;
 }