[IOT-1996] Make resource/csdk/connectivity W4 compliant.
authorAlex Kelley <alexke@microsoft.com>
Mon, 27 Mar 2017 16:38:24 +0000 (09:38 -0700)
committerDan Mihai <Daniel.Mihai@microsoft.com>
Wed, 12 Apr 2017 22:22:54 +0000 (22:22 +0000)
These changes include the following:
- Fix W4 warnings under resource/csdk/connectivity.
- Fix W4 warnings under resource/csdk/connectivity/test.
- Enable /W4 /WX on resource/csdk/connectivity.
- Enable /W4 /WX on resource/csdk/connectivity/test.
- Update build_common/Windows/SConscript.

Change-Id: I98d93f4df6fc938f004ef2f6844ba120bb5e788a
Signed-off-by: Alex Kelley <alexke@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/18535
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: Mike Fenelon <mike.fenelon@microsoft.com>
(cherry picked from commit 7a811cc5b6ba90a99ada4a86da1632367a52304c)
Reviewed-on: https://gerrit.iotivity.org/gerrit/18749
Reviewed-by: Dave Thaler <dthaler@microsoft.com>
20 files changed:
build_common/windows/SConscript
resource/c_common/platform_features.h
resource/csdk/connectivity/SConscript
resource/csdk/connectivity/inc/caprotocolmessage.h
resource/csdk/connectivity/inc/catcpinterface.h
resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c
resource/csdk/connectivity/src/adapter_util/caadapterutils.c
resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c
resource/csdk/connectivity/src/cablockwisetransfer.c
resource/csdk/connectivity/src/cainterfacecontroller.c
resource/csdk/connectivity/src/camessagehandler.c
resource/csdk/connectivity/src/caprotocolmessage.c
resource/csdk/connectivity/src/ip_adapter/caipadapter.c
resource/csdk/connectivity/src/ip_adapter/caipserver.c
resource/csdk/connectivity/src/ip_adapter/windows/caipnwmonitor.c
resource/csdk/connectivity/src/tcp_adapter/catcpadapter.c
resource/csdk/connectivity/src/tcp_adapter/catcpserver.c
resource/csdk/connectivity/test/SConscript
resource/csdk/connectivity/test/ssladapter_test.cpp
resource/csdk/include/octypes.h

index d56618e..74735e2 100644 (file)
@@ -21,11 +21,13 @@ if env['CC'] == 'cl':
     #      structs for non-legacy compilers.
     #  - warning C4214:  bit field types other than int
     #    - Disabled due to IoTivity not being ANSI compatible
+    #  - warning C4221: nonstandard extension used: 'identifier' cannot be initialized using address of automatic variable
+    #    - Disabled due to IoTivity not being ANSI compatible
     #  - warning C4232: nonstandard extension used: 'read': address of dllimport 'fread' is not static, identity not guaranteed
     #    - fread, frwrite, etc are provided by the platform and cannot be changed.
     #  - warning C4706: assignment within conditional expression
     #    - Disabled due to the widespread usage in IoTivity and low impact.
-    env.AppendUnique(CCFLAGS=['/wd4127', '/wd4200', '/wd4201', '/wd4204', '/wd4214', '/wd4232', '/wd4706'])
+    env.AppendUnique(CCFLAGS=['/wd4127', '/wd4200', '/wd4201', '/wd4204', '/wd4214', '/wd4221', '/wd4232', '/wd4706'])
 
     env.AppendUnique(CCFLAGS=['/EHsc'])
 
index e674c82..215bfbf 100644 (file)
 #  define UINT16_MAX 65535
 #endif
 
+/**
+ * Mark a parameter as unused. Used to prevent unused variable compiler warnings.
+ */
+#define OC_UNUSED(x) (void)(x)
+
 #endif
index 132f7c4..6450bcf 100644 (file)
@@ -18,7 +18,7 @@ print "BUILD_SAMPLE is %s" % build_sample
 print "MQ flag is %s" % with_mq
 
 if target_os in ['msys_nt', 'windows']:
-    connectivity_env.AppendUnique(CCFLAGS=['/W3', '/WX'])
+    connectivity_env.AppendUnique(CCFLAGS=['/W4', '/WX'])
 
 targets_disallow_multitransport = ['arduino']
 
index 0620a34..a119027 100644 (file)
@@ -123,7 +123,7 @@ CAResult_t CAParseURI(const char *uriInfo, coap_list_t **options);
  * @param[out]  optlist              options information.
  * @return  CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h).
  */
