From: Erich Keane Date: Tue, 17 Mar 2015 22:19:38 +0000 (-0700) Subject: Fixed build warnings in stack X-Git-Tag: 1.2.0+RC1~1855^2~82 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0a3fd6601426db022f127d9d5bb7f0d1f6630502;p=platform%2Fupstream%2Fiotivity.git Fixed build warnings in stack OCException's string handling was missing a few items. ocstack used some creative casting to get a 16 bit value out of an 8 bit array that could likely result in bad-optimizations or undefined behavior. Removed an unused variable. Change-Id: I9af5d22f450f72d15b793cec57630e8c81f7b5de Signed-off-by: Erich Keane Reviewed-on: https://gerrit.iotivity.org/gerrit/496 Tested-by: jenkins-iotivity Reviewed-by: Sachin Agrawal Reviewed-by: Sashi Penta --- diff --git a/resource/csdk/stack/src/occollection.c b/resource/csdk/stack/src/occollection.c index 2156ee4..fd18359 100644 --- a/resource/csdk/stack/src/occollection.c +++ b/resource/csdk/stack/src/occollection.c @@ -26,6 +26,8 @@ #include "logger.h" #include "ocmalloc.h" #include "cJSON.h" +#include "ocmalloc.h" + /// Module Name #include diff --git a/resource/csdk/stack/src/ocstack.c b/resource/csdk/stack/src/ocstack.c index 7a2cee4..6e2427f 100644 --- a/resource/csdk/stack/src/ocstack.c +++ b/resource/csdk/stack/src/ocstack.c @@ -121,7 +121,8 @@ static OCStackResult OCBuildIPv4Address(uint8_t a, uint8_t b, uint8_t c, uint8_t ipAddr->addr[1] = b; ipAddr->addr[2] = c; ipAddr->addr[3] = d; - *((uint16_t*)&(ipAddr->addr[4])) = port; + ipAddr->addr[4] = (uint8_t)port; + ipAddr->addr[5] = (uint8_t)(port >> 8); return OC_STACK_OK; } @@ -3067,8 +3068,6 @@ OCStackResult initResources() */ void insertResource(OCResource *resource) { - OCResource *pointer = NULL; - if (!headResource) { headResource = resource; tailResource = resource; @@ -3612,7 +3611,7 @@ int32_t OCDevAddrToPort(OCDevAddr *ipAddr, uint16_t *port) return OC_STACK_INVALID_PARAM; } - *port = *((uint16_t*)&ipAddr->addr[4]); + *port = (ipAddr->addr[5]<< 8) | ipAddr->addr[4]; return OC_STACK_OK; } diff --git a/resource/include/StringConstants.h b/resource/include/StringConstants.h index 355b6a7..4bb245b 100644 --- a/resource/include/StringConstants.h +++ b/resource/include/StringConstants.h @@ -74,6 +74,8 @@ namespace OC static const char INVALID_OBESERVE[] = "Invalid Observe Param"; static const char NO_MEMORY[] = "No Memory"; static const char COMM_ERROR[] = "Communication Error"; + static const char TIMEOUT[] = "Timeout"; + static const char ADAPTER_NOT_ENABLED[] = "Adapter Not Enabled"; static const char NOT_IMPL[] = "Not Implemented"; static const char NOT_FOUND[] = "Resource Not Found"; static const char RESOURCE_ERROR[] = "Resource Error"; diff --git a/resource/src/OCException.cpp b/resource/src/OCException.cpp index 104ce42..64d1cfd 100644 --- a/resource/src/OCException.cpp +++ b/resource/src/OCException.cpp @@ -51,6 +51,10 @@ std::string OC::OCException::reason(const OCStackResult sr) return OC::Exception::NO_MEMORY; case OC_STACK_COMM_ERROR: return OC::Exception::COMM_ERROR; + case OC_STACK_TIMEOUT: + return OC::Exception::TIMEOUT; + case OC_STACK_ADAPTER_NOT_ENABLED: + return OC::Exception::ADAPTER_NOT_ENABLED; case OC_STACK_NOTIMPL: return OC::Exception::NOT_IMPL; case OC_STACK_NO_RESOURCE: