resolve build warnings in base layer for linux
authorJaewook Jung <jw0213.jung@samsung.com>
Thu, 25 Aug 2016 06:25:04 +0000 (15:25 +0900)
committerJon A. Cruz <jon@joncruz.org>
Tue, 30 Aug 2016 20:31:01 +0000 (20:31 +0000)
resolve build warnings in base layer for linux
(unused parameter, comparison warning..)

Change-Id: I91e69af57ec653260ebddf4d89d5a5d5fcc0ffe4
Signed-off-by: Jaewook Jung <jw0213.jung@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10895
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jon@joncruz.org>
12 files changed:
resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.c
resource/csdk/connectivity/src/cainterfacecontroller.c
resource/csdk/connectivity/src/caretransmission.c
resource/csdk/connectivity/src/ip_adapter/caipserver.c
resource/csdk/connectivity/src/tcp_adapter/catcpserver.c
resource/csdk/connectivity/test/caprotocolmessagetest.cpp
resource/csdk/connectivity/test/ulinklist_test.cpp
resource/csdk/stack/src/ocpayload.c
resource/csdk/stack/src/ocstack.c
resource/csdk/stack/src/oickeepalive.c
resource/csdk/stack/test/linux/occlient.c
resource/examples/directpairingclient.cpp

index 6a53b0bc0fd15a9911269d7bf8aae7b172a8ef7e..dec32b51799f1c426844f58e0c201152a9c05012 100644 (file)
@@ -70,6 +70,8 @@ void coap_pdu_clear(coap_pdu_t *pdu, size_t size, coap_transport_type transport,
         /* data is NULL unless explicitly set by coap_add_data() */
         pdu->length = length;
     }
+#else
+    (void)length;
 #endif
 }
 