-CAResult_t CAParseUriPartial(const unsigned char *str, size_t length, int target,
+CAResult_t CAParseUriPartial(const unsigned char *str, size_t length, uint16_t target,
                              coap_list_t **optlist);
 
 /**
@@ -171,9 +171,10 @@ int CAOrderOpts(void *a, void *b);
 /**
  * number of options count.
  * @param[in]   opt_iter            option iteration for count.
- * @return number of options.
+ * @param[out]  optionCount         number of options.
+ * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h).
  */
-uint32_t CAGetOptionCount(coap_opt_iterator_t opt_iter);
+CAResult_t CAGetOptionCount(coap_opt_iterator_t opt_iter, uint8_t *optionCount);
 
 /**
  * gets option data.
index 90b2354..1e79a80 100644 (file)
@@ -236,7 +236,7 @@ CAResult_t CASearchAndDeleteTCPSession(const CAEndpoint_t *endpoint);
  *
  * @param[in]   data    Data to be send.
  * @param[in]   dlen    Total data length.
- * @return  Payload length
+ * @return  Payload length or 0 on error.
  */
 size_t CACheckPayloadLengthFromHeader(const void *data, size_t dlen);
 
index 8d1b436..11089d1 100644 (file)
@@ -282,7 +282,7 @@ static PkiInfo_t g_pkiInfo = {{NULL, 0}, {NULL, 0}, {NULL, 0}, {NULL, 0}};
 
 typedef struct  {
     int code;
-    int alert;
+    unsigned char alert;
 } CrtVerifyAlert_t;
 
 static const CrtVerifyAlert_t crtVerifyAlerts[] = {
@@ -309,7 +309,7 @@ static const CrtVerifyAlert_t crtVerifyAlerts[] = {
     {0, 0}
 };
 
-static int GetAlertCode(uint32_t flags)
+static unsigned char GetAlertCode(uint32_t flags)
 {
     const CrtVerifyAlert_t *cur;
 
@@ -518,7 +518,11 @@ static int SendCallBack(void * tep, const unsigned char * data, size_t dataLen)
         size_t dataToSend = (dataLen > INT_MAX) ? INT_MAX : dataLen;
         CAPacketSendCallback sendCallback = g_caSslContext->adapterCallbacks[adapterIndex].sendCallback;
         sentLen = sendCallback(&(((SslEndPoint_t * )tep)->sep.endpoint), (const void *) data, dataToSend);
-        if (sentLen != dataLen)
+        if (0 > sentLen)
+        {
+            OIC_LOG(ERROR, NET_SSL_TAG, "Error sending packet. The error will be reported in the adapter.");
+        }
+        else if ((size_t)sentLen != dataLen)
         {
             OIC_LOG_V(DEBUG, NET_SSL_TAG,
                       "Packet was partially sent - sent/total/remained bytes : %d/%" PRIuPTR "/%" PRIuPTR,
@@ -580,8 +584,8 @@ static int ParseChain(mbedtls_x509_crt * crt, unsigned char * buf, size_t bufLen
 {
     int ret;
     OIC_LOG_V(DEBUG, NET_SSL_TAG, "In %s", __func__);
-    VERIFY_NON_NULL_RET(crt, NET_SSL_TAG, "Param crt is NULL" , -1);
-    VERIFY_NON_NULL_RET(buf, NET_SSL_TAG, "Param buf is NULL" , -1);
+    VERIFY_NON_NULL_RET(crt, NET_SSL_TAG, "Param crt is NULL", -1);
+    VERIFY_NON_NULL_RET(buf, NET_SSL_TAG, "Param buf is NULL", -1);
 
     if (NULL != errNum)
     {
@@ -605,13 +609,13 @@ static int ParseChain(mbedtls_x509_crt * crt, unsigned char * buf, size_t bufLen
     {
         *errNum = ret;
     }
-    
+
     ret = 0;
     for (const mbedtls_x509_crt *cur = crt; cur != NULL; cur = cur->next)
     {
         ret++;
     }
-    
+
     OIC_LOG_V(DEBUG, NET_SSL_TAG, "Out %s", __func__);
     return ret;
 }
@@ -1029,6 +1033,8 @@ static bool checkSslOperation(SslEndPoint_t*  peer,
                               const char* str,
                               unsigned char msg)
 {
+    OC_UNUSED(str);
+
     if ((0 != ret) &&
         (MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY != ret) &&
         (MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED != ret) &&
@@ -2289,7 +2295,6 @@ CAResult_t CAsetTlsCipherSuite(const uint32_t cipher)
     OIC_LOG_V(DEBUG, NET_SSL_TAG, "In %s", __func__);
     VERIFY_NON_NULL_RET(g_caSslContext, NET_SSL_TAG, "SSL context is not initialized." , CA_STATUS_NOT_INITIALIZED);
 
-    CAResult_t res = CA_STATUS_FAILED;
     SslCipher_t index = GetCipherIndex(cipher);
     if (SSL_CIPHER_MAX == index)
     {
index da22fbd..f9cac50 100644 (file)
@@ -374,6 +374,13 @@ void CALogSendStateInfo(CATransportAdapter_t adapter,
                         const char *addr, uint16_t port, ssize_t sentLen,
                         bool isSuccess, const char* message)
 {
+#ifndef TB_LOG
+    OC_UNUSED(addr);
+    OC_UNUSED(port);
+    OC_UNUSED(sentLen);
+    OC_UNUSED(message);
+#endif
+
     OIC_LOG(DEBUG, CA_ADAPTER_UTILS_TAG, "CALogSendStateInfo");
     OIC_LOG(DEBUG, ANALYZER_TAG, "=================================================");
 
index 9ea72ae..0e5273a 100644 (file)
@@ -2745,8 +2745,8 @@ static CAResult_t CALEAdapterGattClientStop()
 static ssize_t CALESecureSendDataCB(CAEndpoint_t *endpoint,
                              const void *data, size_t dataLen)
 {
-    VERIFY_NON_NULL_RET(endpoint, CALEADAPTER_TAG, "endpoint is NULL", 0);
-    VERIFY_NON_NULL_RET(data, CALEADAPTER_TAG, "data is NULL", 0);
+    VERIFY_NON_NULL_RET(endpoint, CALEADAPTER_TAG, "endpoint is NULL", -1);
+    VERIFY_NON_NULL_RET(data, CALEADAPTER_TAG, "data is NULL", -1);
 
     OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "Secure Data Send - encrypted datalen = %d", dataLen);
 
@@ -2765,7 +2765,7 @@ static ssize_t CALESecureSendDataCB(CAEndpoint_t *endpoint,
             {
                 g_errorHandler(endpoint, data, dataLen, result);
             }
-            return 0;
+            return -1;
         }
     }
     else if (ADAPTER_CLIENT == g_adapterType ||
@@ -2781,14 +2781,14 @@ static ssize_t CALESecureSendDataCB(CAEndpoint_t *endpoint,
             {
                 g_errorHandler(endpoint, data, dataLen, result);
             }
-            return 0;
+            return -1;
         }
     }
     else
     {
         OIC_LOG_V(ERROR, CALEADAPTER_TAG,
                   "Can't Send Message adapterType = %d, dataType = %d", g_adapterType, dataType);
-        return 0;
+        return -1;
     }
 
     return (ssize_t)dataLen;
index e123284..21e16be 100644 (file)
@@ -416,10 +416,10 @@ CAResult_t CAReceiveBlockWiseData(coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
                 return CA_STATUS_FAILED;
             }
 
-            coap_block_t *block = CAGetBlockOption(blockDataID, data->type);
-            if (!block)
+            coap_block_t *tempBlock = CAGetBlockOption(blockDataID, data->type);
+            if (!tempBlock)
             {
-                OIC_LOG(ERROR, TAG, "block is null");
+                OIC_LOG(ERROR, TAG, "tempBlock is null");
                 CADestroyBlockID(blockDataID);
                 return CA_STATUS_FAILED;
             }
@@ -427,7 +427,7 @@ CAResult_t CAReceiveBlockWiseData(coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
             CAResult_t res = CA_STATUS_OK;
             if (COAP_OPTION_BLOCK2 == data->type)
             {
-                res = CASetNextBlockOption2(pdu, endpoint, receivedData, *block, dataLen);
+                res = CASetNextBlockOption2(pdu, endpoint, receivedData, *tempBlock, dataLen);
                 if (CA_STATUS_OK != res)
                 {
                     OIC_LOG(ERROR, TAG, "setting has failed");
@@ -437,7 +437,7 @@ CAResult_t CAReceiveBlockWiseData(coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
             }
             else if (COAP_OPTION_BLOCK1 == data->type)
             {
-                res = CASetNextBlockOption1(pdu, endpoint, receivedData, *block, dataLen);
+                res = CASetNextBlockOption1(pdu, endpoint, receivedData, *tempBlock, dataLen);
                 if (CA_STATUS_OK != res)
                 {
                     OIC_LOG(ERROR, TAG, "setting has failed");
@@ -955,9 +955,9 @@ CAResult_t CASetNextBlockOption1(coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
     else
     {
         // received message type is response
-        uint32_t code = CA_RESPONSE_CODE(pdu->transport_hdr->udp.code);
-        if (0 == block.m && (CA_REQUEST_ENTITY_INCOMPLETE != code
-                && CA_REQUEST_ENTITY_TOO_LARGE != code))
+        uint32_t responseCode = CA_RESPONSE_CODE(pdu->transport_hdr->udp.code);
+        if (0 == block.m && (CA_REQUEST_ENTITY_INCOMPLETE != responseCode
+                && CA_REQUEST_ENTITY_TOO_LARGE != responseCode))
         {
             int isBlock2 = coap_get_block(pdu, COAP_OPTION_BLOCK2, &block);
             if (isBlock2)
@@ -1101,8 +1101,8 @@ CAResult_t CASetNextBlockOption2(coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
                                                                           COAP_OPTION_SIZE2,
                                                                           &(data->payloadLength));
 
-            uint32_t code = CA_RESPONSE_CODE(pdu->transport_hdr->udp.code);
-            if (CA_REQUEST_ENTITY_INCOMPLETE != code && CA_REQUEST_ENTITY_TOO_LARGE != code)
+            uint32_t responseCode = CA_RESPONSE_CODE(pdu->transport_hdr->udp.code);
+            if (CA_REQUEST_ENTITY_INCOMPLETE != responseCode && CA_REQUEST_ENTITY_TOO_LARGE != responseCode)
             {
                 // check if received payload is exact
                 blockWiseStatus = CACheckBlockErrorType(data, &block, receivedData,
@@ -1579,9 +1579,10 @@ CAResult_t CAAddBlockOption2(coap_pdu_t **pdu, const CAInfo_t *info, size_t data
             goto exit;
         }
 
+        assert(block2->szx <= UINT8_MAX);
         if (!coap_add_block(*pdu, (unsigned int)dataLength,
                             (const unsigned char *) info->payload,
-                            block2->num, block2->szx))
+                            block2->num, (unsigned char)block2->szx))
         {
             OIC_LOG(ERROR, TAG, "Data length is smaller than the start index");
             return CA_STATUS_FAILED;
@@ -1676,9 +1677,10 @@ CAResult_t CAAddBlockOption1(coap_pdu_t **pdu, const CAInfo_t *info, size_t data
         }
 
         // add the payload data as the block size.
+        assert(block1->szx <= UINT8_MAX);
         if (!coap_add_block(*pdu, (unsigned int)dataLength,
                             (const unsigned char *) info->payload, block1->num,
-                            block1->szx))
+                            (unsigned char)block1->szx))
         {
             OIC_LOG(ERROR, TAG, "Data length is smaller than the start index");
             return CA_STATUS_FAILED;
index f7fe831..2a54e5c 100644 (file)
@@ -587,9 +587,9 @@ CAResult_t CASendUnicastData(const CAEndpoint_t *endpoint, const void *data, uin
             sentDataLen = g_adapterHandler[index].sendData(endpoint, data, length, dataType);
         }
 
-        if (sentDataLen != length)
+        if ((0 > sentDataLen) || ((uint32_t)sentDataLen != length))
         {
-            OIC_LOG(ERROR, TAG, "error in sending data. Error will be reported in adapter");
+            OIC_LOG(ERROR, TAG, "Error sending data. The error will be reported in adapter.");
 #ifdef SINGLE_THREAD
             //in case of single thread, no error handler. Report error immediately
             return CA_SEND_FAILED;
index f29b3ea..bf08a00 100755 (executable)
@@ -567,9 +567,7 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
                 // Blockwise transfer
                 if (NULL != info)
                 {
-                    CAResult_t res = CAAddBlockOption(&pdu, info,
-                                                      data->remoteEndpoint,
-                                                      &options);
+                    res = CAAddBlockOption(&pdu, info, data->remoteEndpoint, &options);
                     if (CA_STATUS_OK != res)
                     {
                         OIC_LOG(INFO, TAG, "to write block option has failed");
@@ -1464,7 +1462,9 @@ static void CALogPDUInfo(const CAData_t *data, const coap_pdu_t *pdu)
         }
     }
 
-    size_t payloadLen = (pdu->data) ? (unsigned char *) pdu->hdr + pdu->length - pdu->data : 0;
+#ifdef TB_LOG
+    size_t payloadLen = (pdu->data) ? (unsigned char *)pdu->hdr + pdu->length - pdu->data : 0;
+#endif
     OIC_LOG_V(DEBUG, ANALYZER_TAG, "CoAP Message Full Size = [%lu]", pdu->length);
     OIC_LOG(DEBUG, ANALYZER_TAG, "CoAP Header (+ 0xFF)");
     OIC_LOG_BUFFER(DEBUG, ANALYZER_TAG,  (const uint8_t *) pdu->transport_hdr,
@@ -1472,7 +1472,7 @@ static void CALogPDUInfo(const CAData_t *data, const coap_pdu_t *pdu)
     OIC_LOG_V(DEBUG, ANALYZER_TAG, "CoAP Header size = [%lu]", pdu->length - payloadLen);
 
     OIC_LOG_V(DEBUG, ANALYZER_TAG, "CoAP Payload");
-//    OIC_LOG_BUFFER(DEBUG, ANALYZER_TAG, pdu->data, payloadLen);
+    //OIC_LOG_BUFFER(DEBUG, ANALYZER_TAG, pdu->data, payloadLen);
     OIC_LOG_V(DEBUG, ANALYZER_TAG, "CoAP Payload Size = [%lu]", payloadLen);
     OIC_LOG(DEBUG, ANALYZER_TAG, "=================================================");
     OIC_TRACE_END();
index 541f4e8..5c319fc 100755 (executable)
@@ -199,7 +199,7 @@ coap_pdu_t *CAParsePDU(const char *data, size_t length, uint32_t *outCode,
 #endif
 
     coap_pdu_t *outpdu =
-        coap_pdu_init2(0, 0, ntohs(COAP_INVALID_TID), length, transport);
+        coap_pdu_init2(0, 0, ntohs((unsigned short)COAP_INVALID_TID), length, transport);
     if (NULL == outpdu)
     {
         OIC_LOG(ERROR, TAG, "outpdu is null");
@@ -247,7 +247,7 @@ coap_pdu_t *CAParsePDU(const char *data, size_t length, uint32_t *outCode,
 
 exit:
     OIC_LOG(DEBUG, TAG, "data :");
-    OIC_LOG_BUFFER(DEBUG, TAG,  data, length);
+    OIC_LOG_BUFFER(DEBUG, TAG,  (const uint8_t *)data, length);
     coap_delete_pdu(outpdu);
     return NULL;
 }
@@ -316,7 +316,7 @@ coap_pdu_t *CAGeneratePDUImpl(code_t code, const CAInfo_t *info,
     }
 
     coap_pdu_t *pdu = coap_pdu_init2(0, 0,
-                                     ntohs(COAP_INVALID_TID),
+                                     ntohs((unsigned short)COAP_INVALID_TID),
                                      length, *transport);
 
     if (NULL == pdu)
@@ -462,7 +462,7 @@ CAResult_t CAParseURI(const char *uriInfo, coap_list_t **optlist)
     return CA_STATUS_OK;
 }
 
-CAResult_t CAParseUriPartial(const unsigned char *str, size_t length, int target,
+CAResult_t CAParseUriPartial(const unsigned char *str, size_t length, uint16_t target,
                              coap_list_t **optlist)
 {
     VERIFY_NON_NULL(optlist, TAG, "optlist");
@@ -543,7 +543,7 @@ CAResult_t CAParseHeadOption(uint32_t code, const CAInfo_t *info, coap_list_t **
             return CA_STATUS_FAILED;
         }
 
-        uint32_t id = (info->options + i)->optionID;
+        uint16_t id = (info->options + i)->optionID;
         switch (id)
         {
             case COAP_OPTION_URI_PATH:
@@ -712,10 +712,11 @@ int CAOrderOpts(void *a, void *b)
     return COAP_OPTION_KEY(*(coap_option *) a) == COAP_OPTION_KEY(*(coap_option * ) b);
 }
 
-uint32_t CAGetOptionCount(coap_opt_iterator_t opt_iter)
+CAResult_t CAGetOptionCount(coap_opt_iterator_t opt_iter, uint8_t *optionCount)
 {
-    uint32_t count = 0;
+    CAResult_t result = CA_STATUS_OK;
     coap_opt_t *option = NULL;
+    *optionCount = 0;
 
     while ((option = coap_option_next(&opt_iter)))
     {
@@ -730,11 +731,23 @@ uint32_t CAGetOptionCount(coap_opt_iterator_t opt_iter)
             && COAP_OPTION_ETAG != opt_iter.type && COAP_OPTION_MAXAGE != opt_iter.type
             && COAP_OPTION_PROXY_SCHEME != opt_iter.type)
         {
-            count++;
+            if (*optionCount < UINT8_MAX)
+            {
+                (*optionCount)++;
+            }
+            else
+            {
+                // Overflow. Return an error to the caller.
+                assert(false);
+                OIC_LOG_V(ERROR, TAG, "Overflow detected in %s", __func__);
+                *optionCount = 0;
+                result = CA_STATUS_FAILED;
+                break;
+            }
         }
     }
 
-    return count;
+    return result;
 }
 
 CAResult_t CAGetInfoFromPDU(const coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
@@ -766,7 +779,14 @@ CAResult_t CAGetInfoFromPDU(const coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
     }
 
     // init HeaderOption list
-    uint32_t count = CAGetOptionCount(opt_iter);
+    uint8_t count = 0;
+    CAResult_t countResult = CAGetOptionCount(opt_iter, &count);
+    if (CA_STATUS_OK != countResult)
+    {
+        OIC_LOG_V(ERROR, TAG, "CAGetOptionCount failed with error: %d!", countResult);
+        return countResult;
+    }
+
     memset(outInfo, 0, sizeof(*outInfo));
 
     outInfo->numOptions = count;
@@ -907,8 +927,9 @@ CAResult_t CAGetInfoFromPDU(const coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
                 }
                 else if (2 == COAP_OPT_LENGTH(option))
                 {
-                    outInfo->payloadFormat = CAConvertFormat(
-                            coap_decode_var_bytes(COAP_OPT_VALUE(option), COAP_OPT_LENGTH(option)));
+                    unsigned int decodedFormat = coap_decode_var_bytes(COAP_OPT_VALUE(option), COAP_OPT_LENGTH(option));
+                    assert(decodedFormat <= UINT16_MAX);
+                    outInfo->payloadFormat = CAConvertFormat((uint16_t)decodedFormat);
                 }
                 else
                 {
@@ -920,8 +941,9 @@ CAResult_t CAGetInfoFromPDU(const coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
             {
                 if (2 == COAP_OPT_LENGTH(option))
                 {
-                    outInfo->payloadVersion = coap_decode_var_bytes(COAP_OPT_VALUE(option),
-                            COAP_OPT_LENGTH(option));
+                    unsigned int decodedVersion = coap_decode_var_bytes(COAP_OPT_VALUE(option), COAP_OPT_LENGTH(option));
+                    assert(decodedVersion <= UINT16_MAX);
+                    outInfo->payloadVersion = (uint16_t)decodedVersion;
                 }
                 else
                 {
@@ -934,8 +956,9 @@ CAResult_t CAGetInfoFromPDU(const coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
             {
                 if (2 == COAP_OPT_LENGTH(option))
                 {
-                    outInfo->acceptVersion = coap_decode_var_bytes(COAP_OPT_VALUE(option),
-                                                                   COAP_OPT_LENGTH(option));
+                    unsigned int decodedVersion = coap_decode_var_bytes(COAP_OPT_VALUE(option), COAP_OPT_LENGTH(option));
+                    assert(decodedVersion <= UINT16_MAX);
+                    outInfo->acceptVersion = (uint16_t)decodedVersion;
                 }
                 else
                 {
@@ -951,9 +974,9 @@ CAResult_t CAGetInfoFromPDU(const coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
                 }
                 else if (2 == COAP_OPT_LENGTH(option))
                 {
-                    outInfo->acceptFormat = CAConvertFormat(
-                            coap_decode_var_bytes(COAP_OPT_VALUE(option),
-                                                  COAP_OPT_LENGTH(option)));
+                    unsigned int decodedFormat = coap_decode_var_bytes(COAP_OPT_VALUE(option), COAP_OPT_LENGTH(option));
+                    assert(decodedFormat <= UINT16_MAX);
+                    outInfo->acceptFormat = CAConvertFormat((uint16_t)decodedFormat);
                 }
                 else
                 {
@@ -981,7 +1004,8 @@ CAResult_t CAGetInfoFromPDU(const coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
                     if (bufLength <= sizeof(outInfo->options[0].optionData))
                     {
                         outInfo->options[idx].optionID = opt_iter.type;
-                        outInfo->options[idx].optionLength = bufLength;
+                        assert(bufLength <= UINT16_MAX);
+                        outInfo->options[idx].optionLength = (uint16_t)bufLength;
                         outInfo->options[idx].protocolID = CA_COAP_ID;
                         memcpy(outInfo->options[idx].optionData, buf, bufLength);
                         idx++;
@@ -1009,7 +1033,8 @@ CAResult_t CAGetInfoFromPDU(const coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
         memcpy(outInfo->token, token, token_length);
     }
 
-    outInfo->tokenLength = token_length;
+    assert(token_length <= UINT8_MAX);
+    outInfo->tokenLength = (uint8_t)token_length;
 
     // set payload data
     size_t dataSize;
@@ -1098,7 +1123,8 @@ CAResult_t CAGetTokenFromPDU(const coap_hdr_transport_t *pdu_hdr,
         memcpy(outInfo->token, token, token_length);
     }
 
-    outInfo->tokenLength = token_length;
+    assert(token_length <= UINT8_MAX);
+    outInfo->tokenLength = (uint8_t)token_length;
 
     return CA_STATUS_OK;
 }
index edf96c1..3e0b4dd 100644 (file)
@@ -287,14 +287,14 @@ void CAIPErrorHandler(const CAEndpoint_t *endpoint, const void *data,
 
 static void CAInitializeIPGlobals()
 {
-    caglobals.ip.u6.fd  = -1;
-    caglobals.ip.u6s.fd = -1;
-    caglobals.ip.u4.fd  = -1;
-    caglobals.ip.u4s.fd = -1;
-    caglobals.ip.m6.fd  = -1;
-    caglobals.ip.m6s.fd = -1;
-    caglobals.ip.m4.fd  = -1;
-    caglobals.ip.m4s.fd = -1;
+    caglobals.ip.u6.fd  = OC_INVALID_SOCKET;
+    caglobals.ip.u6s.fd = OC_INVALID_SOCKET;
+    caglobals.ip.u4.fd  = OC_INVALID_SOCKET;
+    caglobals.ip.u4s.fd = OC_INVALID_SOCKET;
+    caglobals.ip.m6.fd  = OC_INVALID_SOCKET;
+    caglobals.ip.m6s.fd = OC_INVALID_SOCKET;
+    caglobals.ip.m4.fd  = OC_INVALID_SOCKET;
+    caglobals.ip.m4s.fd = OC_INVALID_SOCKET;
     caglobals.ip.u6.port  = 0;
     caglobals.ip.u6s.port = 0;
     caglobals.ip.u4.port  = 0;
index 9e346cc..45c0643 100644 (file)
@@ -537,14 +537,13 @@ void CADeInitializeIPGlobals()
 static CAResult_t CAReceiveMessage(CASocketFd_t fd, CATransportFlags_t flags)
 {
     char recvBuffer[COAP_MAX_PDU_SIZE] = {0};
-
-    size_t len = 0;
     int level = 0;
     int type = 0;
     int namelen = 0;
     struct sockaddr_storage srcAddr = { .ss_family = 0 };
     unsigned char *pktinfo = NULL;
 #if !defined(WSA_CMSG_DATA)
+    size_t len = 0;
     struct cmsghdr *cmp = NULL;
     struct iovec iov = { .iov_base = recvBuffer, .iov_len = sizeof (recvBuffer) };
     union control
@@ -615,11 +614,11 @@ static CAResult_t CAReceiveMessage(CASocketFd_t fd, CATransportFlags_t flags)
                   .namelen = namelen,
                   .lpBuffers = &iov,
                   .dwBufferCount = 1,
-                  .Control = {.buf = cmsg.data, .len = sizeof (cmsg)}
+                  .Control = {.buf = (char*)cmsg.data, .len = sizeof (cmsg)}
                  };
 
     uint32_t recvLen = 0;
-    uint32_t ret = caglobals.ip.wsaRecvMsg(fd, &msg, &recvLen, 0,0);
+    uint32_t ret = caglobals.ip.wsaRecvMsg(fd, &msg, (LPDWORD)&recvLen, 0,0);
     OIC_LOG_V(DEBUG, TAG, "WSARecvMsg recvd %u bytes", recvLen);
     if (OC_SOCKET_ERROR == ret)
     {
@@ -678,11 +677,14 @@ static CAResult_t CAReceiveMessage(CASocketFd_t fd, CATransportFlags_t flags)
     if (flags & CA_SECURE)
     {
 #ifdef __WITH_DTLS__
-        int ret = CAdecryptSsl(&sep, (uint8_t *)recvBuffer, recvLen);
-        OIC_LOG_V(DEBUG, TAG, "CAdecryptSsl returns [%d]", ret);
+#ifdef TB_LOG
+        int decryptResult = 
+#endif
+        CAdecryptSsl(&sep, (uint8_t *)recvBuffer, recvLen);
+        OIC_LOG_V(DEBUG, TAG, "CAdecryptSsl returns [%d]", decryptResult);
 #else
         OIC_LOG(ERROR, TAG, "Encrypted message but no DTLS");
-#endif
+#endif // __WITH_DTLS__
     }
     else
     {
@@ -723,7 +725,7 @@ static CASocketFd_t CACreateSocket(int family, uint16_t *port, bool isMulticast)
         return OC_INVALID_SOCKET;
     }
 #endif
-    struct sockaddr_storage sa = { .ss_family = family };
+    struct sockaddr_storage sa = { .ss_family = (short)family };
     socklen_t socklen = 0;
 
     if (family == AF_INET6)
@@ -1350,7 +1352,7 @@ static void sendData(CASocketFd_t fd, const CAEndpoint_t *endpoint,
         else
         {
             sent += len;
-            if (sent != len)
+            if (sent != (size_t)len)
             {
                 OIC_LOG_V(DEBUG, TAG, "%s%s %s sendTo (Partial Send) is successful: "
                                       "currently sent: %ld bytes, "
index 5f40f13..0e7f907 100644 (file)
@@ -82,7 +82,7 @@ static CANewAddress_t *g_CAIPNetworkMonitorNewAddressQueue = NULL;
  */
 static struct CAIPCBData_t *g_CAIPNetworkMonitorAdapterCallbackList = NULL;
 
-static CAInterface_t *AllocateCAInterface(int index, const char *name, int family,
+static CAInterface_t *AllocateCAInterface(int index, const char *name, uint16_t family,
                                           const char *addr, int flags);
 
 static u_arraylist_t *GetInterfaceInformation(int desiredIndex);
@@ -176,6 +176,10 @@ static void CALLBACK IpAddressChangeCallback(void *context,
                                              MIB_UNICASTIPADDRESS_ROW *row,
                                              MIB_NOTIFICATION_TYPE notificationType)
 {
+    OC_UNUSED(notificationType);
+    OC_UNUSED(row);
+    OC_UNUSED(context);
+
     oc_mutex_lock(g_CAIPNetworkMonitorMutex);
 
     // Fetch new network address info.
@@ -584,7 +588,7 @@ CAResult_t CAIPUnSetNetworkMonitorCallback(CATransportAdapter_t adapter)
 /**
  * Allocate a new CAInterface_t entry for a given IP address.
  */
-static CAInterface_t *AllocateCAInterface(int index, const char *name, int family,
+static CAInterface_t *AllocateCAInterface(int index, const char *name, uint16_t family,
                                           const char *addr, int flags)
 {
     CAInterface_t *ifitem = (CAInterface_t *)OICCalloc(1, sizeof(*ifitem));
@@ -664,7 +668,7 @@ static bool IsValidNetworkAdapter(PIP_ADAPTER_ADDRESSES pAdapterAddr, int desire
 
     // If desiredIndex is non-zero, then only retrieve adapter corresponding to desiredIndex.
     // If desiredIndex is zero, then retrieve all adapters.
-    if (desiredIndex && (pAdapterAddr->IfIndex != desiredIndex))
+    if (desiredIndex && ((int)pAdapterAddr->IfIndex != desiredIndex))
     {
         OIC_LOG_V(DEBUG, TAG, "\t\tInterface %i not interesting.", pAdapterAddr->IfIndex);
         valid = false;
@@ -888,6 +892,8 @@ static u_arraylist_t *GetInterfaceInformation(int desiredIndex)
 
 u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex)
 {
+    OC_UNUSED(desiredIndex);
+
     u_arraylist_t *iflist = u_arraylist_create();
     if (!iflist)
     {
index d776872..71fe8f2 100755 (executable)
@@ -292,10 +292,10 @@ void CATCPAdapterHandler(CATransportAdapter_t adapter, CANetworkStatus_t status)
 
 static void CAInitializeTCPGlobals()
 {
-    caglobals.tcp.ipv4.fd = -1;
-    caglobals.tcp.ipv4s.fd = -1;
-    caglobals.tcp.ipv6.fd = -1;
-    caglobals.tcp.ipv6s.fd = -1;
+    caglobals.tcp.ipv4.fd = OC_INVALID_SOCKET;
+    caglobals.tcp.ipv4s.fd = OC_INVALID_SOCKET;
+    caglobals.tcp.ipv6.fd = OC_INVALID_SOCKET;
+    caglobals.tcp.ipv6s.fd = OC_INVALID_SOCKET;
 
     // Set the port number received from application.
     caglobals.tcp.ipv4.port = caglobals.ports.tcp.u4;
@@ -568,7 +568,6 @@ void CATCPSendDataThread(void *threadData)
     else
     {
         // Check payload length from CoAP over TCP format header.
-        CAResult_t result = CA_STATUS_OK;
         size_t payloadLen = CACheckPayloadLengthFromHeader(tcpData->data, tcpData->dataLen);
         if (!payloadLen)
         {
@@ -585,32 +584,33 @@ void CATCPSendDataThread(void *threadData)
         }
 
 #ifdef __WITH_TLS__
-         if (tcpData->remoteEndpoint && tcpData->remoteEndpoint->flags & CA_SECURE)
-         {
-             OIC_LOG(DEBUG, TAG, "CAencryptSsl called!");
-             result = CAencryptSsl(tcpData->remoteEndpoint, tcpData->data, tcpData->dataLen);
-
-             if (CA_STATUS_OK != result)
-             {
-                 OIC_LOG(ERROR, TAG, "CAAdapterNetDtlsEncrypt failed!");
-                 CASearchAndDeleteTCPSession(tcpData->remoteEndpoint);
-                 CATCPErrorHandler(tcpData->remoteEndpoint, tcpData->data, tcpData->dataLen,
-                                   CA_SEND_FAILED);
-             }
-             OIC_LOG_V(DEBUG, TAG,
-                       "CAAdapterNetDtlsEncrypt returned with result[%d]", result);
-            return;
-         }
+        CAResult_t result = CA_STATUS_OK;
+        if (tcpData->remoteEndpoint && tcpData->remoteEndpoint->flags & CA_SECURE)
+        {
+            OIC_LOG(DEBUG, TAG, "CAencryptSsl called!");
+            result = CAencryptSsl(tcpData->remoteEndpoint, tcpData->data, tcpData->dataLen);
+
+            if (CA_STATUS_OK != result)
+            {
+                OIC_LOG(ERROR, TAG, "CAAdapterNetDtlsEncrypt failed!");
+                CASearchAndDeleteTCPSession(tcpData->remoteEndpoint);
+                CATCPErrorHandler(tcpData->remoteEndpoint, tcpData->data, tcpData->dataLen,
+                                  CA_SEND_FAILED);
+            }
+            OIC_LOG_V(DEBUG, TAG,
+                      "CAAdapterNetDtlsEncrypt returned with result[%d]", result);
+           return;
+        }
 #endif
         //Processing for sending unicast
-         ssize_t dlen = CATCPSendData(tcpData->remoteEndpoint, tcpData->data, tcpData->dataLen);
-         if (-1 == dlen)
-         {
-             OIC_LOG(ERROR, TAG, "CATCPSendData failed");
-             CASearchAndDeleteTCPSession(tcpData->remoteEndpoint);
-             CATCPErrorHandler(tcpData->remoteEndpoint, tcpData->data, tcpData->dataLen,
-                               CA_SEND_FAILED);
-         }
+        ssize_t dlen = CATCPSendData(tcpData->remoteEndpoint, tcpData->data, tcpData->dataLen);
+        if (-1 == dlen)
+        {
+            OIC_LOG(ERROR, TAG, "CATCPSendData failed");
+            CASearchAndDeleteTCPSession(tcpData->remoteEndpoint);
+            CATCPErrorHandler(tcpData->remoteEndpoint, tcpData->data, tcpData->dataLen,
+                              CA_SEND_FAILED);
+        }
     }
 }
 
index 73812ec..22d3b5d 100644 (file)
@@ -770,7 +770,7 @@ static void CAReceiveMessage(CASocketFd_t fd)
             nbRead = tlsLength - svritem->tlsLen;
         }
 
-        len = recv(fd, svritem->tlsdata + svritem->tlsLen, (int)nbRead, 0);
+        len = recv(fd, (char*)svritem->tlsdata + svritem->tlsLen, (int)nbRead, 0);
         if (len < 0)
         {
             OIC_LOG_V(ERROR, TAG, "recv failed %s", strerror(errno));
@@ -802,7 +802,7 @@ static void CAReceiveMessage(CASocketFd_t fd)
         svritem->protocol = COAP;
 
         // svritem->tlsdata can also be used as receiving buffer in case of raw tcp
-        len = recv(fd, svritem->tlsdata, sizeof(svritem->tlsdata), 0);
+        len = recv(fd, (char*)svritem->tlsdata, sizeof(svritem->tlsdata), 0);
         if (len < 0)
         {
             OIC_LOG_V(ERROR, TAG, "recv failed %s", strerror(errno));
@@ -887,7 +887,7 @@ static CAResult_t CATCPCreateSocket(int family, CATCPSessionInfo_t *svritem)
     svritem->fd = fd;
 
     // #2. convert address from string to binary.
-    struct sockaddr_storage sa = { .ss_family = family };
+    struct sockaddr_storage sa = { .ss_family = (short)family };
     CAResult_t res = CAConvertNameToAddr(svritem->sep.endpoint.addr,
                                          svritem->sep.endpoint.port, &sa);
     if (CA_STATUS_OK != res)
@@ -943,7 +943,7 @@ static CASocketFd_t CACreateAcceptSocket(int family, CASocket_t *sock)
     }
 
     socklen_t socklen = 0;
-    struct sockaddr_storage server = { .ss_family = family };
+    struct sockaddr_storage server = { .ss_family = (short)family };
 
     CASocketFd_t fd = socket(family, SOCK_STREAM, IPPROTO_TCP);
     if (OC_INVALID_SOCKET == fd)
@@ -1198,13 +1198,13 @@ void CATCPSetConnectionChangedCallback(CATCPConnectionHandleCallback connHandler
 
 size_t CACheckPayloadLengthFromHeader(const void *data, size_t dlen)
 {
-    VERIFY_NON_NULL_RET(data, TAG, "data", -1);
+    VERIFY_NON_NULL_RET(data, TAG, "data", 0);
 
     coap_transport_t transport = coap_get_tcp_header_type_from_initbyte(
             ((unsigned char *)data)[0] >> 4);
 
     coap_pdu_t *pdu = coap_pdu_init2(0, 0,
-                                     ntohs(COAP_INVALID_TID),
+                                     ntohs((unsigned short)COAP_INVALID_TID),
                                      dlen, transport);
     if (!pdu)
     {
index fa958f4..269064a 100644 (file)
@@ -70,7 +70,7 @@ if 'CLIENT' in rd_mode or 'SERVER' in rd_mode:
 if target_os not in ['msys_nt', 'windows']:
     catest_env.AppendUnique(LIBS = ['m'])
 else:
-    catest_env.AppendUnique(CCFLAGS=['/W3', '/WX'])
+    catest_env.AppendUnique(CCFLAGS=['/W4', '/WX'])
 
 
 ######################################################################
index f0e1b21..83f411c 100644 (file)
@@ -704,7 +704,7 @@ unsigned char control_server_message_ECDHE_ECDSA_WITH_AES_128_CCM[] = {
     0x48, 0x45, 0x2d, 0x45, 0x43, 0x44, 0x53, 0x41, 0x2d, 0x57, 0x49, 0x54, 0x48, 0x2d, 0x41, 0x45,
     0x53, 0x2d, 0x31, 0x32, 0x38, 0x2d, 0x43, 0x43, 0x4d, 0x3c, 0x2f, 0x70, 0x3e, 0x0d, 0x0a
 };
-int control_server_message_ECDHE_ECDSA_WITH_AES_128_CCM_len = sizeof(control_server_message_ECDHE_ECDSA_WITH_AES_128_CCM);
+size_t control_server_message_ECDHE_ECDSA_WITH_AES_128_CCM_len = sizeof(control_server_message_ECDHE_ECDSA_WITH_AES_128_CCM);
 
 unsigned char control_server_message_ECDHE_ECDSA_WITH_AES_128_CCM_8[] = {
     0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0x0d,
@@ -719,7 +719,7 @@ unsigned char control_server_message_ECDHE_ECDSA_WITH_AES_128_CCM_8[] = {
     0x53, 0x2d, 0x31, 0x32, 0x38, 0x2d, 0x43, 0x43, 0x4d, 0x2d, 0x38, 0x3c, 0x2f, 0x70, 0x3e, 0x0d,
     0x0a
 };
-int control_server_message_ECDHE_ECDSA_WITH_AES_128_CCM_8_len = sizeof(control_server_message_ECDHE_ECDSA_WITH_AES_128_CCM_8);
+size_t control_server_message_ECDHE_ECDSA_WITH_AES_128_CCM_8_len = sizeof(control_server_message_ECDHE_ECDSA_WITH_AES_128_CCM_8);
 
 unsigned char control_server_message_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256[] = {
     0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0x0d,
@@ -734,7 +734,7 @@ unsigned char control_server_message_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256[] = {
     0x53, 0x2d, 0x31, 0x32, 0x38, 0x2d, 0x43, 0x42, 0x43, 0x2d, 0x53, 0x48, 0x41, 0x32, 0x35, 0x36,
     0x3c, 0x2f, 0x70, 0x3e, 0x0d, 0x0a
 };
-int control_server_message_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256_len = sizeof(control_server_message_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256);
+size_t control_server_message_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256_len = sizeof(control_server_message_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256);
 
 unsigned char control_server_message_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256[] = {
     0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0x0d,
@@ -749,7 +749,7 @@ unsigned char control_server_message_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256[] = {
     0x53, 0x2d, 0x31, 0x32, 0x38, 0x2d, 0x47, 0x43, 0x4D, 0x2d, 0x53, 0x48, 0x41, 0x32, 0x35, 0x36,
     0x3c, 0x2f, 0x70, 0x3e, 0x0d, 0x0a
 };
-int control_server_message_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256_len = sizeof(control_server_message_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256);
+size_t control_server_message_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256_len = sizeof(control_server_message_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256);
 
 unsigned char control_server_message_ECDHE_ECDSA_WITH_AES_128_CBC_SHA[] = {
     0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0x0d,
@@ -764,13 +764,13 @@ unsigned char control_server_message_ECDHE_ECDSA_WITH_AES_128_CBC_SHA[] = {
     0x53, 0x2d, 0x31, 0x32, 0x38, 0x2d, 0x43, 0x42, 0x43, 0x2d, 0x53, 0x48, 0x41, 0x3c, 0x2f, 0x70,
     0x3e, 0x0d, 0x0a
 };
-int control_server_message_ECDHE_ECDSA_WITH_AES_128_CBC_SHA_len = sizeof(control_server_message_ECDHE_ECDSA_WITH_AES_128_CBC_SHA);
+size_t control_server_message_ECDHE_ECDSA_WITH_AES_128_CBC_SHA_len = sizeof(control_server_message_ECDHE_ECDSA_WITH_AES_128_CBC_SHA);
 
 unsigned char control_client_message[] = {
     0x47, 0x45, 0x54, 0x20, 0x2f, 0x20, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x0d, 0x0a,
     0x0d, 0x0a
 };
-int control_client_message_len = sizeof(control_client_message);
+size_t control_client_message_len = sizeof(control_client_message);
 
 unsigned char control_server_message_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384[] = {
     0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0x0d,
@@ -785,7 +785,7 @@ unsigned char control_server_message_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384[] = {
     0x53, 0x2d, 0x32, 0x35, 0x36, 0x2d, 0x43, 0x42, 0x43, 0x2d, 0x53, 0x48, 0x41, 0x33, 0x38, 0x34,
     0x3c, 0x2f, 0x70, 0x3e, 0x0d, 0x0a
 };
-int control_server_message_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384_len = sizeof(control_server_message_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384);
+size_t control_server_message_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384_len = sizeof(control_server_message_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384);
 
 unsigned char control_server_message_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384[] = {
     0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0x0d,
@@ -800,7 +800,7 @@ unsigned char control_server_message_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384[] = {
     0x53, 0x2d, 0x32, 0x35, 0x36, 0x2d, 0x47, 0x43, 0x4D, 0x2d, 0x53, 0x48, 0x41, 0x33, 0x38, 0x34,
     0x3c, 0x2f, 0x70, 0x3e, 0x0d, 0x0a
 };
-int control_server_message_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384_len = sizeof(control_server_message_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384);
+size_t control_server_message_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384_len = sizeof(control_server_message_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384);
 
 static volatile bool socket_error = false;
 
@@ -906,7 +906,7 @@ static void infoCallback_that_loads_x509(PkiInfo_t * inf)
 
 static bool socketOpen_server()
 {
-    int portno;
+    unsigned short portno;
     struct sockaddr_in serv_addr, cli_addr;
     socklen_t clilen;
 
index caf7dfe..524dad6 100644 (file)
@@ -639,17 +639,6 @@ extern "C" {
 #define OC_RSRVD_REDIRECT_URI             "redirecturi"
 
 #define OC_RSRVD_CERTIFICATE              "certificate"
-/**
- * Mark a parameter as unused. Used to prevent unused variable compiler warnings.
- * Used in three cases:
- * 1. in callbacks when one of the parameters are unused
- * 2. when due to code changes a functions parameter is no longer
- *    used but must be left in place for backward compatibility
- *    reasons.
- * 3. a variable is only used in the debug build variant and would
- *    give a build warning in release mode.
- */
-#define OC_UNUSED(x) (void)(x)
 
 /**
  * These enums (OCTransportAdapter and OCTransportFlags) must