From: George Nash Date: Tue, 21 Feb 2017 23:40:57 +0000 (-0800) Subject: Clean up compiler warnings found in provisioningclient X-Git-Tag: 1.3.0~514 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7ffc0239eacefa7078bc2a5536e4d4a63d7eb152;p=platform%2Fupstream%2Fiotivity.git Clean up compiler warnings found in provisioningclient 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 Reviewed-on: https://gerrit.iotivity.org/gerrit/17447 Reviewed-by: Kevin Kane Tested-by: jenkins-iotivity --- diff --git a/resource/provisioning/examples/provisioningclient.cpp b/resource/provisioning/examples/provisioningclient.cpp index d38f6b8..d7e8e29 100644 --- a/resource/provisioning/examples/provisioningclient.cpp +++ b/resource/provisioning/examples/provisioningclient.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -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; }