@@ -204,6 +206,9 @@ coap_pdu_init(unsigned char type, unsigned char code, unsigned short id,
 coap_pdu_t *
 coap_new_pdu(coap_transport_type transport, unsigned int size)
 {
+#ifndef WITH_TCP
+    (void)size;
+#endif
     coap_pdu_t *pdu;
 
 #ifndef WITH_CONTIKI
index 9b1729c5cefa95b6821078310c35c151625ce2d1..5153b690dbea43be87fc7c1553b3a36a52e8c6cb 100644 (file)
@@ -141,6 +141,7 @@ static void CAAdapterChangedCallback(CATransportAdapter_t adapter, CANetworkStat
     OIC_LOG_V(DEBUG, TAG, "[%d]adapter status is changed to [%d]", adapter, status);
 }
 
+#if defined(TCP_ADAPTER) || defined(EDR_ADAPTER) || defined(LE_ADAPTER)
 static void CAConnectionChangedCallback(const CAEndpoint_t *info, bool isConnected)
 {
     // Call the callback.
@@ -150,6 +151,7 @@ static void CAConnectionChangedCallback(const CAEndpoint_t *info, bool isConnect
     }
     OIC_LOG_V(DEBUG, TAG, "[%s] connection status is changed to [%d]", info->addr, isConnected);
 }
+#endif
 
 static void CAAdapterErrorHandleCallback(const CAEndpoint_t *endpoint,
                                          const void *data, uint32_t dataLen,
@@ -298,7 +300,7 @@ CAResult_t CAGetNetworkInfo(CAEndpoint_t **info, uint32_t *size)
 
             OIC_LOG_V(DEBUG,
                       TAG,
-                      "%zu adapter network info size is %" PRIu32 " res:%d",
+                      "%" PRIu32 " adapter network info size is %" PRIu32 " res:%d",
                       index,
                       tempSize[index],
                       res);
index 4c6f55c32cd250b98e1f8f4cd27ae341fc1bfe2e..a3cb02f219243b82890f0c7296548e6e3ad23683 100644 (file)
@@ -44,6 +44,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef TB_LOG
+#include <inttypes.h>
+#endif
 
 #ifndef SINGLE_THREAD
 #ifdef HAVE_UNISTD_H
@@ -147,7 +150,7 @@ static bool CACheckTimeout(uint64_t currentTime, CARetransmissionData_t *retData
 
     if (currentTime >= retData->timeStamp + timeout)
     {
-        OIC_LOG_V(DEBUG, TAG, "%llu microseconds time out!!, tried count(%d)",
+        OIC_LOG_V(DEBUG, TAG, "%" PRIu64 " microseconds time out!!, tried count(%d)",
                   timeout, retData->triedCount);
         return true;
     }
@@ -282,7 +285,7 @@ void CARetransmissionBaseRoutine(void *threadValue)
         else if (!context->isStop)
         {
             // check each RETRANSMISSION_CHECK_PERIOD_SEC time.
-            OIC_LOG_V(DEBUG, TAG, "wait..(%lld)microseconds",
+            OIC_LOG_V(DEBUG, TAG, "wait..(%" PRIu64 ")microseconds",
                       RETRANSMISSION_CHECK_PERIOD_SEC * (uint64_t) USECS_PER_SEC);
 
             // wait
index e9226340aa4fa2a5d216dd5fcca355f88b186063..313d2f6a55b3f3c34e6e2f8d3240939e7401cf85 100644 (file)
@@ -1204,9 +1204,6 @@ static void sendData(int fd, const CAEndpoint_t *endpoint,
         return;
     }
 
-    char *secure = (endpoint->flags & CA_SECURE) ? "secure " : "";
-
-    (void)secure; // eliminates unused-variable waring when built in release mode
     (void)cast;  // eliminates release warning
     (void)fam;
 
@@ -1223,6 +1220,10 @@ static void sendData(int fd, const CAEndpoint_t *endpoint,
     {
         socklen = sizeof(struct sockaddr_in);
     }
+
+#ifdef TB_LOG
+    const char *secure = (endpoint->flags & CA_SECURE) ? "secure " : "";
+#endif
 #if !defined(_WIN32)
     ssize_t len = sendto(fd, data, dlen, 0, (struct sockaddr *)&sock, socklen);
     if (OC_SOCKET_ERROR == len)
index 92b6a668a6260b4666fc26eae714ef23b9020d0c..d532c103a4c1bb3fd2a08a8037f3da09e10db8a1 100644 (file)
@@ -1051,6 +1051,9 @@ static void sendData(const CAEndpoint_t *endpoint, const void *data,
         remainLen -= len;
     } while (remainLen > 0);
 
+#ifndef TB_LOG
+    (void)fam;
+#endif
     OIC_LOG_V(INFO, TAG, "unicast %stcp sendTo is successful: %zu bytes", fam, dlen);
 }
 
index 96fb6fa1b304dbaf40845b4666cc74df3f669d39..718c3d33b1e348ddc9f41205cab8e2f72d6c2aea 100644 (file)
@@ -170,8 +170,8 @@ TEST(CAProtocolMessage, CAParseURILongPath)
 
     CoAPOptionCase cases[] = {
         {COAP_OPTION_URI_PATH, 113, "oic"
-        "123456789012345678901234567890123456789012345678901234567890"
-        "12345678901234567890123456789012345678901234567890"},
+        "123456789012345678901234567890123456789012345678901234567890"
+        "12345678901234567890123456789012345678901234567890"},
         {COAP_OPTION_URI_PATH, 3, "res"},
         {COAP_OPTION_URI_QUERY, 14, "rt=core.sensor"},
         {COAP_OPTION_URI_QUERY, 13, "if=core.mi.ll"},
@@ -201,7 +201,7 @@ TEST(CAProtocolMessage, CAGetTokenFromPDU)
 
     CAInfo_t inData;
     memset(&inData, 0, sizeof(CAInfo_t));
-    inData.token = "token";
+    inData.token = (CAToken_t)"token";
     inData.tokenLength = strlen(inData.token);
     inData.type = CA_MSG_NONCONFIRM;
 
index 16061424e99756f02d21c52d71c0776b2d830b5e..5e93032a820dc289b083f391dd931922c308ac58 100644 (file)
@@ -120,7 +120,7 @@ TEST_F(ULinkListF, LengthMulti)
     int dummy[1000] = {0};
     size_t cap = sizeof(dummy) / sizeof(dummy[0]);
 
-    for (int i = 0; i < cap; ++i)
+    for (size_t i = 0; i < cap; ++i)
     {
         dummy[i] = i;
         EXPECT_EQ(CA_STATUS_OK, u_linklist_add(list, &dummy[i]));
index b308c0fc18e1571ff2bab1bea8076e3d018cbc1c..3af571ea5b28ca60db0f4b1ca6ee11068f7e8fef 100644 (file)
@@ -1332,22 +1332,27 @@ exit:
 
 char* OCCreateString(const OCStringLL* ll)
 {
+    if (!ll)
+    {
+        return NULL;
+    }
+
     char *str = NULL;
     char *pos = NULL;
     size_t len = 0;
     size_t sublen = 0;
     int count = 0;
 
-    if (!ll) return NULL;
-
-    for (const OCStringLL *it = ll; it ; it = it->next )
+    for (const OCStringLL *it = ll; it; it = it->next)
     {
         len += strlen(it->value) + 1;
     }
     len--; // renove trailing separator (just added above)
     str = (char*) malloc(len + 1);
     if (!str)
+    {
         return NULL;
+    }
 
     pos = str;
     const OCStringLL *it = ll;
@@ -1355,13 +1360,13 @@ char* OCCreateString(const OCStringLL* ll)
     {
         sublen = strlen(it->value);
         count = snprintf(pos, len + 1, "%s", it->value);
-        if (count<sublen)
+        if ((size_t)count < sublen)
         {
             free(str);
             return NULL;
         }
-        len-=sublen;
-        pos+=count;
+        len -= sublen;
+        pos += count;
 
         it = it->next;
         if (it)
index 95fdc070d20f3b7fcd74848f6758cff58cd8c651..13d595be32864192921d4e052a5881f01628d66e 100644 (file)
@@ -885,7 +885,7 @@ OCPresenceTrigger convertTriggerStringToEnum(const char * triggerStr)
     {
         OIC_LOG_V(ERROR, TAG,
                   "encodeAddressForRFC6874 failed: "
-                  "outputSize (%d) < inputSize (%d)",
+                  "outputSize (%zu) < inputSize (%zu)",
                   outputSize, inputSize);
 
         return OC_STACK_ERROR;
index a521f87511701ea539c4f6989d5e3c49338a9378..c2544e6489361dd6e2fb7fe3633e81a6f59010b5 100644 (file)
@@ -533,7 +533,7 @@ void IncreaseInterval(KeepAliveEntry_t *entry)
     VERIFY_NON_NULL_NR(entry, FATAL);
 
     OIC_LOG_V(DEBUG, TAG, "Total interval counts: %d", entry->intervalSize);
-    if (entry->intervalSize > entry->currIndex + 1)
+    if (entry->intervalSize > (size_t)entry->currIndex + 1)
     {
         entry->currIndex++;
         entry->interval = entry->intervalInfo[entry->currIndex];
index 1180defe3b7ed04fa1eb738f673789b60ca01251..0de8db53aa87f4e7436f495d82054bd7cd5e5f43 100644 (file)
@@ -46,6 +46,7 @@ void handleSigInt(int signum) {
 // This is a function called back when a device is discovered
 OCStackApplicationResult applicationDiscoverCB(
         OCClientResponse * clientResponse) {
+    (void)clientResponse;
     OIC_LOG(INFO, TAG, "Entering applicationDiscoverCB (Application Layer CB)");
     OIC_LOG_V(INFO, TAG, "Device =============> Discovered %s @ %s:%d",
                                     clientResponse->resourceUri,
index dfea47c855dfe03402e716759285d5f85a52f731..46b36a617cd732909d55007156ff368e1a9f5b1c 100644 (file)
@@ -35,7 +35,6 @@
 #include "OCPlatform.h"
 #include "OCApi.h"
 
-#define MAX_URI_LENGTH (64)
 #define MAX_PERMISSION_LENGTH (5)
 #define CREATE (1)
 #define READ (2)