Fix build warnings
authorSakthivel Samidurai <sakthivel.samidurai@intel.com>
Mon, 26 Jan 2015 20:06:33 +0000 (17:06 -0300)
committerSudarshan Prasad <sudarshan.prasad@intel.com>
Sat, 31 Jan 2015 20:31:15 +0000 (20:31 +0000)
Fix all build warnings in the CA branch. Build warnings due to
different pointer types for token, endpoint, and request info.

Change-Id: Ia29f8cb6f020457985ed1d6138e633eec412395e
Signed-off-by: Sakthivel Samidurai <sakthivel.samidurai@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/259
Reviewed-by: Erich Keane <erich.keane@intel.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Sudarshan Prasad <sudarshan.prasad@intel.com>
14 files changed:
resource/csdk/occoap/src/occoap.c
resource/csdk/occoap/src/occoaphelper.c
resource/csdk/stack/include/internal/occlientcb.h
resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/ocserverslow.cpp
resource/csdk/stack/src/occlientcb.c
resource/csdk/stack/src/ocobserve.c
resource/csdk/stack/src/ocserverrequest.c
resource/csdk/stack/src/ocstack.c
resource/examples/roomserver.cpp
resource/examples/simpleserver.cpp
resource/include/StringConstants.h
resource/src/OCException.cpp
resource/src/OCResource.cpp

index fe7c5f7..412b8af 100644 (file)
@@ -107,7 +107,7 @@ static void HandleCoAPAckRst(struct coap_context_t * ctx, uint8_t msgType,
                 OC_LOG_V(DEBUG, TAG,
                         "Received RST, removing all queues associated with Token %d bytes",
                         CA_MAX_TOKEN_LEN);
-                OC_LOG_BUFFER(INFO, TAG, sentToken, CA_MAX_TOKEN_LEN);
+                OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)sentToken, CA_MAX_TOKEN_LEN);
                 coap_cancel_all_messages(ctx, &sentQueue->remote, (unsigned char *)sentToken,
                         CA_MAX_TOKEN_LEN);
 #else
index d6622a2..3a5c861 100644 (file)
@@ -576,7 +576,7 @@ GenerateCoAPPdu(uint8_t msgType, uint8_t code, unsigned short id,
         VERIFY_NON_NULL(pdu);
 #ifdef CA_INT
         pdu->hdr->token_length = CA_MAX_TOKEN_LEN;
-        if (!coap_add_token(pdu, CA_MAX_TOKEN_LEN, *token))
+        if (!coap_add_token(pdu, CA_MAX_TOKEN_LEN, (const unsigned char *)*token))
         {
             OC_LOG(FATAL, TAG, PCF("coap_add_token failed"));
         }
index aeb4394..7ee14b8 100644 (file)
@@ -143,7 +143,7 @@ void DeleteClientCB(ClientCB *cbNode);
  */
 //------------------------------------------------------------------------
 #ifdef CA_INT
-ClientCB* GetClientCB(CAToken_t * token, OCDoHandle handle, const unsigned char * requestUri);
+ClientCB* GetClientCB(const CAToken_t * token, OCDoHandle handle, const unsigned char * requestUri);
 #else // CA_INT
 ClientCB* GetClientCB(OCCoAPToken * token, OCDoHandle handle, const unsigned char * requestUri);
 #endif // CA_INT
index 62a2065..fe363cf 100644 (file)
@@ -33,9 +33,14 @@ static int UNICAST_DISCOVERY = 0;
 static int TEST_CASE = 0;
 static const char * TEST_APP_UNICAST_DISCOVERY_QUERY = "coap://0.0.0.0:5683/oc/core";
 static const char * TEST_APP_UNICAST_DEVICE_DISCOVERY_QUERY = "coap://0.0.0.0:5683/oc/core/d";
-static const char * TEST_APP_MULTICAST_DEVICE_DISCOVERY_QUERY = "coap://224.0.1.187:5683/oc/core/d";
+
 #ifdef CA_INT
 static const char * MULTICAST_DEVICE_DISCOVERY_QUERY = "/oc/core/d";
+#else //CA_INT
+static const char * TEST_APP_MULTICAST_DEVICE_DISCOVERY_QUERY = "coap://224.0.1.187:5683/oc/core/d";
+#endif //CA_INT
+
+#ifdef CA_INT
 static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oc/core";
 //The following variable determines the interface (wifi, ethernet etc.)
 //to be used for sending unicast messages. Default set to WIFI.
index e1184e1..cd600bb 100644 (file)
@@ -38,9 +38,7 @@ static std::list<OCEntityHandlerRequest *> gRequestList;
 static constexpr unsigned int SLOW_RESPONSE_DELAY_SEC = 5;
 
 static LEDResource LED;
-// This variable determines instance number of the LED resource.
-// Used by POST method to create a new instance of LED resource.
-static unsigned int gCurrLedInstance = 0;
+
 static constexpr unsigned int SAMPLE_MAX_NUM_POST_INSTANCE = 2;
 static LEDResource gLedInstance[SAMPLE_MAX_NUM_POST_INSTANCE];
 
index 5896d79..509b5f1 100644 (file)
@@ -121,7 +121,7 @@ void DeleteClientCB(ClientCB * cbNode) {
         OC_LOG(INFO, TAG, PCF("deleting tokens"));
 #ifdef CA_INT
         CADestroyToken (cbNode->token);
-        OC_LOG_BUFFER(INFO, TAG, cbNode->token, CA_MAX_TOKEN_LEN);
+        OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)cbNode->token, CA_MAX_TOKEN_LEN);
 #else
         OC_LOG_BUFFER(INFO, TAG, cbNode->token.token, cbNode->token.tokenLength);
 #endif // CA_INT
