# - It is an acceptable approach for variable size structs.
# - warning C4201: nameless struct/union
# - Disabled due to IoTivity not being ANSI compatible
+ # - warning C4204: nonstandard extension used: non-constant aggregate initializer
+ # - Disabled due to IoTivity not being ANSI compatible and this is an appropriate way to intialize
+ # structs for non-legacy compilers.
# - warning C4214: bit field types other than int
# - 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', '/wd4214', '/wd4706'])
+ env.AppendUnique(CCFLAGS=['/wd4127', '/wd4200', '/wd4201', '/wd4204', '/wd4214', '/wd4232', '/wd4706'])
env.AppendUnique(CCFLAGS=['/EHsc'])
# define SIZE_MAX ((size_t)-1)
#endif
+#ifdef WITH_ARDUINO
+/**
+ * UINT16_MAX does not appear to be defined on Arduino so we define it here.
+ */
+# define UINT16_MAX 65535
+#endif
+
#endif
#define TAG "IPC"
-#define UINT16_MAX 65535
-
static int g_sockID = 0;
/**
if target_os in ['windows', 'msys_nt']:
libocsrm_env.AppendUnique(LIBPATH = [os.path.join(libocsrm_env.get('BUILD_DIR'), 'resource', 'oc_logger')])
- # Enable W4 but disable the following warning:
- # - 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.
- libocsrm_env.AppendUnique(CCFLAGS=['/wd4232', '/W4', '/WX'])
+ libocsrm_env.AppendUnique(CCFLAGS=['/W4', '/WX'])
if target_os in ['linux', 'android', 'tizen', 'msys_nt', 'windows'] and libocsrm_env.get('SECURED') == '1':
SConscript('provisioning/SConscript', 'libocsrm_env')
if target_os not in ['windows', 'msys_nt']:
liboctbstack_env.AppendUnique(LIBS = ['m'])
else:
- liboctbstack_env.AppendUnique(CCFLAGS=['/W3', '/WX'])
+ liboctbstack_env.AppendUnique(CCFLAGS=['/W4', '/WX'])
# octbstack.def specifies the list of functions exported by octbstack.dll.
liboctbstack_env.Replace(WINDOWS_INSERT_DEF = ['1'])
*
******************************************************************/
- #include "ocendpoint.h"
- #include "logger.h"
- #include "oic_malloc.h"
- #include "oic_string.h"
- #include <string.h>
- #include "cainterface.h"
+#include "ocendpoint.h"
+#include "logger.h"
+#include "oic_malloc.h"
+#include "oic_string.h"
+#include <string.h>
+#include "cainterface.h"
#define VERIFY_NON_NULL(arg) { if (!arg) {OIC_LOG(FATAL, TAG, #arg " is NULL"); goto exit;} }
#define VERIFY_GT_ZERO(arg) { if (arg < 1) {OIC_LOG(FATAL, TAG, #arg " < 1"); goto exit;} }
#define VERIFY_GT(arg1, arg2) { if (arg1 <= arg2) {OIC_LOG(FATAL, TAG, #arg1 " <= " #arg2); goto exit;} }
+#define VERIFY_LT_OR_EQ(arg1, arg2) { if (arg1 > arg2) {OIC_LOG(FATAL, TAG, #arg1 " > " #arg2); goto exit;} }
#define TAG "OIC_RI_ENDPOINT"
OCStackResult OCGetSupportedEndpointFlags(const OCTpsSchemeFlags givenFlags, OCTpsSchemeFlags* out)
// port start pos
tokPos = tmp + 1;
- VERIFY_GT_ZERO(atoi(tokPos));
+ char* end = NULL;
+ long port = strtol(tokPos, &end, 10);
+ VERIFY_GT_ZERO(port);
+ VERIFY_LT_OR_EQ(port, UINT16_MAX);
OIC_LOG_V(INFO, TAG, "parsed port is:%s", tokPos);
out->tps = tps;
out->addr = addr;
- out->port = atoi(tokPos);
+ out->port = (uint16_t)port;
}
OICFree(origin);
else
{
value->data = val.bytes;
- value->len = strlen(val.bytes);
+ value->len = strlen((const char*)val.bytes);
}
}
else
{
for (size_t j = 0; j < i; ++j)
{
- OCByteString* tmp = &(*array)[j];
- OICFree(tmp->bytes);
+ OCByteString* temp = &(*array)[j];
+ OICFree(temp->bytes);
}
OICFree(*array);
*array = NULL;
err |= cbor_encoder_create_array(&linkMap, &epsArray, epsCount);
VERIFY_CBOR_SUCCESS(TAG, err, "Failed setting endpoints array");
- for (size_t i = 0; i < epsCount; ++i)
+ for (size_t j = 0; j < epsCount; ++j)
{
CborEncoder endpointMap;
- OCEndpointPayload* endpoint = OCEndpointPayloadGetEndpoint(resource->eps, i);
+ OCEndpointPayload* endpoint = OCEndpointPayloadGetEndpoint(resource->eps, j);
VERIFY_PARAM_NON_NULL(TAG, endpoint, "Failed retrieving endpoint");
char* endpointStr = OCCreateEndpointString(endpoint);
endpoint = NULL;
int pri = 0;
char *endpointStr = NULL;
- OCStackResult ret = OC_STACK_ERROR;
endpoint = (OCEndpointPayload *)OICCalloc(1, sizeof(OCEndpointPayload));
VERIFY_PARAM_NON_NULL(TAG, endpoint, "Failed allocating endpoint payload");
err = cbor_value_dup_text_string(&curVal, &endpointStr, &len, NULL);
VERIFY_CBOR_SUCCESS(TAG, err, "to find endpoint value");
- ret = OCParseEndpointString(endpointStr, endpoint);
+ OCStackResult parseResult = OCParseEndpointString(endpointStr, endpoint);
OICFree(endpointStr);
- if (OC_STACK_OK == ret)
+ if (OC_STACK_OK == parseResult)
{
// pri
err = cbor_value_map_find_value(&epMap, OC_RSRVD_PRIORITY, &curVal);
}
else
{
- if (OC_STACK_ADAPTER_NOT_ENABLED == ret)
+ if (OC_STACK_ADAPTER_NOT_ENABLED == parseResult)
{
OIC_LOG(ERROR, TAG, "Ignore unrecognized endpoint info");
}
}
else
{
- result = OC_STACK_NO_MEMORY;
+ return OC_STACK_NO_MEMORY;
}
// Protocol Independent ID - Mandatory
{
OC_UNUSED(resourcePtr);
OC_UNUSED(devAddr);
- OCRepPayload *tempPayload = NULL;
- OCStackResult ret;
+
char *introspectionData = NULL;
size_t size = 0;
- ret = GetIntrospectionDataFromPS(&introspectionData, &size);
+ OCStackResult ret = GetIntrospectionDataFromPS(&introspectionData, &size);
if (OC_STACK_OK == ret)
{
OCRepPayload *tempPayload = OCRepPayloadCreate();
{
*payload = tempPayload;
}
+ else
+ {
+ OCRepPayloadDestroy(tempPayload);
+ ret = OC_STACK_ERROR;
+ }
}
else
{
if (ret != OC_STACK_OK)
{
OICFree(introspectionData);
- OCRepPayloadDestroy(tempPayload);
}
return ret;
OCRepPayload** payload, OCDevAddr *devAddr)
{
OC_UNUSED(devAddr);
+
size_t dimensions[3] = { 0, 0, 0 };
OCRepPayload *tempPayload = NULL;
OCRepPayload **urlInfoPayload = NULL;
goto exit;
}
- char *interfaceQuery = NULL;
- char *resourceTypeQuery = NULL;
-
CAEndpoint_t *networkInfo = NULL;
size_t infoSize = 0;
return;
}
- for (uint8_t i = start; i < responseInfo->info.numOptions; i++)
+ for (int i = start; i < responseInfo->info.numOptions; i++)
{
memcpy (&(response->rcvdVendorSpecificHeaderOptions[i-start]),
&(responseInfo->info.options[i]), sizeof(OCHeaderOption));
return (OCPayload*) payload;
}
-unsigned int GetNumOfTargetResource(OCAction *actionset)
+uint8_t GetNumOfTargetResource(OCAction *actionset)
{
- int numOfResource = 0;
+ uint8_t numOfResource = 0;
OCAction *pointerAction = actionset;
while (pointerAction != NULL)
{
+ assert(numOfResource < UINT8_MAX);
+
numOfResource++;
pointerAction = pointerAction->next;
}
{
OIC_LOG_V(INFO, TAG, "Execute ActionSet : %s",
actionset->actionsetName);
- unsigned int num = GetNumOfTargetResource(
- actionset->head);
+ uint8_t num = GetNumOfTargetResource(actionset->head);
((OCServerRequest *) ehRequest->requestHandle)->ehResponseHandler =
HandleAggregateResponse;
+
+ assert(num < UINT8_MAX);
+
((OCServerRequest *) ehRequest->requestHandle)->numResponses =
num + 1;
else if (strcmp(doWhat, GET_ACTIONSET) == 0)
{
char *plainText = NULL;
- OCActionSet *actionset = NULL;
+ OCActionSet *tempActionSet = NULL;
- GetActionSet(details, resource->actionsetHead, &actionset);
- if (actionset != NULL)
+ GetActionSet(details, resource->actionsetHead, &tempActionSet);
+ if (tempActionSet != NULL)
{
- BuildStringFromActionSet(actionset, &plainText);
+ BuildStringFromActionSet(tempActionSet, &plainText);
if (plainText != NULL)
{
VERIFY_SQLITE(sqlite3_bind_int64(stmtIF, sqlite3_bind_parameter_index(stmtIF, "@id"), id));
while (SQLITE_ROW == sqlite3_step(stmtIF))
{
- const unsigned char *itf = sqlite3_column_text(stmtIF, if_value_index);
- result = appendStringLL(&resourcePayload->interfaces, itf);
+ const unsigned char *tempItf = sqlite3_column_text(stmtIF, if_value_index);
+ result = appendStringLL(&resourcePayload->interfaces, tempItf);
if (OC_STACK_OK != result)
{
goto exit;
if (SQLITE_ROW == res || SQLITE_DONE == res)
{
const unsigned char *di = sqlite3_column_text(stmt1, di_index);
- const unsigned char *address = sqlite3_column_text(stmt1, address_index);
- OIC_LOG_V(DEBUG, TAG, " %s %s", di, address);
- discPayload->baseURI = OICStrdup((char *)address);
+ const unsigned char *tempAddress = sqlite3_column_text(stmt1, address_index);
+ OIC_LOG_V(DEBUG, TAG, " %s %s", di, tempAddress);
+ discPayload->baseURI = OICStrdup((char *)tempAddress);
if (!discPayload->baseURI)
{
result = OC_STACK_NO_MEMORY;
if target_os in ['msys_nt', 'windows']:
stacktest_env.PrependUnique(LIBS = ['sqlite3'])
- stacktest_env.AppendUnique(CCFLAGS=['/W3', '/WX'])
+ stacktest_env.AppendUnique(CCFLAGS=['/W4', '/WX'])
else:
stacktest_env.PrependUnique(LIBS = ['m'])
char *zoneId = NULL;
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCGetLinkLocalZoneId(0, NULL));
EXPECT_EQ(OC_STACK_ERROR, OCGetLinkLocalZoneId(9999, &zoneId));
- EXPECT_EQ(OC_STACK_ERROR, OCGetLinkLocalZoneId(-1, &zoneId));
+ EXPECT_EQ(OC_STACK_ERROR, OCGetLinkLocalZoneId(UINT32_MAX, &zoneId));
}