Commit ee3d0a17 authored by Alex Kelley's avatar Alex Kelley Committed by Dan Mihai

[IOT-1996] Make resource/csdk/connectivity W4 compliant.

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: default avatarAlex Kelley <alexke@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/18535Tested-by: default avatarjenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: default avatarDan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: default avatarMike Fenelon <mike.fenelon@microsoft.com>
(cherry picked from commit 7a811cc5)
Reviewed-on: https://gerrit.iotivity.org/gerrit/18749Reviewed-by: default avatarDave Thaler <dthaler@microsoft.com>
parent 3613c36e
......@@ -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'])
......
......@@ -108,4 +108,9 @@
# define UINT16_MAX 65535
#endif
/**
* Mark a parameter as unused. Used to prevent unused variable compiler warnings.
*/
#define OC_UNUSED(x) (void)(x)
#endif
......@@ -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']
......
......@@ -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.
......
......@@ -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);
......
......@@ -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)
{
......
......@@ -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, "=================================================");
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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();
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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, "
......
......@@ -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.