@@ -156,7 +156,7 @@ void DeleteClientCB(ClientCB * cbNode) {
 }
 
 #ifdef CA_INT
-ClientCB* GetClientCB(CAToken_t * token, OCDoHandle handle, const unsigned char * requestUri)
+ClientCB* GetClientCB(const CAToken_t * token, OCDoHandle handle, const unsigned char * requestUri)
 #else // CA_INT
 ClientCB* GetClientCB(OCCoAPToken * token, OCDoHandle handle, const unsigned char * requestUri)
 #endif // CA_INT
@@ -166,8 +166,8 @@ ClientCB* GetClientCB(OCCoAPToken * token, OCDoHandle handle, const unsigned cha
         LL_FOREACH(cbList, out) {
             OC_LOG(INFO, TAG, PCF("comparing tokens"));
 #ifdef CA_INT
-            OC_LOG_BUFFER(INFO, TAG, *token, CA_MAX_TOKEN_LEN);
-            OC_LOG_BUFFER(INFO, TAG, out->token, CA_MAX_TOKEN_LEN);
+            OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)*token, CA_MAX_TOKEN_LEN);
+            OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)out->token, CA_MAX_TOKEN_LEN);
             if(memcmp(out->token, *token, CA_MAX_TOKEN_LEN) == 0)
             {
                 return out;
index 7e17023..f167da3 100644 (file)
@@ -410,8 +410,8 @@ ResourceObserver* GetObserverUsingToken (const OCCoAPToken * token)
         {
 #ifdef CA_INT
             OC_LOG(INFO, TAG,PCF("comparing tokens"));
-            OC_LOG_BUFFER(INFO, TAG, token, CA_MAX_TOKEN_LEN);
-            OC_LOG_BUFFER(INFO, TAG, out->token, CA_MAX_TOKEN_LEN);
+            OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)token, CA_MAX_TOKEN_LEN);
+            OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)out->token, CA_MAX_TOKEN_LEN);
             if((memcmp(out->token, *token, CA_MAX_TOKEN_LEN) == 0))
             {
                 return out;
@@ -445,7 +445,7 @@ OCStackResult DeleteObserverUsingToken (OCCoAPToken * token)
     {
         OC_LOG_V(INFO, TAG, PCF("deleting tokens"));
 #ifdef CA_INT
-        OC_LOG_BUFFER(INFO, TAG, obsNode->token, CA_MAX_TOKEN_LEN);
+        OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)obsNode->token, CA_MAX_TOKEN_LEN);
 #else
         OC_LOG_BUFFER(INFO, TAG, obsNode->token.token, obsNode->token.tokenLength);
 #endif
