Commit 568aadcf authored by Pawel Winogrodzki's avatar Pawel Winogrodzki Committed by Dan Mihai

IOT-1583: Removing /W3 warnings inside connectivity/ (part 1)

Removing the /W3 warnings in order to add the /WX option to prevent new
ones from being added inside the resource/csdk/connectivity/ directory.

Change-Id: Ibd53ad378b5d960ea59f2e2c61254a9257d03a3e
Signed-off-by: default avatarPawel Winogrodzki <pawelwi@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17419Tested-by: default avatarjenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: default avatarDan Mihai <Daniel.Mihai@microsoft.com>
parent fc3e6746
......@@ -25,6 +25,7 @@
* functions to write to the pipe and read from the pipe.
*/
#include <cinttypes>
#include <string.h>
#include <errno.h>
#include "messageHandler.h"
......@@ -35,7 +36,6 @@
#include "platform_features.h"
#include "oic_malloc.h"
#include "logger.h"
#include <cinttypes>
#define TAG "PIPE_HANDLER"
......
......@@ -6,14 +6,15 @@ import os.path
# Set common flags
if env['CC'] == 'cl':
# Enable warnings as errors.
# - warning C4133: incompatible type conversion
env.AppendUnique(CCFLAGS=['/we4133'])
# Disable the following warnings:
# - warning C4127: conditional expression is constant
# - Disabled due to the widespread usage in IoTivity
env.AppendUnique(CCFLAGS=['/wd4127'])
# - warning C4200: zero-sized array in struct/union.
# - It is an acceptable approach for variable size structs.
env.AppendUnique(CCFLAGS=['/wd4127', '/wd4200'])
env.AppendUnique(CCFLAGS=['/EHsc'])
......
......@@ -28,6 +28,7 @@
#include "iotivity_config.h"
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
......
......@@ -216,7 +216,7 @@ CAResult_t CAUnSelectNetwork(CATransportAdapter_t nonInterestedNetwork);
* @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_STATUS_NOT_INITIALIZED or
* ::CA_STATUS_INVALID_PARAM or ::CA_MEMORY_ALLOC_FAILED
*/
CAResult_t CAGetNetworkInformation(CAEndpoint_t **info, uint32_t *size);
CAResult_t CAGetNetworkInformation(CAEndpoint_t **info, size_t *size);
/**
* Get supported network adapter.
......
......@@ -29,6 +29,31 @@ extern "C"
{
#endif /* __cplusplus */
/**
* Macro to verify the validity of input argument.
*
* @param expr Expression to verify.
* @param log_tag Log tag.
* @param log_message Log message.
*/
#define VERIFY_TRUE(expr, log_tag, log_message) \
VERIFY_TRUE_RET((expr), (log_tag), (log_message), CA_STATUS_INVALID_PARAM)
/**
* Macro to verify the validity of input argument.
*
* @param expr Expression to verify.
* @param log_tag Log tag.
* @param log_message Log message.
* @param ret Return value.
*/
#define VERIFY_TRUE_RET(expr, log_tag, log_message, ret) \
if (!(expr)) \
{ \
OIC_LOG_V(ERROR, (log_tag), "Invalid input: %s", (log_message)); \
return (ret); \
} \
/**
* Macro to verify the validity of input argument.
*
......@@ -38,11 +63,7 @@ extern "C"
* @param ret return value
*/
#define VERIFY_NON_NULL_RET(arg, log_tag, log_message, ret) \
if (NULL == (arg)) \
{ \
OIC_LOG_V(ERROR, (log_tag), "Invalid input:%s", (log_message)); \
return (ret); \
} \
VERIFY_TRUE_RET(NULL != (arg), (log_tag), (log_message), (ret))
/**
* Macro to verify the validity of input argument.
......
......@@ -39,8 +39,8 @@ extern "C"
typedef struct u_arraylist_t
{
void **data;
uint32_t length;
uint32_t capacity;
size_t length;
size_t capacity;
} u_arraylist_t;
/**
......@@ -86,7 +86,7 @@ void u_arraylist_shrink_to_fit(u_arraylist_t *list);
* @param[in] index index of array list.
* @return void pointer of data if success or NULL pointer otherwise.
*/
void *u_arraylist_get(const u_arraylist_t *list, uint32_t index);
void *u_arraylist_get(const u_arraylist_t *list, size_t index);
/**
* Returns the index of the data from the array list.
......@@ -95,7 +95,7 @@ void *u_arraylist_get(const u_arraylist_t *list, uint32_t index);
* @param[out]index index of array list.
* @return true if success, false otherwise.
*/
bool u_arraylist_get_index(const u_arraylist_t *list, const void *data, uint32_t *index);
bool u_arraylist_get_index(const u_arraylist_t *list, const void *data, size_t *index);
/**
* Add data in the array list.
......@@ -111,14 +111,14 @@ bool u_arraylist_add(u_arraylist_t *list, void *data);
* @param[in] index index of array list.
* @return void pointer of the data if success or NULL pointer otherwise.
*/
void *u_arraylist_remove(u_arraylist_t *list, uint32_t index);
void *u_arraylist_remove(u_arraylist_t *list, size_t index);
/**
* Returns the length of the array list.
* @param[in] list pointer of array list.
* @return length of the array list.
*/
uint32_t u_arraylist_length(const u_arraylist_t *list);
size_t u_arraylist_length(const u_arraylist_t *list);
/**
* Returns whether the data exists or not.
......
......@@ -188,7 +188,7 @@ CAResult_t ca_thread_pool_add_task(ca_thread_pool_t thread_pool, ca_thread_func
int thrRet = oc_thread_new(&threadInfo->thread, ca_thread_pool_pthreads_delegate, info);
if (thrRet != 0)
{
uint32_t index = 0;
size_t index = 0;
if (u_arraylist_get_index(thread_pool->details->threads_list, threadInfo, &index))
{
u_arraylist_remove(thread_pool->details->threads_list, index);
......@@ -216,7 +216,7 @@ void ca_thread_pool_free(ca_thread_pool_t thread_pool)
oc_mutex_lock(thread_pool->details->list_lock);
for (uint32_t i = 0; i < u_arraylist_length(thread_pool->details->threads_list); ++i)
for (size_t i = 0; i < u_arraylist_length(thread_pool->details->threads_list); ++i)
{
ca_thread_pool_thread_info_t *threadInfo = (ca_thread_pool_thread_info_t *)
u_arraylist_get(thread_pool->details->threads_list, i);
......
......@@ -110,7 +110,7 @@ void u_arraylist_shrink_to_fit(u_arraylist_t *list)
}
}
void *u_arraylist_get(const u_arraylist_t *list, uint32_t index)
void *u_arraylist_get(const u_arraylist_t *list, size_t index)
{
if (!list )
{
......@@ -125,14 +125,14 @@ void *u_arraylist_get(const u_arraylist_t *list, uint32_t index)
return NULL;
}
bool u_arraylist_get_index(const u_arraylist_t *list, const void *data, uint32_t *index)
bool u_arraylist_get_index(const u_arraylist_t *list, const void *data, size_t *index)
{
if (!list || !data)
{
return false;
}
for (uint32_t i = 0; i < list->length; i++)
for (size_t i = 0; i < list->length; i++)
{
if (data == list->data[i])
{
......@@ -169,7 +169,7 @@ bool u_arraylist_add(u_arraylist_t *list, void *data)
list->data = (void **) tmp;
memset(list->data + list->capacity, 0,
(new_capacity - list->capacity) * sizeof(list->data[0]));
list->capacity = (uint32_t)new_capacity;
list->capacity = new_capacity;
}
list->data[list->length] = data;
......@@ -178,7 +178,7 @@ bool u_arraylist_add(u_arraylist_t *list, void *data)
return true;
}
void *u_arraylist_remove(u_arraylist_t *list, uint32_t index)
void *u_arraylist_remove(u_arraylist_t *list, size_t index)
{
void *removed = NULL;
......@@ -201,7 +201,7 @@ void *u_arraylist_remove(u_arraylist_t *list, uint32_t index)
return removed;
}
uint32_t u_arraylist_length(const u_arraylist_t *list)
size_t u_arraylist_length(const u_arraylist_t *list)
{
if (!list)
{
......@@ -218,7 +218,7 @@ bool u_arraylist_contains(const u_arraylist_t *list, const void *data)
return false;
}
for (uint32_t i = 0; i < list->length; i++)
for (size_t i = 0; i < list->length; i++)
{
if (data == list->data[i])
{
......@@ -236,7 +236,7 @@ void u_arraylist_destroy(u_arraylist_t *list)
{
return;
}
for (uint32_t i = 0; i < list->length; i++)
for (size_t i = 0; i < list->length; i++)
{
OICFree(list->data[i]);
}
......
......@@ -123,7 +123,7 @@ void CAdeinitSslAdapter();
*
*/
CAResult_t CAencryptSsl(const CAEndpoint_t *endpoint, void *data, uint32_t dataLen);
CAResult_t CAencryptSsl(const CAEndpoint_t *endpoint, void *data, size_t dataLen);
/**
* Performs TLS decryption of the data.
......@@ -138,7 +138,7 @@ CAResult_t CAencryptSsl(const CAEndpoint_t *endpoint, void *data, uint32_t dataL
* @retval ::CA_STATUS_FAILED Operation failed.
*
*/
CAResult_t CAdecryptSsl(const CASecureEndpoint_t *sep, uint8_t *data, uint32_t dataLen);
CAResult_t CAdecryptSsl(const CASecureEndpoint_t *sep, uint8_t *data, size_t dataLen);
/**
* Initiate TLS handshake with selected cipher suite.
......
......@@ -114,7 +114,7 @@ typedef int32_t (*CAAdapterSendMulticastData)(const CAEndpoint_t *endpoint,
* @param[out] size Number of local connectivity structures.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h)
*/
typedef CAResult_t (*CAAdapterGetNetworkInfo)(CAEndpoint_t **info, uint32_t *size);
typedef CAResult_t (*CAAdapterGetNetworkInfo)(CAEndpoint_t **info, size_t *size);
/**
* Read Synchronous API callback.
......
......@@ -477,14 +477,14 @@ CAPayload_t CAGetPayloadInfo(const CAData_t *data, size_t *payloadLen);
* @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
CAResult_t CAUpdateBlockOptionType(const CABlockDataID_t *blockID,
uint8_t blockType);
uint16_t blockType);
/**
* Get the block option type from block-wise transfer list.
* @param[in] blockID ID set of CABlockData.
* @return block option type.
*/
uint8_t CAGetBlockOptionType(const CABlockDataID_t *blockID);
uint16_t CAGetBlockOptionType(const CABlockDataID_t *blockID);
/**
* Get the block data from block-wise transfer list.
......
......@@ -118,7 +118,7 @@ CAResult_t CASetAdapterRAInfo(const CARAInfo_t *caraInfo);
* @param[out] size number of connectivity information structures.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
CAResult_t CAGetNetworkInfo(CAEndpoint_t **info, uint32_t *size);
CAResult_t CAGetNetworkInfo(CAEndpoint_t **info, size_t *size);
/**
* Sends unicast data to the remote endpoint.
......
......@@ -61,7 +61,7 @@ u_arraylist_t *CAGetSelectedNetworkList();
* @param[out] size No Of Array objects.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
CAResult_t CAGetNetworkInformationInternal(CAEndpoint_t **info, uint32_t *size);
CAResult_t CAGetNetworkInformationInternal(CAEndpoint_t **info, size_t *size);
/**
* Terminate network type from selected configuration.
......
......@@ -86,7 +86,8 @@ CAResult_t CAGenerateVariableForFragmentation(size_t dataLength,
size_t *totalLength,
uint16_t mtuSize)
{
OIC_LOG_V(DEBUG, TAG, "IN, dataLength = %zu, mtu = %zu", dataLength, mtuSize);
OIC_LOG_V(DEBUG, TAG, "IN, dataLength = %" PRIuPTR ", mtu = %u",
dataLength, (uint32_t)mtuSize);
size_t remainDataSize = 0;
size_t dataOnlyLen =
......
......@@ -30,6 +30,7 @@
#define _DEFAULT_SOURCE
#define _BSD_SOURCE
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -66,7 +67,7 @@ static bool CACheckPayloadLength(const CAData_t *sendData)
// check if message has to be transfered to a block
size_t maxBlockSize = BLOCK_SIZE(CA_DEFAULT_BLOCK_SIZE);
OIC_LOG_V(DEBUG, TAG, "payloadLen=%zu, maxBlockSize=%zu", payloadLen, maxBlockSize);
OIC_LOG_V(DEBUG, TAG, "payloadLen=%" PRIuPTR ", maxBlockSize=%" PRIuPTR, payloadLen, maxBlockSize);
if (payloadLen <= maxBlockSize)
{
......@@ -311,6 +312,8 @@ CAResult_t CAReceiveBlockWiseData(coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
VERIFY_NON_NULL(pdu->transport_hdr, TAG, "pdu->transport_hdr");
VERIFY_NON_NULL(endpoint, TAG, "endpoint");
VERIFY_NON_NULL(receivedData, TAG, "receivedData");
VERIFY_TRUE((pdu->transport_hdr->udp.token_length <= UINT8_MAX), TAG,
"pdu->transport_hdr->udp.token_length");
// check if received message type is CA_MSG_RESET
if (CA_EMPTY == pdu->transport_hdr->udp.code)
......@@ -397,7 +400,7 @@ CAResult_t CAReceiveBlockWiseData(coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
{
CABlockDataID_t* blockDataID = CACreateBlockDatablockId(
(CAToken_t)pdu->transport_hdr->udp.token,
pdu->transport_hdr->udp.token_length,
(uint8_t)pdu->transport_hdr->udp.token_length,
endpoint->addr, endpoint->port);
if (NULL == blockDataID || blockDataID->idLength < 1)
{
......@@ -455,7 +458,7 @@ CAResult_t CAReceiveBlockWiseData(coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
if (receivedData->responseInfo)
{
CARemoveBlockDataFromListWithSeed((CAToken_t)pdu->transport_hdr->udp.token,
pdu->transport_hdr->udp.token_length,
(uint8_t)pdu->transport_hdr->udp.token_length,
endpoint->addr, endpoint->port);
}
return CA_NOT_SUPPORTED;
......@@ -682,6 +685,8 @@ CAResult_t CASendErrorMessage(const coap_pdu_t *pdu, uint8_t status,
VERIFY_NON_NULL(pdu, TAG, "pdu");
VERIFY_NON_NULL(pdu->transport_hdr, TAG, "pdu->transport_hdr");
VERIFY_NON_NULL(blockID, TAG, "blockID");
VERIFY_TRUE((pdu->transport_hdr->udp.token_length <= UINT8_MAX), TAG,
"pdu->transport_hdr->udp.token_length");
// create error responseInfo
CABlockData_t *data = CAGetBlockDataFromBlockDataList(blockID);
......@@ -722,7 +727,7 @@ CAResult_t CASendErrorMessage(const coap_pdu_t *pdu, uint8_t status,
}
else
{
CAInfo_t responseData = { .tokenLength = pdu->transport_hdr->udp.token_length };
CAInfo_t responseData = { .tokenLength = (uint8_t)pdu->transport_hdr->udp.token_length };
responseData.token = (CAToken_t) OICMalloc(responseData.tokenLength);
if (!responseData.token)
{
......@@ -825,7 +830,7 @@ CAResult_t CAReceiveLastBlock(const CABlockDataID_t *blockID, const CAData_t *re
static CABlockData_t* CACheckTheExistOfBlockData(const CABlockDataID_t* blockDataID,
coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
uint8_t blockType)
uint16_t blockType)
{
// Get BlockData data. If does not exist, create a new data
CABlockData_t *data = CAGetBlockDataFromBlockDataList(blockDataID);
......@@ -871,12 +876,14 @@ CAResult_t CASetNextBlockOption1(coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
VERIFY_NON_NULL(pdu->transport_hdr, TAG, "pdu->transport_hdr");
VERIFY_NON_NULL(endpoint, TAG, "endpoint");
VERIFY_NON_NULL(receivedData, TAG, "receivedData");
VERIFY_TRUE((pdu->transport_hdr->udp.token_length <= UINT8_MAX), TAG,
"pdu->transport_hdr->udp.token_length");
OIC_LOG_V(INFO, TAG, "num:%d, M:%d, sze:%d", block.num, block.m, block.szx);
CABlockDataID_t* blockDataID = CACreateBlockDatablockId(
(CAToken_t)pdu->transport_hdr->udp.token,
pdu->transport_hdr->udp.token_length,
(uint8_t)pdu->transport_hdr->udp.token_length,
endpoint->addr, endpoint->port);
if (NULL == blockDataID || blockDataID->idLength < 1)
{
......@@ -1016,10 +1023,12 @@ CAResult_t CASetNextBlockOption2(coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
VERIFY_NON_NULL(pdu->transport_hdr, TAG, "pdu->transport_hdr");
VERIFY_NON_NULL(endpoint, TAG, "endpoint");
VERIFY_NON_NULL(receivedData, TAG, "receivedData");
VERIFY_TRUE((pdu->transport_hdr->udp.token_length <= UINT8_MAX), TAG,
"pdu->transport_hdr->udp.token_length");
CABlockDataID_t* blockDataID = CACreateBlockDatablockId(
(CAToken_t)pdu->transport_hdr->udp.token,
pdu->transport_hdr->udp.token_length,
(uint8_t)pdu->transport_hdr->udp.token_length,
endpoint->addr, endpoint->port);
if (NULL == blockDataID || blockDataID->idLength < 1)
{
......@@ -1395,18 +1404,22 @@ CAResult_t CAAddBlockOption(coap_pdu_t **pdu, const CAInfo_t *info,
VERIFY_NON_NULL(info, TAG, "info");
VERIFY_NON_NULL(endpoint, TAG, "endpoint");
VERIFY_NON_NULL(options, TAG, "options");
VERIFY_TRUE(((*pdu)->transport_hdr->udp.token_length <= UINT8_MAX), TAG,
"pdu->transport_hdr->udp.token_length");
VERIFY_TRUE((info->payloadSize <= COAP_MAX_PDU_SIZE), TAG,
"info->payloadSize");
CAResult_t res = CA_STATUS_OK;
size_t dataLength = 0;
unsigned int dataLength = 0;
if (info->payload)
{
dataLength = info->payloadSize;
OIC_LOG_V(DEBUG, TAG, "dataLength - %zu", dataLength);
dataLength = (unsigned int)info->payloadSize;
OIC_LOG_V(DEBUG, TAG, "dataLength - %" PRIuPTR, dataLength);
}
CABlockDataID_t* blockDataID = CACreateBlockDatablockId(
(CAToken_t)(*pdu)->transport_hdr->udp.token,
(*pdu)->transport_hdr->udp.token_length,
(uint8_t)(*pdu)->transport_hdr->udp.token_length,
endpoint->addr, endpoint->port);
if (NULL == blockDataID || blockDataID->idLength < 1)
{
......@@ -1423,7 +1436,7 @@ CAResult_t CAAddBlockOption(coap_pdu_t **pdu, const CAInfo_t *info,
goto exit;
}
uint8_t blockType = CAGetBlockOptionType(blockDataID);
uint16_t blockType = CAGetBlockOptionType(blockDataID);
if (COAP_OPTION_BLOCK2 == blockType)
{
res = CAAddBlockOption2(pdu, info, dataLength, blockDataID, options);
......@@ -1468,7 +1481,7 @@ CAResult_t CAAddBlockOption(coap_pdu_t **pdu, const CAInfo_t *info,
OIC_LOG_V(DEBUG, TAG, "[%d] pdu length after option", (*pdu)->length);
// if response data is so large. it have to send as block transfer
if (!coap_add_data(*pdu, dataLength, (const unsigned char *) info->payload))
if (!coap_add_data(*pdu, dataLength, (const unsigned char*)info->payload))
{
OIC_LOG(INFO, TAG, "it has to use block");
res = CA_STATUS_FAILED;
......@@ -1513,6 +1526,7 @@ CAResult_t CAAddBlockOption2(coap_pdu_t **pdu, const CAInfo_t *info, size_t data
VERIFY_NON_NULL(info, TAG, "info");
VERIFY_NON_NULL(blockID, TAG, "blockID");
VERIFY_NON_NULL(options, TAG, "options");
VERIFY_TRUE((dataLength <= COAP_MAX_PDU_SIZE), TAG, "dataLength");
// get set block data from CABlock list-set.
coap_block_t *block1 = CAGetBlockOption(blockID, COAP_OPTION_BLOCK1);
......@@ -1567,7 +1581,8 @@ CAResult_t CAAddBlockOption2(coap_pdu_t **pdu, const CAInfo_t *info, size_t data
goto exit;
}
if (!coap_add_block(*pdu, dataLength, (const unsigned char *) info->payload,
if (!coap_add_block(*pdu, (unsigned int)dataLength,
(const unsigned char *) info->payload,
block2->num, block2->szx))
{
OIC_LOG(ERROR, TAG, "Data length is smaller than the start index");
......@@ -1618,6 +1633,7 @@ CAResult_t CAAddBlockOption1(coap_pdu_t **pdu, const CAInfo_t *info, size_t data
VERIFY_NON_NULL(info, TAG, "info");
VERIFY_NON_NULL(blockID, TAG, "blockID");
VERIFY_NON_NULL(options, TAG, "options");
VERIFY_TRUE((dataLength <= COAP_MAX_PDU_SIZE), TAG, "dataLength");
// get set block data from CABlock list-set.
coap_block_t *block1 = CAGetBlockOption(blockID, COAP_OPTION_BLOCK1);
......@@ -1662,7 +1678,8 @@ CAResult_t CAAddBlockOption1(coap_pdu_t **pdu, const CAInfo_t *info, size_t data
}
// add the payload data as the block size.
if (!coap_add_block(*pdu, dataLength, (const unsigned char *) info->payload, block1->num,
if (!coap_add_block(*pdu, (unsigned int)dataLength,
(const unsigned char *) info->payload, block1->num,
block1->szx))
{
OIC_LOG(ERROR, TAG, "Data length is smaller than the start index");
......@@ -1690,7 +1707,8 @@ CAResult_t CAAddBlockOption1(coap_pdu_t **pdu, const CAInfo_t *info, size_t data
}
// add the payload data as the block size.
if (!coap_add_data(*pdu, dataLength, (const unsigned char *) info->payload))
if (!coap_add_data(*pdu, (unsigned int)dataLength,
(const unsigned char*)info->payload))
{
OIC_LOG(ERROR, TAG, "failed to add payload");
return CA_STATUS_FAILED;
......@@ -1764,9 +1782,9 @@ CAResult_t CAAddOptionToPDU(coap_pdu_t *pdu, coap_list_t **options)
COAP_OPTION_DATA(*(coap_option *) opt->data));
OIC_LOG_V(DEBUG, TAG, "[%d] pdu length", pdu->length);
int ret = coap_add_option(pdu, COAP_OPTION_KEY(*(coap_option *) opt->data),
COAP_OPTION_LENGTH(*(coap_option *) opt->data),
COAP_OPTION_DATA(*(coap_option *) opt->data));
size_t ret = coap_add_option(pdu, COAP_OPTION_KEY(*(coap_option *) opt->data),
COAP_OPTION_LENGTH(*(coap_option *) opt->data),
COAP_OPTION_DATA(*(coap_option *) opt->data));
if (!ret)
{
return CA_STATUS_FAILED;
......@@ -1785,6 +1803,7 @@ CAResult_t CAAddBlockSizeOption(coap_pdu_t *pdu, uint16_t sizeType, size_t dataL
OIC_LOG(DEBUG, TAG, "IN-CAAddBlockSizeOption");
VERIFY_NON_NULL(pdu, TAG, "pdu");
VERIFY_NON_NULL(options, TAG, "options");
VERIFY_TRUE((dataLength <= UINT_MAX), TAG, "dataLength");
if (sizeType != COAP_OPTION_SIZE1 && sizeType != COAP_OPTION_SIZE2)
{
......@@ -1793,7 +1812,8 @@ CAResult_t CAAddBlockSizeOption(coap_pdu_t *pdu, uint16_t sizeType, size_t dataL
}
unsigned char value[BLOCKWISE_OPTION_BUFFER] = { 0 };
unsigned int optionLength = coap_encode_var_bytes(value, dataLength);
unsigned int optionLength = coap_encode_var_bytes(value,
(unsigned int)dataLength);
int ret = coap_insert(options,
CACreateNewOptionNode(sizeType, optionLength, (char *) value),
......@@ -1831,7 +1851,7 @@ bool CAIsPayloadLengthInPduWithBlockSizeOption(coap_pdu_t *pdu,
*totalPayloadLen = coap_decode_var_bytes(COAP_OPT_VALUE(option),
COAP_OPT_LENGTH(option));
OIC_LOG_V(DEBUG, TAG, "the total payload length to be received is [%zu]bytes",
OIC_LOG_V(DEBUG, TAG, "the total payload length to be received is [%" PRIuPTR "]bytes",
*totalPayloadLen);
return true;
......@@ -1896,16 +1916,16 @@ uint8_t CACheckBlockErrorType(CABlockData_t *currData, coap_block_t *receivedBlo
if (receivedBlock->m && blockPayloadLen != (size_t) BLOCK_SIZE(receivedBlock->szx))
{
// 413 Error handling of too large entity
if (COAP_MAX_PDU_SIZE < BLOCK_SIZE(receivedBlock->szx) + optionLen)
if (COAP_MAX_PDU_SIZE < ((size_t)BLOCK_SIZE(receivedBlock->szx)) + optionLen)
{
// buffer size is smaller than received block size
OIC_LOG(ERROR, TAG, "error type 4.13");
OIC_LOG(ERROR, TAG, "too large size");
// set the block size to be smaller than COAP_MAX_PDU_SIZE
for (int32_t size = CA_DEFAULT_BLOCK_SIZE; size >= 0; size--)
for (unsigned int size = CA_DEFAULT_BLOCK_SIZE; size >= 0; size--)
{
if (COAP_MAX_PDU_SIZE >= BLOCK_SIZE(size) + optionLen)
if (COAP_MAX_PDU_SIZE >= (size_t)BLOCK_SIZE(size) + optionLen)
{
OIC_LOG_V(ERROR, TAG, "replace sze with %d", size);
currData->block2.szx = size;
......@@ -2028,6 +2048,8 @@ CAData_t* CACreateNewDataSet(const coap_pdu_t *pdu, const CAEndpoint_t *endpoint
VERIFY_NON_NULL_RET(pdu, TAG, "pdu", NULL);
VERIFY_NON_NULL_RET(pdu->transport_hdr, TAG, "pdu->transport_hdr", NULL);
VERIFY_NON_NULL_RET(endpoint, TAG, "endpoint", NULL);
VERIFY_TRUE_RET((pdu->transport_hdr->udp.token_length <= UINT8_MAX), TAG,
"pdu->transport_hdr->udp.token_length", NULL);
CARequestInfo_t* requestInfo = NULL;
CAResponseInfo_t* responseInfo = NULL;
......@@ -2035,7 +2057,7 @@ CAData_t* CACreateNewDataSet(const coap_pdu_t *pdu, const CAEndpoint_t *endpoint
uint32_t code = pdu->transport_hdr->udp.code;
if (CA_GET == code || CA_POST == code || CA_PUT == code || CA_DELETE == code)
{
CAInfo_t responseData = { .tokenLength = pdu->transport_hdr->udp.token_length };
CAInfo_t responseData = { .tokenLength = (uint8_t)pdu->transport_hdr->udp.token_length };
responseData.token = (CAToken_t) OICMalloc(responseData.tokenLength);
if (!responseData.token)
{
......@@ -2055,7 +2077,7 @@ CAData_t* CACreateNewDataSet(const coap_pdu_t *pdu, const CAEndpoint_t *endpoint
}
else
{
CAInfo_t requestData = { .tokenLength = pdu->transport_hdr->udp.token_length };
CAInfo_t requestData = { .tokenLength = (uint8_t)pdu->transport_hdr->udp.token_length };
requestData.token = (CAToken_t) OICMalloc(requestData.tokenLength);
if (!requestData.token)
{
......@@ -2249,7 +2271,7 @@ CAResult_t CAHandleBlockErrorResponse(coap_block_t *block, uint16_t blockType,
return CA_STATUS_OK;
}
CAResult_t CAUpdateBlockOptionType(const CABlockDataID_t *blockID, uint8_t blockType)
CAResult_t CAUpdateBlockOptionType(const CABlockDataID_t *blockID, uint16_t blockType)
{
OIC_LOG(DEBUG, TAG, "IN-UpdateBlockOptionType");
VERIFY_NON_NULL(blockID, TAG, "blockID");
......@@ -2274,7 +2296,7 @@ CAResult_t CAUpdateBlockOptionType(const CABlockDataID_t *blockID, uint8_t block
return CA_STATUS_FAILED;
}
uint8_t CAGetBlockOptionType(const CABlockDataID_t *blockID)
uint16_t CAGetBlockOptionType(const CABlockDataID_t *blockID)
{
OIC_LOG(DEBUG, TAG, "IN-GetBlockOptionType");
VERIFY_NON_NULL_RET(blockID, TAG, "blockID", 0);
......
......@@ -288,7 +288,7 @@ void CADestroyToken(CAToken_t token)
OIC_LOG(DEBUG, TAG, "OUT");
}
CAResult_t CAGetNetworkInformation(CAEndpoint_t **info, uint32_t *size)
CAResult_t CAGetNetworkInformation(CAEndpoint_t **info, size_t *size)
{
OIC_LOG(DEBUG, TAG, "CAGetNetworkInformation");
......
......@@ -52,7 +52,7 @@
static CAConnectivityHandler_t *g_adapterHandler = NULL;
static uint32_t g_numberOfAdapters = 0;
static size_t g_numberOfAdapters = 0;