From 910587285c5f773a0c77be375fbb420245123be4 Mon Sep 17 00:00:00 2001 From: Ossama Othman Date: Wed, 26 Oct 2016 13:44:53 -0700 Subject: [PATCH] Addressed format specifier, unused variable, etc, build warnings. Change-Id: I8ccfc5e185cfea2555ac5337eb2afa897f1984e4 Signed-off-by: Ossama Othman Reviewed-on: https://gerrit.iotivity.org/gerrit/13725 Tested-by: jenkins-iotivity Reviewed-by: Thiago Macieira Reviewed-by: David Antler Reviewed-by: Habib Virji (cherry picked from commit 329265241170fa97589cc9dd39131886267ad93e) Reviewed-on: https://gerrit.iotivity.org/gerrit/13819 --- .../src/adapter_util/cafragmentation.c | 2 +- .../connectivity/src/bt_le_adapter/caleadapter.c | 24 +++++++++++----------- resource/csdk/stack/src/ocresource.c | 4 ++-- resource/include/StringConstants.h | 2 ++ resource/src/OCException.cpp | 4 ++++ resource/unittests/OCExceptionTest.cpp | 8 ++++++-- 6 files changed, 27 insertions(+), 17 deletions(-) diff --git a/resource/csdk/connectivity/src/adapter_util/cafragmentation.c b/resource/csdk/connectivity/src/adapter_util/cafragmentation.c index dc51dd4..67a6aab 100644 --- a/resource/csdk/connectivity/src/adapter_util/cafragmentation.c +++ b/resource/csdk/connectivity/src/adapter_util/cafragmentation.c @@ -84,7 +84,7 @@ CAResult_t CAGenerateVariableForFragmentation(size_t dataLength, size_t *remainingLen, size_t *totalLength) { - OIC_LOG_V(DEBUG, TAG, "IN, dataLength = %d", dataLength); + OIC_LOG_V(DEBUG, TAG, "IN, dataLength = %zu", dataLength); size_t remainDataSize = 0; size_t dataOnlyLen = diff --git a/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c b/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c index e96e5a1..04703a9 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c +++ b/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c @@ -898,7 +898,7 @@ static void CALEDataReceiverHandler(void *threadData) bleData->dataLen - (CA_BLE_HEADER_SIZE + CA_BLE_LENGTH_HEADER_SIZE); OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "Total data to be accumulated [%u] bytes", newSender->totalDataLen); - OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "data received in the first packet [%u] bytes", + OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "data received in the first packet [%zu] bytes", dataOnlyLen); newSender->defragData = OICCalloc(newSender->totalDataLen + 1, @@ -965,7 +965,7 @@ static void CALEDataReceiverHandler(void *threadData) if (senderInfo->recvDataLen + dataOnlyLen > senderInfo->totalDataLen) { OIC_LOG_V(ERROR, CALEADAPTER_TAG, - "Data Length exceeding error!! Receiving [%d] total length [%d]", + "Data Length exceeding error!! Receiving [%zu] total length [%u]", senderInfo->recvDataLen + dataOnlyLen, senderInfo->totalDataLen); u_arraylist_remove(bleData->senderInfo, senderIndex); OICFree(senderInfo->defragData); @@ -973,7 +973,7 @@ static void CALEDataReceiverHandler(void *threadData) ca_mutex_unlock(g_bleReceiveDataMutex); return; } - OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "Copying the data of length [%d]", + OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "Copying the data of length [%zu]", dataOnlyLen); memcpy(senderInfo->defragData + senderInfo->recvDataLen, bleData->data + CA_BLE_HEADER_SIZE, @@ -1049,12 +1049,12 @@ static void CALEServerSendDataThread(void *threadData) } OIC_LOG_V(DEBUG, CALEADAPTER_TAG, - "Packet info: data size[%d] midPacketCount[%d] remainingLen[%d] totalLength[%d]", + "Packet info: data size[%d] midPacketCount[%u] remainingLen[%zu] totalLength[%zu]", bleData->dataLen, midPacketCount, remainingLen, totalLength); OIC_LOG_V(DEBUG, CALEADAPTER_TAG, - "Server total Data length with header is [%u]", + "Server total Data length with header is [%zu]", totalLength); uint8_t dataSegment[CA_SUPPORTED_BLE_MTU_SIZE] = {0}; @@ -1247,7 +1247,7 @@ static void CALEServerSendDataThread(void *threadData) return; } OIC_LOG_V(DEBUG, CALEADAPTER_TAG, - "Server Sent data length [%d]", remainingLen + CA_BLE_HEADER_SIZE); + "Server Sent data length [%zu]", remainingLen + CA_BLE_HEADER_SIZE); } } else @@ -1342,7 +1342,7 @@ static void CALEServerSendDataThread(void *threadData) return; } OIC_LOG_V(DEBUG, CALEADAPTER_TAG, - "Server Sent data length [%d]", remainingLen + CA_BLE_HEADER_SIZE); + "Server Sent data length [%zu]", remainingLen + CA_BLE_HEADER_SIZE); } } @@ -1379,7 +1379,7 @@ static void CALEClientSendDataThread(void *threadData) } OIC_LOG_V(DEBUG, CALEADAPTER_TAG, - "Packet info: data size[%d] midPacketCount[%d] remainingLen[%d] totalLength[%d]", + "Packet info: data size[%d] midPacketCount[%u] remainingLen[%zu] totalLength[%zu]", bleData->dataLen, midPacketCount, remainingLen, totalLength); uint8_t dataSegment[CA_SUPPORTED_BLE_MTU_SIZE] = {0}; @@ -1567,7 +1567,7 @@ static void CALEClientSendDataThread(void *threadData) return; } OIC_LOG_V(DEBUG, CALEADAPTER_TAG, - "Client Sent Data length is [%d]", remainingLen + CA_BLE_HEADER_SIZE); + "Client Sent Data length is [%zu]", remainingLen + CA_BLE_HEADER_SIZE); } } else @@ -1664,7 +1664,7 @@ static void CALEClientSendDataThread(void *threadData) return; } OIC_LOG_V(DEBUG, CALEADAPTER_TAG, - "Client Sent Data length is [%d]", remainingLen + CA_BLE_HEADER_SIZE); + "Client Sent Data length is [%zu]", remainingLen + CA_BLE_HEADER_SIZE); } } @@ -3374,7 +3374,7 @@ static void CALERemoveReceiveQueueData(u_arraylist_t *dataInfoList, const char* uint32_t arrayLength = u_arraylist_length(portList); for (uint32_t i = 0; i < arrayLength; i++) { - uint16_t port = u_arraylist_get(portList, i); + uint16_t port = (uint16_t)(uintptr_t)u_arraylist_get(portList, i); OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "port : %X", port); if (CA_STATUS_OK == CALEGetSenderInfo(address, port, @@ -3419,7 +3419,7 @@ static CAResult_t CALEGetPortsFromSenderInfo(const char *leAddress, if (!strncmp(info->remoteEndpoint->addr, leAddress, addrLength)) { - u_arraylist_add(portList, (void *)info->remoteEndpoint->port); + u_arraylist_add(portList, (void *)(uintptr_t)info->remoteEndpoint->port); } } diff --git a/resource/csdk/stack/src/ocresource.c b/resource/csdk/stack/src/ocresource.c index 6b8c542..1a6c830 100755 --- a/resource/csdk/stack/src/ocresource.c +++ b/resource/csdk/stack/src/ocresource.c @@ -698,10 +698,8 @@ static OCStackResult HandleVirtualResource (OCServerRequest *request, OCResource discoveryResult = getQueryParamsForFiltering (virtualUriInRequest, request->query, &interfaceQuery, &resourceTypeQuery); - bool interfaceQueryAllocated = false; if (!interfaceQuery && !resourceTypeQuery) { - interfaceQueryAllocated = true; interfaceQuery = OICStrdup(OC_RSRVD_INTERFACE_LL); } @@ -1013,6 +1011,8 @@ HandleResourceWithEntityHandler (OCServerRequest *request, OCResource *resource, uint8_t collectionResource) { + OC_UNUSED(collectionResource); + if(!request || ! resource) { return OC_STACK_INVALID_PARAM; diff --git a/resource/include/StringConstants.h b/resource/include/StringConstants.h index 44e1178..b0a111f 100644 --- a/resource/include/StringConstants.h +++ b/resource/include/StringConstants.h @@ -125,6 +125,8 @@ namespace OC static const char INCONSISTENT_DB[] = "Data in provisioning DB is inconsistent"; static const char AUTHENTICATION_FAILURE[] = "Authentication failure"; static const char PUBLISH_RESOURCE_FAILED[] = "Publish Resource failure"; + static const char FORBIDDEN_REQ[] = "Forbidden request"; + static const char INTERNAL_SERVER_ERROR[] = "Internal server error"; } namespace Error diff --git a/resource/src/OCException.cpp b/resource/src/OCException.cpp index 419b8f5..a8d2d5d 100644 --- a/resource/src/OCException.cpp +++ b/resource/src/OCException.cpp @@ -109,6 +109,10 @@ std::string OC::OCException::reason(const OCStackResult sr) return OC::Exception::INCONSISTENT_DB; case OC_STACK_AUTHENTICATION_FAILURE: return OC::Exception::AUTHENTICATION_FAILURE; + case OC_STACK_FORBIDDEN_REQ: + return OC::Exception::FORBIDDEN_REQ; + case OC_STACK_INTERNAL_SERVER_ERROR: + return OC::Exception::INTERNAL_SERVER_ERROR; } return OC::Exception::UNKNOWN_ERROR; diff --git a/resource/unittests/OCExceptionTest.cpp b/resource/unittests/OCExceptionTest.cpp index 934073e..f3fe50e 100644 --- a/resource/unittests/OCExceptionTest.cpp +++ b/resource/unittests/OCExceptionTest.cpp @@ -73,7 +73,9 @@ namespace OC OC_STACK_PDM_IS_NOT_INITIALIZED, OC_STACK_DUPLICATE_UUID, OC_STACK_INCONSISTENT_DB, - OC_STACK_AUTHENTICATION_FAILURE + OC_STACK_AUTHENTICATION_FAILURE, + OC_STACK_FORBIDDEN_REQ, + OC_STACK_INTERNAL_SERVER_ERROR }; std::string resultMessages[]= @@ -118,7 +120,9 @@ namespace OC OC::Exception::PDM_DB_NOT_INITIALIZED, OC::Exception::DUPLICATE_UUID, OC::Exception::INCONSISTENT_DB, - OC::Exception::AUTHENTICATION_FAILURE + OC::Exception::AUTHENTICATION_FAILURE, + OC::Exception::FORBIDDEN_REQ, + OC::Exception::INTERNAL_SERVER_ERROR }; TEST(OCExceptionTest, ReasonCodeMatches) { -- 2.7.4