Commit 20dbb631 authored by Oleksandr Dmytrenko's avatar Oleksandr Dmytrenko Committed by Aleksey

cc1plus: all warnings being treated as errors fix

1) error: missing initializer for member OicSecKey::len
2) ISO C++ forbids converting a string constant to 'char*'
3) _POSIX_C_SOURCE redefined

Change-Id: Ib74fd60f124d58213afc9855b71c38ba6d00503c
Signed-off-by: default avatarOleksandr Dmytrenko <o.dmytrenko@samsung.com>
parent c30f25a5
......@@ -411,6 +411,15 @@ struct OicUuid
uint8_t id[UUID_LENGTH];
};
#ifndef OC_ZERO_UUID
# if (__STDC_VERSION__ >= 199901L)
# define OC_ZERO_UUID {.id={0}}
# else
# define OC_ZERO_UUID {{0}}
# endif
#endif
/**
* /oic/sec/jwk (JSON Web Key) data type.
* See JSON Web Key (JWK) draft-ietf-jose-json-web-key-41
......@@ -426,6 +435,14 @@ struct OicSecKey
};
#ifndef OC_INIT_SEC_KEY
# if (__STDC_VERSION__ >= 199901L)
# define OC_INIT_SEC_KEY(_data, _len, _encoding) {.data=(_data), .len=(_len), .encoding=(_encoding)}
# else
# define OC_INIT_SEC_KEY(_data, _len, _encoding) {(_data), (_len), (_encoding)}
# endif
#endif
struct OicSecOpt
{
uint8_t *data;
......
......@@ -210,7 +210,7 @@ int32_t GetDtlsPskCredentials( CADtlsPskCredType_t type,
unsigned char *result, size_t result_length);
/*
* This internal callback is used to retrieve UUIDs from CRED
* This internal callback is used to retrieve UUIDs from CRED
* entries that have matching publicData.
*
* @param ctx context holding UUID list
......@@ -344,4 +344,12 @@ void FreeCred(OicSecCred_t *cred);
*/
bool IsCredRowneruuidTheNilUuid();
#ifndef OC_CBOR_VALUE_INIT
# if (__STDC_VERSION__ >= 199901L)
# define OC_CBOR_VALUE_INIT {.parser = NULL, .ptr = NULL, .remaining = 0, .extra = 0, .type = 0, .flags = 0}
# else
# define OC_CBOR_VALUE_INIT {NULL, NULL, 0, 0, 0, 0}
# endif
#endif
#endif //IOTVT_SRM_CREDR_H
......@@ -173,7 +173,7 @@ static void provisionCredCB(void* ctx, size_t nOfRes, OCProvisionResult_t* arr,
}
/* Function of type OCProvisionResultCB from \resource\csdk\security\provisioning\include\pmtypes.h */
void provisionTrustChainCB(void* ctx, int nOfRes, OCProvisionResult_t *arr, bool hasError)
void provisionTrustChainCB(void* ctx, size_t nOfRes, OCProvisionResult_t *arr, bool hasError)
{
if(!hasError)
{
......@@ -571,9 +571,9 @@ static int doGetRequest(const char* uri, int dev_num)
return -1;
}
/*
* Make sure the OCDevAddr passed to OCDoRequest contains the remote peer's UUID,
* so that PSK lookup succeeds.
/*
* Make sure the OCDevAddr passed to OCDoRequest contains the remote peer's UUID,
* so that PSK lookup succeeds.
*/
if (!OCConvertUuidToString(device->doxm->deviceID.id, device->endpoint.remoteId))
{
......
......@@ -230,7 +230,7 @@ static void provisionCredCB(void* ctx, size_t nOfRes, OCProvisionResult_t* arr,
}
/* Function of type OCProvisionResultCB from \resource\csdk\security\provisioning\include\pmtypes.h */
void provisionTrustChainCB(void* ctx, int nOfRes, OCProvisionResult_t *arr, bool hasError)
void provisionTrustChainCB(void* ctx, size_t nOfRes, OCProvisionResult_t *arr, bool hasError)
{
if (!hasError)
{
......
......@@ -28,7 +28,10 @@ if provisioning_lib_env.get('WITH_TCP') == True and provisioning_lib_env.get('WI
target_os = provisioning_lib_env.get('TARGET_OS')
provisioning_lib_env.AppendUnique(CPPPATH=['#resource/csdk/security/include/experimental'])
provisioning_lib_env.AppendUnique(CPPPATH=[
'#resource/csdk/security/include/experimental',
'#extlibs/sqlite3'
])
provisioning_lib_env.PrependUnique(LIBS=['coap'])
......
......@@ -1574,15 +1574,8 @@ OCStackResult OC_CALL OCSaveTrustCertChain(const uint8_t *trustCertChain, size_t
*/
OCStackResult OC_CALL OCSaveOwnCertChain(const char* cert, const char* key, uint16_t *credId)
{
OicSecKey_t ownCert = { 0 };
ownCert.data = (uint8_t*) cert;
ownCert.len = strlen(cert) + 1;
ownCert.encoding = OIC_ENCODING_PEM;
OicSecKey_t ownKey = { 0 };
ownKey.data = (uint8_t*) key;
ownKey.len = strlen(key) + 1;
ownKey.encoding = OIC_ENCODING_PEM;
OicSecKey_t ownCert = OC_INIT_SEC_KEY((uint8_t*)cert, strlen(cert) + 1, OIC_ENCODING_PEM);
OicSecKey_t ownKey = OC_INIT_SEC_KEY((uint8_t*) key, strlen(key) + 1, OIC_ENCODING_PEM);
return SRPSaveOwnCertChain(&ownCert, &ownKey, credId);
}
......@@ -1599,10 +1592,7 @@ OCStackResult OC_CALL OCSaveOwnCertChain(const char* cert, const char* key, uint
*/
OCStackResult OC_CALL OCSaveOwnRoleCert(const char* cert, uint16_t *credId)
{
OicSecKey_t ownCert = { 0 };
ownCert.data = (uint8_t*)cert;
ownCert.len = strlen(cert) + 1;
ownCert.encoding = OIC_ENCODING_PEM;
OicSecKey_t ownCert = OC_INIT_SEC_KEY((uint8_t*)cert, strlen(cert) + 1, OIC_ENCODING_PEM);
return SRPSaveOwnRoleCert(&ownCert, credId);
}
......
......@@ -525,7 +525,7 @@ static void SetResult(OTMContext_t* otmCtx, const OCStackResult res)
{
OIC_LOG(WARNING, TAG, "Failed to revert is DTLS credential handler.");
}
OicUuid_t emptyUuid = { .id={0}};
OicUuid_t emptyUuid = OC_ZERO_UUID;
SetUuidForPinBasedOxm(&emptyUuid);
}
else if(OIC_MANUFACTURER_CERTIFICATE == otmCtx->selectedDeviceInfo->doxm->oxmSel ||
......@@ -622,7 +622,7 @@ static CAResult_t OwnershipTransferSessionEstablished(const CAEndpoint_t *endpoi
{
uint8_t preMutualVerifNum[OWNER_PSK_LENGTH_128] = {0};
uint8_t mutualVerifNum[MUTUAL_VERIF_NUM_LEN] = {0};
OicUuid_t deviceID = {.id = {0}};
OicUuid_t deviceID = OC_ZERO_UUID;
//Generate mutualVerifNum
char label[LABEL_LEN] = {0};
......@@ -706,7 +706,7 @@ static CAResult_t OwnershipTransferSessionFailed(const CAEndpoint_t *endpoint,
{
OIC_LOG(ERROR, TAG, "The PIN number may be incorrect.");
OicUuid_t emptyUuid = {.id={0}};
OicUuid_t emptyUuid = OC_ZERO_UUID;
memcpy(&(newDevDoxm->owner), &emptyUuid, sizeof(OicUuid_t));
newDevDoxm->owned = false;
otmCtx->attemptCnt++;
......@@ -764,7 +764,7 @@ CAResult_t DTLSHandshakeCB(const CAEndpoint_t *endpoint, const CAErrorInfo_t *in
CAResult_t result = CA_STATUS_OK;
bool emptyOwnerUuid = false;
OicUuid_t emptyUuid = {.id={0}};
OicUuid_t emptyUuid = OC_ZERO_UUID;
bool matching = false;
OicSecDoxm_t* newDevDoxm = NULL;
OTMContext_t* otmCtx = NULL;
......@@ -836,7 +836,7 @@ static OCStackResult SaveOwnerPSK(OCProvisionDev_t *selectedDeviceInfo)
CopyDevAddrToEndpoint(&selectedDeviceInfo->endpoint, &endpoint);
endpoint.port = getSecurePort(selectedDeviceInfo);
OicUuid_t ownerDeviceID = {.id={0}};
OicUuid_t ownerDeviceID = OC_ZERO_UUID;
if (OC_STACK_OK != GetDoxmDeviceID(&ownerDeviceID))
{
OIC_LOG(ERROR, TAG, "Error while retrieving Owner's device ID");
......@@ -1390,7 +1390,7 @@ static OCStackApplicationResult OwnerCredentialHandler(void *ctx, OCDoHandle UNU
*/
if(OIC_RANDOM_DEVICE_PIN == otmCtx->selectedDeviceInfo->doxm->oxmSel)
{
OicUuid_t emptyUuid = { .id={0}};
OicUuid_t emptyUuid = OC_ZERO_UUID;
SetUuidForPinBasedOxm(&emptyUuid);
caResult = CAregisterPskCredentialsHandler(GetDtlsPskCredentials);
......@@ -1402,7 +1402,7 @@ static OCStackApplicationResult OwnerCredentialHandler(void *ctx, OCDoHandle UNU
}
}
#ifdef __WITH_TLS__
otmCtx->selectedDeviceInfo->connType |= CT_FLAG_SECURE;
otmCtx->selectedDeviceInfo->connType = (OCConnectivityType)(otmCtx->selectedDeviceInfo->connType | CT_FLAG_SECURE);
#endif
res = PostOwnerAcl(otmCtx, GET_ACL_VER(otmCtx->selectedDeviceInfo->specVer));
if(OC_STACK_OK != res)
......@@ -1761,7 +1761,7 @@ static OCStackResult PostOwnerCredential(OTMContext_t* otmCtx)
cbData.cd = NULL;
//Generate owner credential for new device
OicUuid_t credSubjectId = {.id={0}};
OicUuid_t credSubjectId = OC_ZERO_UUID;
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
const OicSecCred_t* ownerCredential = GetCredResourceData(&(deviceInfo->doxm->deviceID));
if (NULL == ownerCredential)
......@@ -3027,7 +3027,7 @@ OCStackResult ConfigSelfOwnership(void)
return OC_STACK_ERROR;
}
OicUuid_t deviceID = {.id={0}};
OicUuid_t deviceID = OC_ZERO_UUID;
if ( OC_STACK_OK != GetDoxmDeviceID(&deviceID) )
{
OIC_LOG (ERROR, TAG, "Unable to retrieve doxm Device ID");
......
......@@ -66,7 +66,7 @@ OCStackResult CreateJustWorksOwnerTransferPayload(OTMContext_t* otmCtx,
return OC_STACK_INVALID_PARAM;
}
OicUuid_t uuidPT = {.id={0}};
OicUuid_t uuidPT = OC_ZERO_UUID;
if (OC_STACK_OK != GetDoxmDeviceID(&uuidPT))
{
......
......@@ -85,7 +85,7 @@ OCStackResult CreateMCertificateBasedOwnerTransferPayload(OTMContext_t* otmCtx,
return OC_STACK_INVALID_PARAM;
}
OicUuid_t uuidPT = {.id={0}};
OicUuid_t uuidPT = OC_ZERO_UUID;
*payload = NULL;
*size = 0;
......
......@@ -64,7 +64,7 @@ OCStackResult CreatePinBasedOwnerTransferPayload(OTMContext_t* otmCtx, uint8_t *
return OC_STACK_INVALID_PARAM;
}
OicUuid_t uuidPT = {.id={0}};
OicUuid_t uuidPT = OC_ZERO_UUID;
*payload = NULL;
*size = 0;
......
......@@ -333,7 +333,8 @@ OCStackResult MoveDeviceList(OCProvisionDev_t **ppDstDevicesList,
return OC_STACK_INVALID_PARAM;
}
OCProvisionDev_t *ptr = GetDevice(ppSrcDevicesList, endpoint->addr, endpoint->port);
OCProvisionDev_t *ptr = NULL;
ptr = GetDevice(ppSrcDevicesList, endpoint->addr, endpoint->port);
if(ptr)
{
LL_DELETE(*ppSrcDevicesList, ptr);
......@@ -1576,7 +1577,7 @@ OCStackResult PMMultipleOwnerDeviceDiscovery(unsigned short waittime, bool isMul
const char *DOXM_MOM_ENABLE_MULTICAST_QUERY = "/oic/sec/doxm?mom!=0&owned=TRUE";
const char *DOXM_MULTIPLE_OWNED_MULTICAST_QUERY = "/oic/sec/doxm?owned=TRUE";
DiscoveryInfo *pDInfo = OICCalloc(1, sizeof(DiscoveryInfo));
DiscoveryInfo *pDInfo = (DiscoveryInfo *)OICCalloc(1, sizeof(DiscoveryInfo));
if(NULL == pDInfo)
{
OIC_LOG(ERROR, TAG, "PMDeviceDiscovery : Memory allocation failed.");
......
......@@ -24,7 +24,7 @@
#include <stdlib.h>
#include <limits.h>
#include <sqlite3.h>
#include "sqlite3.h"
#include "experimental/logger.h"
#include "oic_malloc.h"
#include "provisioningdatabasemanager.h"
......
......@@ -57,6 +57,15 @@
#define TAG "OIC_SRPAPI"
#ifndef OC_INIT_OC_CALLBACK_DATA
# if (__STDC_VERSION__ >= 199901L)
# define OC_INIT_OC_CALLBACK_DATA(ctx, handler, deleter) {.context=(ctx), .cb=(handler), .cd=(deleter)}
# else
# define OC_INIT_OC_CALLBACK_DATA(ctx, handler, deleter) {(ctx), (handler), (deleter)}
# endif
#endif
static trustCertChainContext_t g_trustCertChainNotifier;
/**
......@@ -639,11 +648,7 @@ static OCStackResult provisionCredentials(OicSecCred_t *cred,
}
OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
OCCallbackData cbData;
memset(&cbData, 0, sizeof(cbData));
cbData.cb = responseHandler;
cbData.context = (void *)credData;
cbData.cd = NULL;
OCCallbackData cbData = OC_INIT_OC_CALLBACK_DATA(credData, responseHandler, NULL);
OCDoHandle handle = NULL;
OCMethod method = OC_REST_POST;
......@@ -718,7 +723,7 @@ static OCStackResult ProvisionCredentialsDos(void *ctx, OicSecCred_t *cred,
}
OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
OCCallbackData cbData = { .context = NULL, .cb = NULL, .cd = NULL };
OCCallbackData cbData = OC_INIT_OC_CALLBACK_DATA(NULL, NULL, NULL);
cbData.cb = responseHandler;
cbData.context = ctx;
cbData.cd = NULL;
......@@ -907,7 +912,7 @@ OCStackResult SetDOS(const Data_t *data, OicSecDeviceOnboardingState_t dos,
return OC_STACK_INVALID_PARAM;
}
OCCallbackData cbData = { .context = NULL, .cb = NULL, .cd = NULL };
OCCallbackData cbData = OC_INIT_OC_CALLBACK_DATA(NULL, NULL, NULL);
OCMethod method = OC_REST_POST;
OCDoHandle handle = NULL;
OCProvisionDev_t *targetDev = NULL;
......@@ -1235,7 +1240,7 @@ static OCStackApplicationResult ProvisionTrustChainCB(void *ctx, OCDoHandle UNUS
}
OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
OCCallbackData cbData = {.context = NULL, .cb = NULL, .cd = NULL};
OCCallbackData cbData = OC_INIT_OC_CALLBACK_DATA(NULL, NULL, NULL);
cbData.cb = ProvisionCB;
cbData.context = ctx;
cbData.cd = NULL;
......@@ -1315,7 +1320,7 @@ static OCStackApplicationResult ProvisionSecurityProfileInfoCB(void *ctx, OCDoHa
}
OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
OCCallbackData cbData = {.context = NULL, .cb = NULL, .cd = NULL};
OCCallbackData cbData = OC_INIT_OC_CALLBACK_DATA(NULL, NULL, NULL);
cbData.cb = ProvisionCB;
cbData.context = ctx;
cbData.cd = NULL;
......@@ -1611,7 +1616,7 @@ static OCStackApplicationResult ProvisionCertificateCB(void *ctx, OCDoHandle han
const OCProvisionDev_t *pDev = NULL;
OicSecCred_t *cred = NULL;
OCSecurityPayload *secPayload = NULL;
OCCallbackData cbData = {.context = ctx, .cb = ProvisionCB, .cd = NULL};
OCCallbackData cbData = OC_INIT_OC_CALLBACK_DATA(ctx, ProvisionCB, NULL);
OCDoHandle lHandle = NULL;
int secureFlag = 0;//don't send private data(key)
......@@ -1687,7 +1692,7 @@ OCStackResult SRPProvisionCertificate(void *ctx,
OCStackResult ret = OC_STACK_ERROR;
Data_t *data = NULL;
OicSecCred_t *cred = NULL;
OicSecKey_t deviceCert = { 0 };
OicSecKey_t deviceCert = OC_INIT_SEC_KEY(NULL, 0, OIC_ENCODING_UNKNOW);
OicUuid_t provTooldeviceID = {{0,}};
if (OC_STACK_OK != GetDoxmDeviceID(&provTooldeviceID))
......@@ -1866,7 +1871,7 @@ OCStackResult SRPProvisionCredentials(void *ctx, OicSecCredType_t type, size_t k
/* pemCert is the cerficiate to be provisioned */
VERIFY_NOT_NULL_RETURN(TAG, pemCert, ERROR, OC_STACK_INVALID_PARAM);
OicSecKey_t deviceCert = { 0 };
OicSecKey_t deviceCert = OC_INIT_SEC_KEY(NULL, 0, OIC_ENCODING_UNKNOW);
deviceCert.data = (uint8_t*) pemCert; /* Casting away const is OK here */
deviceCert.len = strlen(pemCert) + 1;
deviceCert.encoding = OIC_ENCODING_PEM;
......@@ -2216,11 +2221,7 @@ static OCStackResult SendDeleteCredentialRequest(void* ctx,
return OC_STACK_ERROR;
}
OCCallbackData cbData;
memset(&cbData, 0, sizeof(cbData));
cbData.context = ctx;
cbData.cb = respHandler;
cbData.cd = NULL;
OCCallbackData cbData = OC_INIT_OC_CALLBACK_DATA(ctx, respHandler, NULL);
OIC_LOG_V(INFO, TAG, "URI: %s",reqBuf);
OIC_LOG(DEBUG, TAG, "Sending remove credential request to resource server");
......@@ -2284,11 +2285,7 @@ static OCStackResult SendDeleteACLRequest(void* ctx,
return OC_STACK_ERROR;
}
OCCallbackData cbData;
memset(&cbData, 0, sizeof(cbData));
cbData.context = ctx;
cbData.cb = respHandler;
cbData.cd = NULL;
OCCallbackData cbData = OC_INIT_OC_CALLBACK_DATA(ctx, respHandler, NULL);
OIC_LOG_V(INFO, TAG, "URI: %s",reqBuf);
OIC_LOG(DEBUG, TAG, "Sending remove ACL request to resource server");
......@@ -2632,7 +2629,7 @@ static OCStackApplicationResult SRPRemoveDeviceCB(void *delDevCtx, OCDoHandle ha
if (clientResponse)
{
OicUuid_t revDevUuid = {.id={0}};
OicUuid_t revDevUuid = OC_ZERO_UUID;
if(UUID_LENGTH == clientResponse->identity.id_length)
{
memcpy(revDevUuid.id, clientResponse->identity.id, sizeof(revDevUuid.id));
......@@ -2711,7 +2708,7 @@ static OCStackApplicationResult SRPSyncDeviceCredCB(void *delDevCtx, OCDoHandle
OCProvisionResultCB resultCallback = removeData->resultCallback;
if (clientResponse)
{
OicUuid_t revDevUuid = {.id={0}};
OicUuid_t revDevUuid = OC_ZERO_UUID;
if(UUID_LENGTH == clientResponse->identity.id_length)
{
memcpy(revDevUuid.id, clientResponse->identity.id, sizeof(revDevUuid.id));
......@@ -2808,7 +2805,21 @@ static OCStackApplicationResult SRPResetDeviceCB(void *ctx, OCDoHandle UNUSED,
// Delete Cred and ACL related to the target device.
const OicSecCred_t *cred = NULL;
OCProvisionDev_t * pTargetDev = (OCProvisionDev_t *)ctx;
CAEndpoint_t endpoint = {.adapter = CA_DEFAULT_ADAPTER};
CAEndpoint_t endpoint =
#if (__STDC_VERSION__ >= 199901L)
{.adapter = CA_DEFAULT_ADAPTER, .flags = CA_DEFAULT_FLAGS,
.port = 0, .addr = {0}, .ifindex = 0, .remoteId = {0}
#if defined (ROUTING_GATEWAY) || defined (ROUTING_EP)
,.routeData = {0}
#endif
};
#else
{CA_DEFAULT_ADAPTER, CA_DEFAULT_FLAGS, 0, {0}, 0, {0}
#if defined (ROUTING_GATEWAY) || defined (ROUTING_EP)
,{0}
#endif
};
#endif
CAResult_t caResult = CA_STATUS_FAILED;
OCStackResult res = OC_STACK_OK;
......@@ -3392,7 +3403,7 @@ OCStackResult SRPResetDevice(const OCProvisionDev_t* pTargetDev,
return OC_STACK_NO_MEMORY;
}
OCCallbackData cbData = { .context = NULL, .cb = NULL, .cd = NULL };
OCCallbackData cbData = OC_INIT_OC_CALLBACK_DATA(NULL, NULL, NULL);
OCMethod method = OC_REST_POST;
OCDoHandle handle = NULL;
OCProvisionDev_t *targetDev = NULL;
......@@ -3571,7 +3582,7 @@ OCStackResult SRPGetCredResource(void *ctx, const OCProvisionDev_t *selectedDevi
}
OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
OCCallbackData cbData = {.context=NULL, .cb=NULL, .cd=NULL};
OCCallbackData cbData = OC_INIT_OC_CALLBACK_DATA(NULL, NULL, NULL);
cbData.cb = &SRPGetCredResourceCB;
GetSecData_t* GetSecData = (GetSecData_t*)OICCalloc(1, sizeof(GetSecData_t));
if (NULL == GetSecData)
......@@ -3708,7 +3719,7 @@ OCStackResult SRPGetACLResource(void *ctx, const OCProvisionDev_t *selectedDevic
}
OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
OCCallbackData cbData = {.context=NULL, .cb=NULL, .cd=NULL};
OCCallbackData cbData = OC_INIT_OC_CALLBACK_DATA(NULL, NULL, NULL);
cbData.cb = &SRPGetACLResourceCB;
GetSecData_t* GetSecData = (GetSecData_t*)OICCalloc(1, sizeof(GetSecData_t));
if (NULL == GetSecData)
......@@ -3942,7 +3953,7 @@ OCStackResult SRPGetCSRResource(void *ctx, const OCProvisionDev_t *selectedDevic
}
OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
OCCallbackData cbData = {.context=NULL, .cb=NULL, .cd=NULL};
OCCallbackData cbData = OC_INIT_OC_CALLBACK_DATA(NULL, NULL, NULL);
cbData.cb = &SRPGetCSRResourceCB;
GetCsrData_t* getCsrData = (GetCsrData_t*)OICCalloc(1, sizeof(GetCsrData_t));
if (NULL == getCsrData)
......@@ -3998,7 +4009,7 @@ OCStackResult SRPGetSpResource(void *ctx, const OCProvisionDev_t *selectedDevice
}
OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
OCCallbackData cbData = {.context=NULL, .cb=NULL, .cd=NULL};
OCCallbackData cbData = OC_INIT_OC_CALLBACK_DATA(NULL, NULL, NULL);
cbData.cb = &SRPGetSpResourceCB;
GetSpData_t* getSpData = (GetSpData_t*)OICCalloc(1, sizeof(GetSpData_t));
if (NULL == getSpData)
......@@ -4175,7 +4186,7 @@ OCStackResult SRPGetRolesResource(void *ctx, const OCProvisionDev_t *selectedDev
}
OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
OCCallbackData cbData = {.context=NULL, .cb=NULL, .cd=NULL};
OCCallbackData cbData = OC_INIT_OC_CALLBACK_DATA(NULL, NULL, NULL);
cbData.cb = &SRPGetRolesResourceCB;
GetRolesData_t *getRolesData = (GetRolesData_t*)OICCalloc(1, sizeof(GetRolesData_t));
if (NULL == getRolesData)
......@@ -4275,7 +4286,7 @@ OCStackResult SRPDeleteRoleCertificateByCredId(void* ctx, const OCProvisionDev_t
OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
OCCallbackData cbData = {.context=NULL, .cb=NULL, .cd=NULL};
OCCallbackData cbData = OC_INIT_OC_CALLBACK_DATA(NULL, NULL, NULL);
cbData.cb = &SRPDeleteRoleCertificateCB;
GetSecData_t *getSecData = (GetSecData_t*)OICCalloc(1, sizeof(GetSecData_t));
if (NULL == getSecData)
......@@ -4389,7 +4400,7 @@ static OCStackApplicationResult ProvisionAclCB(void *ctx, OCDoHandle UNUSED,
}
// if rowneruuid is empty, set it to device ID
OicUuid_t emptyOwner = {.id = {0} };
OicUuid_t emptyOwner = OC_ZERO_UUID;
if (memcmp(&(aclData->acl->rownerID.id), &emptyOwner, UUID_IDENTITY_SIZE) == 0)
{
OIC_LOG(DEBUG, TAG, "Set Rowner to PT's deviceId, because Rowner of ACL is empty");
......@@ -4441,7 +4452,7 @@ static OCStackApplicationResult ProvisionAclCB(void *ctx, OCDoHandle UNUSED,
}
OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
OCCallbackData cbData = {.context = NULL, .cb = NULL, .cd = NULL};
OCCallbackData cbData = OC_INIT_OC_CALLBACK_DATA(NULL, NULL, NULL);
cbData.cb = ProvisionCB;
cbData.context = ctx;
cbData.cd = NULL;
......
......@@ -86,6 +86,14 @@ static const char PEM_END_CRT[] = "-----END CERTIFICATE-----";
#include <intsafe.h>
#endif
#ifndef OC_PARSER_ITER_INIT
# if (__STDC_VERSION__ >= 199901L)
# define OC_PARSER_ITER_INIT {.attrPos = NULL, .attrLen = 0, .valPos = NULL, .valLen = 0, .pi = {0, NULL, NULL, 0, NULL, 0}}
# else
# define OC_PARSER_ITER_INIT {NULL, 0, NULL, 0, {0, NULL, NULL, 0, NULL, 0}}
# endif
#endif
/** Max credential types number used for TLS */
#define MAX_TYPE 2
/** Default cbor payload size. This value is increased in case of CborErrorOutOfMemory.
......@@ -100,7 +108,7 @@ static const uint8_t ROLEID_MAP_SIZE = 1;
static OicSecCred_t *gCred = NULL;
static OCResourceHandle gCredHandle = NULL;
static OicUuid_t gRownerId = { .id = { 0 } };
static OicUuid_t gRownerId = OC_ZERO_UUID;
typedef enum CredCompareResult{
CRED_CMP_EQUAL = 0,
......@@ -149,7 +157,7 @@ static bool CheckSubjectOfCertificate(OicSecCred_t* cred, OicUuid_t deviceID)
#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
VERIFY_NOT_NULL_RETURN(TAG, cred, ERROR, false);
const OicUuid_t emptyUuid = { .id = { 0 } };
const OicUuid_t emptyUuid = OC_ZERO_UUID;
if ( SIGNED_ASYMMETRIC_KEY == cred->credType
&& 0 != strcmp(cred->credUsage, TRUST_CA) )
......@@ -184,7 +192,7 @@ static bool CheckSubjectOfCertificate(OicSecCred_t* cred, OicUuid_t deviceID)
*/
static bool IsValidCredential(const OicSecCred_t* cred)
{
OicUuid_t emptyUuid = {.id={0}};
OicUuid_t emptyUuid = OC_ZERO_UUID;
OIC_LOG(DEBUG, TAG, "IN IsValidCredential");
......@@ -264,7 +272,7 @@ exit:
#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
static bool IsEmptyCred(const OicSecCred_t* cred)
{
OicUuid_t emptyUuid = {.id={0}};
OicUuid_t emptyUuid = OC_ZERO_UUID;
VERIFY_SUCCESS(TAG, (0 == memcmp(cred->subject.id, emptyUuid.id, sizeof(emptyUuid))), DEBUG);
VERIFY_SUCCESS(TAG, !IsNonEmptyRole(&cred->roleId), DEBUG);
......@@ -545,7 +553,7 @@ static CborError DeserializeEncodingFromCborInternal(CborValue *map, char *name,
CborError DeserializeEncodingFromCbor(CborValue *rootMap, OicSecKey_t *value)
{
CborValue map = { .parser = NULL };
CborValue map = OC_CBOR_VALUE_INIT;
CborError cborFindResult = cbor_value_enter_container(rootMap, &map);
size_t len = 0;
......@@ -579,7 +587,7 @@ CborError DeserializeEncodingFromCbor(CborValue *rootMap, OicSecKey_t *value)
CborError DeserializeSecOptFromCbor(CborValue *rootMap, OicSecOpt_t *value)
{
CborValue map = { .parser = NULL };
CborValue map = OC_CBOR_VALUE_INIT;
CborError cborFindResult = cbor_value_enter_container(rootMap, &map);
size_t len = 0;
value->revstat = false;
......@@ -1025,8 +1033,14 @@ OCStackResult CBORPayloadToCred(const uint8_t *cborPayload, size_t size,
char* roleIdTagName = NULL;
char* name = NULL;
OCStackResult ret = OC_STACK_ERROR;
CborValue credCbor = { .parser = NULL };
CborParser parser = { .end = NULL };
CborValue credCbor = OC_CBOR_VALUE_INIT ;
CborParser parser =
# if (__STDC_VERSION__ >= 199901L)
{ .end = NULL, .flags = 0};
# else
{ NULL, 0};
# endif
CborError cborFindResult = CborNoError;
cbor_parser_init(cborPayload, size, 0, &parser, &credCbor);
......@@ -1038,7 +1052,7 @@ OCStackResult CBORPayloadToCred(const uint8_t *cborPayload, size_t size,
OicSecCred_t *headCred = NULL;
// Enter CRED Root Map
CborValue CredRootMap = { .parser = NULL, .ptr = NULL, .remaining = 0, .extra = 0, .type = 0, .flags = 0 };
CborValue CredRootMap = OC_CBOR_VALUE_INIT;
cborFindResult = cbor_value_enter_container(&credCbor, &CredRootMap);
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Entering CRED Root Map.");
......@@ -1063,7 +1077,7 @@ OCStackResult CBORPayloadToCred(const uint8_t *cborPayload, size_t size,
// Enter CREDS Array
size_t tempLen = 0;
int credCount = 0;
CborValue credArray = { .parser = NULL, .ptr = NULL, .remaining = 0, .extra = 0, .type = 0, .flags = 0 };
CborValue credArray = OC_CBOR_VALUE_INIT;
cborFindResult = cbor_value_enter_container(&CredRootMap, &credArray);
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Finding Cred Array.");
......@@ -1071,7 +1085,7 @@ OCStackResult CBORPayloadToCred(const uint8_t *cborPayload, size_t size,
{
credCount++;
//CredId -- Mandatory
CborValue credMap = { .parser = NULL, .ptr = NULL, .remaining = 0, .extra = 0, .type = 0, .flags = 0 };
CborValue credMap = OC_CBOR_VALUE_INIT;
cborFindResult = cbor_value_enter_container(&credArray, &credMap);