*/
static int InputACL(OicSecAcl_t *acl)
{
- int unused __attribute__((unused));
+ int ret;
char temp_id [UUID_LENGTH + 4] = {0,};
char temp_rsc[MAX_URI_LENGTH + 1] = {0,};
char temp_pms[MAX_PERMISSION_LENGTH + 1] = {0,};
printf("-URN identifying the subject\n");
printf("ex) 1111-1111-1111-1111 (16 Numbers except to '-')\n");
printf("Subject : ");
- unused = scanf("%19s", temp_id);
+ char *ptr = NULL;
+ ret = scanf("%19ms", &ptr);
+ if(1==ret)
+ {
+ OICStrcpy(temp_id, sizeof(temp_id), ptr);
+ OICFree(ptr);
+ }
+ else
+ {
+ printf("Error while input\n");
+ return -1;
+ }
int j = 0;
for (int i = 0; temp_id[i] != '\0'; i++)
{
if (DASH != temp_id[i])
+ {
+ if(j>UUID_LENGTH)
+ {
+ printf("Invalid input\n");
+ return -1;
+ }
acl->subject.id[j++] = temp_id[i];
+ }
}
//Set Resource.
- printf("Num. of Resource : ");
- unused = scanf("%zu", &acl->resourcesLen);
+ printf("Num. of Resource : \n");
+ ret = scanf("%zu", &acl->resourcesLen);
printf("-URI of resource\n");
printf("ex)/oic/sh/temp/0 (Max_URI_Length: 64 Byte )\n");
- acl->resources = (char **)OICMalloc(acl->resourcesLen * sizeof(char *));
+ acl->resources = (char **)OICCalloc(acl->resourcesLen, sizeof(char *));
if (NULL == acl->resources)
{
OC_LOG(ERROR, TAG, "Error while memory allocation");
for (size_t i = 0; i < acl->resourcesLen; i++)
{
printf("[%zu]Resource : ", i + 1);
- unused = scanf("%64s", temp_rsc);
+ char *ptr_tempRsc = NULL;
+ ret = scanf("%64ms", &ptr_tempRsc);
+ if (1==ret)
+ {
+ OICStrcpy(temp_rsc, sizeof(temp_rsc), ptr_tempRsc);
+ OICFree(ptr_tempRsc);
+ }
+ else
+ {
+ printf("Error while input\n");
+ return -1;
+ }
acl->resources[i] = OICStrdup(temp_rsc);
if (NULL == acl->resources[i])
OC_LOG(ERROR, TAG, "Error while memory allocation");
return -1;
}
- strncpy(acl->resources[i], temp_rsc, strlen(temp_rsc));
- acl->resources[i][strlen(temp_rsc)] = '\0';
}
// Set Permission
do
printf("-Set the permission(C,R,U,D,N)\n");
printf("ex) CRUDN, CRU_N,..(5 Charaters)\n");
printf("Permission : ");
- unused = scanf("%5s", temp_pms);
+ char *ptr_temp_pms = NULL;
+ ret = scanf("%5ms", &ptr_temp_pms);
+ if(1 == ret)
+ {
+ OICStrcpy(temp_pms, sizeof(temp_pms), ptr_temp_pms);
+ OICFree(ptr_temp_pms);
+
+ }
+ else
+ {
+ printf("Error while input\n");
+ return -1;
+ }
}
while (0 != CalculateAclPermission(temp_pms, &(acl->permission)) );
// Set Rowner
printf("Num. of Rowner : ");
- unused = scanf("%zu", &acl->ownersLen);
+ ret = scanf("%zu", &acl->ownersLen);
printf("-URN identifying the rowner\n");
printf("ex) 1111-1111-1111-1111 (16 Numbers except to '-')\n");
acl->owners = (OicUuid_t *)OICCalloc(acl->ownersLen, sizeof(OicUuid_t));
for (size_t i = 0; i < acl->ownersLen; i++)
{
printf("[%zu]Rowner : ", i + 1);
- unused = scanf("%19s", temp_id);
+ char *ptr_temp_id = NULL;
+ ret = scanf("%19ms", &ptr_temp_id);
+ if (1 == ret)
+ {
+ OICStrcpy(temp_id, sizeof(temp_id), ptr_temp_id);
+ OICFree(ptr_temp_id);
+ }
+ else
+ {
+ printf("Error while input\n");
+ return -1;
+ }
j = 0;
for (int k = 0; temp_id[k] != '\0'; k++)
{
//FILE *client_fopen(const char *path, const char *mode)
-FILE *client_fopen(const char *UNUSED_PARAM, const char *mode)
+FILE *client_fopen(const char* UNUSED_PARAM , const char *mode)
{
+ (void)UNUSED_PARAM;
return fopen(CRED_FILE, mode);
}
if(pinBuf)
{
printf("INPUT PIN : ");
- int unused = scanf("%s", pinBuf);
- pinBuf[bufSize - 1] = '\0';
+ char *ptr = NULL;
+ int ret = scanf("%ms", &ptr);
+ if(1 == ret)
+ {
+ OICStrcpy(pinBuf, bufSize, ptr);
+ OICFree(ptr);
+ }
+ else
+ {
+ printf("Error in input\n");
+ return;
+ }
}
}
/**
* Provisioning client sample using ProvisioningAPI
*/
-int main(int argc, char **argv)
+int main()
{
OCStackResult res = OC_STACK_OK;
- int unused __attribute__((unused));
-
- gAcl1 = (OicSecAcl_t *)OICMalloc(sizeof(OicSecAcl_t));
- if (NULL == gAcl1)
- {
- OC_LOG(ERROR, TAG, "Error while memory allocation");
- goto error;
- }
+ int unused;
+ (void)unused;
// Initialize Persistent Storage for SVR database
OCPersistentStorage ps = { .open = NULL,
unused = scanf("%d", &Device2);
- gAcl1 = (OicSecAcl_t *)OICMalloc(sizeof(OicSecAcl_t));
+ gAcl1 = (OicSecAcl_t *)OICCalloc(1,sizeof(OicSecAcl_t));
if (NULL == gAcl1)
{
OC_LOG(ERROR, TAG, "Error while memory allocation");
goto error;
}
- memset(gAcl1, 0x00, sizeof(OicSecAcl_t));
- gAcl2 = (OicSecAcl_t *)OICMalloc(sizeof(OicSecAcl_t));
+ gAcl2 = (OicSecAcl_t *)OICCalloc(1,sizeof(OicSecAcl_t));
if (NULL == gAcl2)
{
OC_LOG(ERROR, TAG, "Error while memory allocation");
goto error;
}
- memset(gAcl2, 0x00, sizeof(OicSecAcl_t));
printf("Input ACL for Device1\n");
if ( 0 == InputACL(gAcl1))
void* callbackParam)
{
OC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag);
-
+ (void)callbackParam;
OCEntityHandlerResult ehResult = OC_EH_ERROR;
OCEntityHandlerResponse response = {};
return fopen(CRED_FILE, mode);
}
-int main(int argc, char* argv[])
+int main()
{
struct timespec timeout;
void* callbackParam)
{
OC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag);
-
+ (void)callbackParam;
OCEntityHandlerResult ehResult = OC_EH_ERROR;
OCEntityHandlerResponse response = {};
OC_LOG(INFO, TAG, "============================");
}
-int main(int argc, char* argv[])
+int main()
{
struct timespec timeout;
OC_LOG(ERROR,TAG,"Context is Null in ACLProv 2");
return;
}
+ (void)nOfRes;
Linkdata_t *link = (Linkdata_t*)ctx;
OCProvisionResultCB resultCallback = link->resultCallback;
OC_LOG(ERROR,TAG,"Context is Null in ACLProv1");
return;
}
+ (void)nOfRes;
Linkdata_t *link = (Linkdata_t*)ctx;
OCProvisionResultCB resultCallback = link->resultCallback;
* and OC_STACK_KEEP_TRANSACTION to keep it.
*/
static OCStackApplicationResult OwnerTransferModeHandler(void *ctx, OCDoHandle UNUSED,
- OCClientResponse *clientResponse)
+ OCClientResponse *clientResponse)
{
OC_LOG(DEBUG, TAG, "IN OwnerTransferModeHandler");
VERIFY_NON_NULL(TAG, ctx, WARNING);
OTMContext_t* otmCtx = (OTMContext_t*)ctx;
-
+ (void)UNUSED;
if(clientResponse->result == OC_STACK_OK)
{
OC_LOG(INFO, TAG, "OwnerTransferModeHandler : response result = OC_STACK_OK");
* and OC_STACK_KEEP_TRANSACTION to keep it.
*/
static OCStackApplicationResult ListMethodsHandler(void *ctx, OCDoHandle UNUSED,
- OCClientResponse *clientResponse)
+ OCClientResponse *clientResponse)
{
OC_LOG(DEBUG, TAG, "IN ListMethodsHandler");
VERIFY_NON_NULL(TAG, ctx, WARNING);
OTMContext_t* otmCtx = (OTMContext_t*)ctx;
-
+ (void)UNUSED;
if (OC_STACK_OK == clientResponse->result)
{
if (NULL == clientResponse->payload)
* @return OC_STACK_DELETE_TRANSACTION to delete the transaction
* and OC_STACK_KEEP_TRANSACTION to keep it.
*/
-static OCStackApplicationResult OwnershipInformationHandler(void *ctx,
- OCDoHandle UNUSED, OCClientResponse *clientResponse)
+static OCStackApplicationResult OwnershipInformationHandler(void *ctx, OCDoHandle UNUSED,
+ OCClientResponse *clientResponse)
{
VERIFY_NON_NULL(TAG, clientResponse, WARNING);
VERIFY_NON_NULL(TAG, ctx, WARNING);
OC_LOG(DEBUG, TAG, "IN OwnershipInformationHandler");
-
+ (void)UNUSED;
OCStackResult res = OC_STACK_OK;
OTMContext_t* otmCtx = (OTMContext_t*)ctx;
if (OC_STACK_OK == clientResponse->result)
* @return OC_STACK_DELETE_TRANSACTION to delete the transaction
* and OC_STACK_KEEP_TRANSACTION to keep it.
*/
-static OCStackApplicationResult OperationModeUpdateHandler(void *ctx,
- OCDoHandle UNUSED, OCClientResponse *clientResponse)
+static OCStackApplicationResult OperationModeUpdateHandler(void *ctx, OCDoHandle UNUSED,
+ OCClientResponse *clientResponse)
{
OC_LOG(DEBUG, TAG, "IN OperationModeUpdateHandler");
VERIFY_NON_NULL(TAG, ctx, WARNING);
OTMContext_t* otmCtx = (OTMContext_t*)ctx;
+ (void) UNUSED;
if (OC_STACK_OK == clientResponse->result)
{
OCStackResult res = OC_STACK_ERROR;
* and OC_STACK_KEEP_TRANSACTION to keep it.
*/
static OCStackApplicationResult FinalizeProvisioningCB(void *ctx, OCDoHandle UNUSED,
- OCClientResponse *clientResponse)
+ OCClientResponse *clientResponse)
{
OC_LOG_V(INFO, TAG, "IN FinalizeProvisioningCB.");
VERIFY_NON_NULL(TAG, ctx, ERROR);
OTMContext_t* otmCtx = (OTMContext_t*)ctx;
-
+ (void)UNUSED;
if(OC_STACK_OK == clientResponse->result)
{
SetResult(otmCtx, OC_STACK_OK);
* and OC_STACK_KEEP_TRANSACTION to keep it.
*/
static OCStackApplicationResult ProvisionDefaultACLCB(void *ctx, OCDoHandle UNUSED,
- OCClientResponse *clientResponse)
+ OCClientResponse *clientResponse)
{
OC_LOG_V(INFO, TAG, "IN ProvisionDefaultACLCB.");
VERIFY_NON_NULL(TAG, ctx, ERROR);
OTMContext_t* otmCtx = (OTMContext_t*) ctx;
+ (void)UNUSED;
if (OC_STACK_RESOURCE_CREATED == clientResponse->result)
{
OCStackResult LoadSecretJustWorksCallback(OTMContext_t* UNUSED_PARAM)
{
//In case of 'just works', secret data not required
+ (void)UNUSED_PARAM;
return OC_STACK_OK;
}
* @return OC_STACK_KEEP_TRANSACTION to keep transaction and
* OC_STACK_DELETE_TRANSACTION to delete it.
*/
-static OCStackApplicationResult SecurePortDiscoveryHandler(void *ctx,
- OCDoHandle UNUSED, OCClientResponse *clientResponse)
+static OCStackApplicationResult SecurePortDiscoveryHandler(void *ctx, OCDoHandle UNUSED,
+ OCClientResponse *clientResponse)
{
if (ctx == NULL)
{
OC_LOG(ERROR, TAG, "Lost List of device information");
return OC_STACK_KEEP_TRANSACTION;
}
-
+ (void)UNUSED;
if (clientResponse)
{
if (NULL == clientResponse->payload)
* @return OC_STACK_KEEP_TRANSACTION to keep transaction and
* OC_STACK_DELETE_TRANSACTION to delete it.
*/
-static OCStackApplicationResult DeviceDiscoveryHandler(void *ctx,
- OCDoHandle UNUSED, OCClientResponse *clientResponse)
+static OCStackApplicationResult DeviceDiscoveryHandler(void *ctx, OCDoHandle UNUSED,
+ OCClientResponse *clientResponse)
{
if (ctx == NULL)
{
OC_LOG(ERROR, TAG, "Lost List of device information");
return OC_STACK_KEEP_TRANSACTION;
}
+ (void)UNUSED;
if (clientResponse)
{
if (NULL == clientResponse->payload)
* and OC_STACK_KEEP_TRANSACTION to keep it.
*/
static OCStackApplicationResult provisionCredentialCB2(void *ctx, OCDoHandle UNUSED,
- OCClientResponse *clientResponse)
+ OCClientResponse *clientResponse)
{
VERIFY_NON_NULL(TAG, ctx, ERROR, OC_STACK_DELETE_TRANSACTION);
CredentialData_t *credData = (CredentialData_t *) ctx;
+ (void)UNUSED;
OCProvisionResultCB resultCallback = credData->resultCallback;
OC_LOG(INFO, TAG, "provisionCredentialCB2 called");
* and OC_STACK_KEEP_TRANSACTION to keep it.
*/
static OCStackApplicationResult provisionCredentialCB1(void *ctx, OCDoHandle UNUSED,
- OCClientResponse *clientResponse)
+ OCClientResponse *clientResponse)
{
VERIFY_NON_NULL(TAG, ctx, ERROR, OC_STACK_DELETE_TRANSACTION);
+ (void)UNUSED;
CredentialData_t* credData = (CredentialData_t*) ctx;
OICFree(credData->credInfoFirst);
const OCProvisionDev_t *deviceInfo = credData->deviceInfo2;
* and OC_STACK_KEEP_TRANSACTION to keep it.
*/
static OCStackApplicationResult SRPProvisionACLCB(void *ctx, OCDoHandle UNUSED,
- OCClientResponse *clientResponse)
+ OCClientResponse *clientResponse)
{
OC_LOG_V(INFO, TAG, "Inside SRPProvisionACLCB.");
+ (void)UNUSED;
VERIFY_NON_NULL(TAG, ctx, ERROR, OC_STACK_DELETE_TRANSACTION);
ACLData_t *aclData = (ACLData_t*)ctx;
OCProvisionResultCB resultCallback = aclData->resultCallback;
* *****************************************************************/
#include "gtest/gtest.h"
#include "secureresourceprovider.h"
-//#include "provisioningmanager.h"
+
static OicSecAcl_t acl;
static OCProvisionDev_t pDev1;
static OCProvisionDev_t pDev2;
static OicSecCredType_t credType;
-static void provisioningCB (void* UNUSED1, int UNUSED2,
- OCProvisionResult_t *UNUSED3, bool UNUSED4)
+static void provisioningCB (void* UNUSED1, int UNUSED2, OCProvisionResult_t *UNUSED3, bool UNUSED4)
{
//dummy callback
+ (void) UNUSED1;
+ (void) UNUSED2;
+ (void) UNUSED3;
+ (void) UNUSED4;
}
TEST(SRPProvisionACLTest, NullDeviceInfo)