resolve build warnings in base layer for linux 95/10895/3
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 6a53b0b..dec32b5 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 9b1729c..5153b69 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 4c6f55c..a3cb02f 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 e922634..313d2f6 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 92b6a66..d532c10 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 96fb6fa..718c3d3 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 1606142..5e93032 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 b308c0f..3af571e 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 95fdc07..13d595b 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 a521f87..c2544e6 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 1180def..0de8db5 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 dfea47c..46b36a6 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)