index 70bc75b..b9ee789 100644 (file)
@@ -47,8 +47,8 @@ OCServerRequest * GetServerRequestUsingToken (const OCCoAPToken token)
     {
 #ifdef CA_INT
         OC_LOG(INFO, TAG,PCF("comparing tokens"));
-        OC_LOG_BUFFER(INFO, TAG, token, CA_MAX_TOKEN_LEN);
-        OC_LOG_BUFFER(INFO, TAG, out->requestToken, CA_MAX_TOKEN_LEN);
+        OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)token, CA_MAX_TOKEN_LEN);
+        OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)out->requestToken, CA_MAX_TOKEN_LEN);
         if(memcmp(out->requestToken, token, CA_MAX_TOKEN_LEN) == 0)
         {
             return out;
index 740908a..66e574d 100644 (file)
@@ -40,6 +40,7 @@
 #ifdef CA_INT
     #include "cacommon.h"
     #include "cainterface.h"
+    #include <arpa/inet.h>
 #endif
 
 
@@ -86,7 +87,6 @@ OCStackResult getQueryFromUri(const char * uri, unsigned char** resourceType, ch
 //TODO: we should allow the server to define this
 #define MAX_OBSERVE_AGE (0x2FFFFUL)
 
-
 //-----------------------------------------------------------------------------
 // Internal API function
 //-----------------------------------------------------------------------------
@@ -283,6 +283,7 @@ OCStackResult UpdateResponseAddr(OCClientResponse *response, const CARemoteEndpo
 {
     struct sockaddr_in sa;
     OCStackResult ret = OC_STACK_INVALID_PARAM;
+
     if (!endPoint)
     {
         OC_LOG(ERROR, TAG, PCF("CA Remote end-point is NULL!"));
@@ -383,7 +384,7 @@ OCStackResult HandlePresenceResponse(const CARemoteEndpoint_t* endPoint,
     snprintf(fullUri, MAX_URI_LENGTH, "coap://%s:%u%s", ipAddress, endPoint->addressInfo.IP.port,
                 OC_PRESENCE_URI);
 
-    cbNode = GetClientCB(NULL, NULL, fullUri);
+    cbNode = GetClientCB(NULL, NULL, (unsigned char *)fullUri);
 
     if(cbNode)
     {
@@ -392,7 +393,7 @@ OCStackResult HandlePresenceResponse(const CARemoteEndpoint_t* endPoint,
     else
     {
         snprintf(fullUri, MAX_URI_LENGTH, "%s%s", OC_MULTICAST_IP, endPoint->resourceUri);
-        cbNode = GetClientCB(NULL, NULL, fullUri);
+        cbNode = GetClientCB(NULL, NULL, (unsigned char *)fullUri);
         if(cbNode)
         {
             multicastPresenceSubscribe = 1;
@@ -613,9 +614,8 @@ void HandleCAResponses(const CARemoteEndpoint_t* endPoint, const CAResponseInfo_
                  &(responseInfo->info.options[i]), sizeof(OCHeaderOption));
             }
         }
-        result = cbNode->callBack(cbNode->context,
-                cbNode->handle, &response);
-        if (result == OC_STACK_DELETE_TRANSACTION)
+        if (cbNode->callBack(cbNode->context,
+                cbNode->handle, &response) == OC_STACK_DELETE_TRANSACTION)
         {
             FindAndDeleteClientCB(cbNode);
         }
@@ -706,7 +706,7 @@ void HandleCARequests(const CARemoteEndpoint_t* endPoint, const CARequestInfo_t*
     }
 
     OC_LOG_V(INFO, TAG, "HandleCARequests: CA token length = %d", CA_MAX_TOKEN_LEN);
-    OC_LOG_BUFFER(INFO, TAG, requestInfo->info.token, CA_MAX_TOKEN_LEN);
+    OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)requestInfo->info.token, CA_MAX_TOKEN_LEN);
 
     serverRequest.requestToken = (CAToken_t)OCMalloc(CA_MAX_TOKEN_LEN+1);
     // Module Name
@@ -747,7 +747,7 @@ void HandleCARequests(const CARemoteEndpoint_t* endPoint, const CARequestInfo_t*
     // TODO-CA: CA is including non-vendor header options as well, like observe.
     // Need to filter those out
     GetObserveHeaderOption(&serverRequest.observationOption,
-            requestInfo->info.options, &(requestInfo->info.numOptions));
+            requestInfo->info.options, (uint8_t *)&(requestInfo->info.numOptions));
     if (requestInfo->info.numOptions > MAX_HEADER_OPTIONS)
     {
         OC_LOG(ERROR, TAG,
index 25c7ee9..47bbaa0 100644 (file)
@@ -74,8 +74,9 @@ public:
 
 public:
     /// Constructor
-    RoomResource(): m_roomName("John's Room"), m_lightState(false),
-                    m_lightColor(0), m_fanState(false), m_fanSpeed(0)
+    RoomResource(): m_roomName("John's Room"), m_roomHandle(nullptr), m_lightState(false),
+                    m_lightColor(0),m_lightHandle(nullptr),  m_fanState(false), m_fanSpeed(0),
+                    m_fanHandle(nullptr)
     {
         m_lightUri = "/a/light"; // URI of the resource
         m_lightTypes.push_back("core.light"); // resource type name. In this case, it is light
@@ -592,7 +593,7 @@ int main(int argc, char* argv[])
         cv.wait(lock);
 
     }
-    catch(OCException e)
+    catch(OCException &e)
     {
         std::cout << "Exception in main: " << e.what();
     }
index a4146c6..e395909 100644 (file)
@@ -74,7 +74,8 @@ public:
 public:
     /// Constructor
     LightResource()
-        :m_name("John's light"), m_state(false), m_power(0), m_lightUri("/a/light") {
+        :m_name("John's light"), m_state(false), m_power(0), m_lightUri("/a/light"),
+                m_resourceHandle(nullptr) {
         // Initialize representation
         m_lightRep.setUri(m_lightUri);
 
@@ -496,6 +497,7 @@ int main(int argc, char* argv[])
                 break;
             case 4:
                 isSlowResponse = true;
+                break;
             default:
                 break;
        }
@@ -536,9 +538,9 @@ int main(int argc, char* argv[])
         std::unique_lock<std::mutex> lock(blocker);
         cv.wait(lock);
     }
-    catch(OCException e)
+    catch(OCException &e)
     {
-        //log(e.what());
+        std::cout << "OCException in main : " << e.what() << endl;
     }
 
     // No explicit call to stop the platform.
index 6e9ac63..b8b8808 100644 (file)
@@ -63,7 +63,6 @@ namespace OC
         static const char RESOURCE_UNREG_FAILED[]      = "Unregistering resource failed";
         static const char OPTION_ID_RANGE_INVALID[]    =
                             "Error: OptionID valid only from 2048 to 3000 inclusive.";
-
         static const char NO_ERROR[]                   = "No Error";
         static const char RESOURCE_CREATED[]           = "Resource Created";
         static const char RESOURCE_DELETED[]           = "Resource Deleted";
@@ -103,6 +102,8 @@ namespace OC
         static const char INVALID_JSON_ARRAY_DEPTH[]   = "Max JSON Array Depth exceeded";
         static const char INVALID_JSON_TYPE_TAG[]      = "Invalid JSON Type Tag";
         static const char INVALID_ATTRIBUTE[]          = "Invalid Attribute: ";
+        static const char INVALID_DEVICE_INFO[]        = "Invalid Device Information";
+
     }
 
     namespace Error
index 9bea2e2..6d72233 100644 (file)
@@ -85,6 +85,10 @@ std::string OC::OCException::reason(const OCStackResult sr)
             return OC::Exception::INVALID_REQUEST_HANDLE;
         case OC_STACK_ERROR:
             return OC::Exception::GENERAL_FAULT;
+        case OC_STACK_INVALID_DEVICE_INFO:
+            return OC::Exception::INVALID_DEVICE_INFO;
+        case OC_STACK_INVALID_JSON:
+            return OC::Exception::INVALID_REPRESENTATION;
     }
 
     return OC::Exception::UNKNOWN_ERROR;
index 3a1312c..faed78e 100644 (file)
@@ -36,8 +36,9 @@ OCResource::OCResource(std::weak_ptr<IClientWrapper> clientWrapper, const std::s
                        const std::vector<std::string>& resourceTypes,
                        const std::vector<std::string>& interfaces)
  :  m_clientWrapper(clientWrapper), m_uri(uri), m_resourceId(serverId, m_uri),
+    m_host(host),
     m_connectivityType(connectivityType),
-    m_host(host), m_isObservable(observable),
+    m_isObservable(observable),
     m_isCollection(false), m_resourceTypes(resourceTypes), m_interfaces(interfaces),
     m_observeHandle(nullptr)
 {