Commit 6fb335eb authored by Shilpa Sodani's avatar Shilpa Sodani Committed by Sachin Agrawal

Fixed compiler warnings

Fixed compiler warnings in security layer due to recently enable compiler flags.

Change-Id: Id88c7385bb493074fab40513745702f6b452590d
Signed-off-by: default avatarShilpa Sodani <shilpa.a.sodani@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2164Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarSachin Agrawal <sachin.agrawal@intel.com>
parent d4ef5a6a
......@@ -43,7 +43,7 @@
#define TAG PCF("SRM-ACL")
OicSecAcl_t *gAcl = NULL;
OicSecAcl_t *gAcl = NULL;
static OCResourceHandle gAclHandle = NULL;
/**
......
......@@ -211,7 +211,7 @@ OicSecAmacl_t * JSONToAmaclBin(const char * jsonStr)
amacl->resources = (char**)OICCalloc(amacl->resourcesLen, sizeof(char*));
VERIFY_NON_NULL(TAG, (amacl->resources), ERROR);
int idxx = 0;
size_t idxx = 0;
do
{
cJSON *jsonRsrc = cJSON_GetArrayItem(jsonObj, idxx);
......
......@@ -41,9 +41,9 @@
#endif
#include <stdint.h>
#define TAG PCF("SRM-CREDL")
static OicSecCred_t *gCred = NULL;
static OCResourceHandle gCredHandle = NULL;
......@@ -517,7 +517,6 @@ exit:
OCStackResult AddCredential(OicSecCred_t * newCred)
{
OCStackResult ret = OC_STACK_ERROR;
char * jsonStr = NULL;
VERIFY_SUCCESS(TAG, NULL != newCred, ERROR);
......@@ -804,7 +803,7 @@ void GetDtlsPskCredentials(CADtlsPskCredsBlob_t **credInfo)
caBlob = (CADtlsPskCredsBlob_t *)OICCalloc(sizeof(CADtlsPskCredsBlob_t), 1);
if (caBlob)
{
OicUuid_t deviceID = {};
OicUuid_t deviceID = {.id={}};
// Retrieve Device ID from doxm resource and copy in PSK creds blob
VERIFY_SUCCESS(TAG, GetDoxmDeviceID(&deviceID) == OC_STACK_OK, ERROR);
......
......@@ -274,7 +274,6 @@ IotvtICalResult_t ParseRecur(const char *recurStr, IotvtICalRecur_t *recur)
return IOTVTICAL_SUCCESS;
}
/**
* Computes number of days between two dates.
*
......@@ -346,8 +345,8 @@ IotvtICalResult_t IsRequestWithinValidTime(char *periodStr, char *recurStr)
return IOTVTICAL_INVALID_PARAMETER;
}
IotvtICalPeriod_t period = {};
IotvtICalRecur_t recur = {};
IotvtICalPeriod_t period = {.startDateTime={.tm_sec=0}};
IotvtICalRecur_t recur = {.freq=0};
IotvtICalResult_t ret = IOTVTICAL_INVALID_ACCESS;
time_t rawTime = time(0);
......@@ -386,7 +385,7 @@ IotvtICalResult_t IsRequestWithinValidTime(char *periodStr, char *recurStr)
(0 <= DiffSecs(currentTime, &period.endDateTime)) &&
(0 <= DiffDays(&period.startDateTime, currentTime)))
{
IotvtICalDateTime_t emptyDT = {};
IotvtICalDateTime_t emptyDT = {.tm_sec=0};
ret = IOTVTICAL_VALID_ACCESS;
//"UNTIL" is an optional parameter of RRULE, checking if until present in recur
......
......@@ -254,7 +254,7 @@ static OCEntityHandlerResult HandlePstatPutRequest(const OCEntityHandlerRequest
*/
for(size_t i=0; i< gPstat->smLen; i++)
{
if(gPstat->sm[i] == omJson->valueint)
if(gPstat->sm[i] == (unsigned int)omJson->valueint)
{
gPstat->om = (OicSecDpom_t)omJson->valueint;
break;
......
......@@ -49,7 +49,6 @@ void ParseQueryIterInit(unsigned char * query, OicParseQueryIter_t * parseIter)
(unsigned char *)OIC_SEC_REST_QUERY_SEPARATOR, (unsigned char *) "", 0, &parseIter->pi);
}
/**
* This method fills the OicParseQueryIter_t struct with next REST query's
* attribute's and value's information
......@@ -94,7 +93,7 @@ OicParseQueryIter_t * GetNextQuery(OicParseQueryIter_t * parseIter)
OCStackResult AddUuidArray(cJSON* jsonRoot, const char* arrayItem,
size_t *numUuids, OicUuid_t** uuids )
{
int idxx = 0;
size_t idxx = 0;
cJSON* jsonObj = cJSON_GetObjectItem(jsonRoot, arrayItem);
VERIFY_NON_NULL(TAG, jsonObj, ERROR);
VERIFY_SUCCESS(TAG, cJSON_Array == jsonObj->type, ERROR);
......
......@@ -195,7 +195,7 @@ OicSecSvc_t * JSONToSvcBin(const char * jsonStr)
svc->owners = (OicUuid_t*)OICCalloc(svc->ownersLen, sizeof(OicUuid_t));
VERIFY_NON_NULL(TAG, (svc->owners), ERROR);
int idxx = 0;
size_t idxx = 0;
do
{
cJSON *jsonOwnr = cJSON_GetArrayItem(jsonObj, idxx);
......
......@@ -137,14 +137,14 @@ TEST(ACLResourceTest, GetDefaultACLTests)
// 'POST' ACL tests
TEST(ACLResourceTest, ACLPostTest)
{
OCEntityHandlerRequest ehReq = {};
OCEntityHandlerRequest ehReq = OCEntityHandlerRequest();
// Read an ACL from the file
char *jsonStr = ReadFile(ACL1_JSON_FILE_NAME);
if (jsonStr)
{
static OCPersistentStorage ps =
{ };
static OCPersistentStorage ps = OCPersistentStorage();
SetPersistentHandler(&ps, true);
// Create Entity Handler POST request payload
......@@ -208,10 +208,10 @@ TEST(ACLResourceTest, GetACLResourceTests)
//'DELETE' ACL test
TEST(ACLResourceTest, ACLDeleteWithSingleResourceTest)
{
OCEntityHandlerRequest ehReq = {};
static OCPersistentStorage ps = {};
OCEntityHandlerRequest ehReq = OCEntityHandlerRequest();
static OCPersistentStorage ps = OCPersistentStorage();
char *jsonStr = NULL;
OicSecAcl_t acl = {};
OicSecAcl_t acl = OicSecAcl_t();
OicSecAcl_t* savePtr = NULL;
const OicSecAcl_t* subjectAcl1 = NULL;
const OicSecAcl_t* subjectAcl2 = NULL;
......@@ -276,9 +276,9 @@ exit:
TEST(ACLResourceTest, ACLDeleteWithMultiResourceTest)
{
OCEntityHandlerRequest ehReq = {};
static OCPersistentStorage ps = {};
OicSecAcl_t acl = {};
OCEntityHandlerRequest ehReq = OCEntityHandlerRequest();
static OCPersistentStorage ps = OCPersistentStorage();
OicSecAcl_t acl = OicSecAcl_t();
char *jsonStr = NULL;
OicSecAcl_t* savePtr = NULL;
const OicSecAcl_t* subjectAcl1 = NULL;
......
......@@ -49,7 +49,6 @@ const OicSecCred_t* GetCredResourceData(const OicUuid_t* subject);
#endif
OicSecCred_t * getCredList()
{
......@@ -182,8 +181,8 @@ TEST(CredEntityHandlerTest, CredEntityHandlerInvalidFlag)
//Cred DELETE request
TEST(CredEntityHandlerTest, CredEntityHandlerDeleteTest)
{
OCEntityHandlerRequest ehReq = {};
static OCPersistentStorage ps = {};
OCEntityHandlerRequest ehReq = OCEntityHandlerRequest();
static OCPersistentStorage ps = OCPersistentStorage();
const OicSecCred_t* subjectCred1 = NULL;
const OicSecCred_t* subjectCred2 = NULL;
char *jsonStr = NULL;
......
......@@ -33,6 +33,7 @@
extern "C" {
#endif
//Declare Doxm resource methods for testing
OCStackResult CreateDoxmResource();
OCEntityHandlerResult DoxmEntityHandler (OCEntityHandlerFlag flag,
......@@ -47,6 +48,7 @@ OCEntityHandlerResult HandleDoxmGetRequest (const OCEntityHandlerRequest * ehReq
}
#endif
OicSecDoxm_t * getBinDoxm()
{
OicSecDoxm_t * doxm = (OicSecDoxm_t*)OICCalloc(1, sizeof(OicSecDoxm_t));
......@@ -130,7 +132,7 @@ TEST(DoxmEntityHandlerTest, DoxmEntityHandlerValidRequest)
{
EXPECT_EQ(OC_STACK_INVALID_PARAM, InitDoxmResource());
char query[] = "oxm=0;owned=false;owner=owner1";
OCEntityHandlerRequest req = {0};
OCEntityHandlerRequest req = OCEntityHandlerRequest();
req.method = OC_REST_GET;
req.query = OICStrdup(query);
EXPECT_EQ(OC_EH_ERROR, DoxmEntityHandler(OCEntityHandlerFlag::OC_REQUEST_FLAG, &req));
......
......@@ -27,6 +27,11 @@
static void printPeriod(IotvtICalPeriod_t *period)
{
if(NULL == period)
{
return;
}
OC_LOG_V(INFO, TAG, PCF("period->startDateTime.tm_year = %d"),period->startDateTime.tm_year);
OC_LOG_V(INFO, TAG, PCF("period->startDateTime.tm_mon = %d"),period->startDateTime.tm_mon);
OC_LOG_V(INFO, TAG, PCF("period->startDateTime.tm_mday = %d"),period->startDateTime.tm_mday);
......@@ -42,6 +47,7 @@ static void printPeriod(IotvtICalPeriod_t *period)
OC_LOG_V(INFO, TAG, PCF("period->startDateTime.tm_sec = %d"),period->endDateTime.tm_sec);
}
static void printRecur(IotvtICalRecur_t *recur)
{
OC_LOG_V(INFO, TAG, PCF("recur->freq = %d"), recur->freq);
......@@ -83,7 +89,7 @@ static void printRecur(IotvtICalRecur_t *recur)
TEST(ParsePeriodTest, ParsePeriodValidDateTime)
{
char periodStr[] = "20150629T153050/20150630T233055";
IotvtICalPeriod_t period = {};
IotvtICalPeriod_t period = IotvtICalPeriod_t();
EXPECT_EQ(IOTVTICAL_SUCCESS, ParsePeriod(periodStr,&period));
printPeriod(&period);
}
......@@ -91,7 +97,7 @@ TEST(ParsePeriodTest, ParsePeriodValidDateTime)
TEST(ParsePeriodTest, ParsePeriodValidDate)
{
char periodStr[] = "20150629/20150630";
IotvtICalPeriod_t period = {};
IotvtICalPeriod_t period = IotvtICalPeriod_t();
EXPECT_EQ(IOTVTICAL_SUCCESS, ParsePeriod(periodStr,&period));
printPeriod(&period);
}
......@@ -99,62 +105,62 @@ TEST(ParsePeriodTest, ParsePeriodValidDate)
TEST(ParsePeriodTest, ParsePeriodMismatchStartDTEndDT1)
{
char periodStr[] = "20150629T153050/20150630";
IotvtICalPeriod_t period = {};
IotvtICalPeriod_t period = IotvtICalPeriod_t();
EXPECT_EQ(IOTVTICAL_INVALID_PERIOD, ParsePeriod(periodStr,&period));
}
TEST(ParsePeriodTest, ParsePeriodMismatchStartDTEndDT2)
{
char periodStr[] = "20150629/20150630T203055";
IotvtICalPeriod_t period = {};
IotvtICalPeriod_t period = IotvtICalPeriod_t();
EXPECT_EQ(IOTVTICAL_INVALID_PERIOD, ParsePeriod(periodStr,&period));
}
TEST(ParsePeriodTest, ParsePeriodInvalidStartDT1)
{
char periodStr[] = "20150629T1530/20150630T203055";
IotvtICalPeriod_t period = {};
IotvtICalPeriod_t period = IotvtICalPeriod_t();
EXPECT_EQ(IOTVTICAL_INVALID_PERIOD, ParsePeriod(periodStr,&period));
}
TEST(ParsePeriodTest, ParsePeriodInvalidEndtDT2)
{
char periodStr[] = "20150629T153050/20150630203055";
IotvtICalPeriod_t period = {};
IotvtICalPeriod_t period = IotvtICalPeriod_t();
EXPECT_EQ(IOTVTICAL_INVALID_PERIOD, ParsePeriod(periodStr,&period));
}
TEST(ParsePeriodTest, ParsePeriodInvalidStartD3)
{
char periodStr[] = "201506/20150630";
IotvtICalPeriod_t period = {};
IotvtICalPeriod_t period = IotvtICalPeriod_t();
EXPECT_EQ(IOTVTICAL_INVALID_PERIOD, ParsePeriod(periodStr,&period));
}
TEST(ParsePeriodTest, ParsePeriodInvalidEndD4)
{
char periodStr[] = "20150629/201530";
IotvtICalPeriod_t period = {};
IotvtICalPeriod_t period = IotvtICalPeriod_t();
EXPECT_EQ(IOTVTICAL_INVALID_PERIOD, ParsePeriod(periodStr,&period));
}
TEST(ParsePeriodTest, ParsePeriodEndDTBeforeStartDT)
{
char periodStr[] = "20150630T203055/20150629T153050";
IotvtICalPeriod_t period = {};
IotvtICalPeriod_t period = IotvtICalPeriod_t();
EXPECT_EQ(IOTVTICAL_INVALID_PERIOD, ParsePeriod(periodStr,&period));
}
TEST(ParsePeriodTest, ParsePeriodEndDBeforeStartD)
{
char periodStr[] = "20150630/20150629";
IotvtICalPeriod_t period = {};
IotvtICalPeriod_t period = IotvtICalPeriod_t();
EXPECT_EQ(IOTVTICAL_INVALID_PERIOD, ParsePeriod(periodStr,&period));
}
TEST(ParseRecurTest, ParseRecurValid1)
{
char recurStr[] = "FREQ=DAILY; UNTIL=20150703; BYDAY=MO, WE, FR";
IotvtICalRecur_t recur = {};
IotvtICalRecur_t recur = IotvtICalRecur_t();
EXPECT_EQ(IOTVTICAL_SUCCESS, ParseRecur(recurStr, &recur));
printRecur(&recur);
}
......@@ -162,7 +168,7 @@ TEST(ParseRecurTest, ParseRecurValid1)
TEST(ParseRecurTest, ParseRecurValid2)
{
char recurStr[] = "FREQ=DAILY";
IotvtICalRecur_t recur = {};
IotvtICalRecur_t recur = IotvtICalRecur_t();
EXPECT_EQ(IOTVTICAL_SUCCESS, ParseRecur(recurStr, &recur));
printRecur(&recur);
}
......@@ -170,28 +176,28 @@ TEST(ParseRecurTest, ParseRecurValid2)
TEST(ParseRecurTest, ParseRecurInValidFreq1)
{
char recurStr[] = "FREQ=WEEKLY; UNTIL=20150703; BYDAY=TU";
IotvtICalRecur_t recur = {};
IotvtICalRecur_t recur = IotvtICalRecur_t();
EXPECT_EQ(IOTVTICAL_INVALID_RRULE, ParseRecur(recurStr, &recur));
}
TEST(ParseRecurTest, ParseRecurInValidFreq2)
{
char recurStr[] = "UNTIL=20150703; BYDAY=TU";
IotvtICalRecur_t recur = {};
IotvtICalRecur_t recur = IotvtICalRecur_t();
EXPECT_EQ(IOTVTICAL_INVALID_RRULE, ParseRecur(recurStr, &recur));
}
TEST(ParseRecurTest, ParseRecurInValidUntil)
{
char recurStr[] = "FREQ=DAILY; UNTIL=20150703T095055; BYDAY=MO, WE, FR";
IotvtICalRecur_t recur = {};
IotvtICalRecur_t recur = IotvtICalRecur_t();
EXPECT_EQ(IOTVTICAL_INVALID_RRULE, ParseRecur(recurStr, &recur));
}
TEST(ParseRecurTest, ParseRecurInValidByday)
{
char recurStr[] = "FREQ=DAILY; UNTIL=20150703; BYDAY=";
IotvtICalRecur_t recur = {};
IotvtICalRecur_t recur = IotvtICalRecur_t();
EXPECT_EQ(IOTVTICAL_INVALID_RRULE, ParseRecur(recurStr, &recur));
}
......
......@@ -25,17 +25,18 @@
TEST(ParseRestQueryTest, ParseRestQueryEmpty)
{
unsigned char query[] = "";
OicParseQueryIter_t parseIter = {0};
OicParseQueryIter_t parseIter = OicParseQueryIter_t();
ParseQueryIterInit(query, &parseIter);
EXPECT_EQ(NULL, GetNextQuery(&parseIter));
}
TEST(ParseRestQueryTest, ParseSingleRestQuery)
{
char attr[10], val[10];
unsigned char query[] = "owned=false";
OicParseQueryIter_t parseIter = {0};
OicParseQueryIter_t parseIter = OicParseQueryIter_t();
ParseQueryIterInit(query, &parseIter);
EXPECT_NE((OicParseQueryIter_t *)NULL, GetNextQuery(&parseIter));
......@@ -49,7 +50,7 @@ TEST(ParseRestQueryTest, ParseRestMultipleQuery)
char attr[10], val[10];
unsigned char query[] = "oxm=0;owned=true;owner=owner1";
OicParseQueryIter_t parseIter = {0};
OicParseQueryIter_t parseIter = OicParseQueryIter_t();
ParseQueryIterInit(query, &parseIter);
printf("\n");
while(GetNextQuery(&parseIter))
......
......@@ -33,6 +33,7 @@
#include "oic_string.h"
#include "common.h"
#define TAG "occlientbasicops"
static int UNICAST_DISCOVERY = 0;
static int TEST_CASE = 0;
......@@ -118,9 +119,12 @@ OCStackResult InvokeOCDoResource(std::ostringstream &query,
return ret;
}
OCStackApplicationResult putReqCB(void* ctx, OCDoHandle handle, OCClientResponse * clientResponse)
OCStackApplicationResult putReqCB(void* ctx, OCDoHandle /*handle*/, OCClientResponse * clientResponse)
{
OC_LOG(INFO, TAG, "Callback Context for PUT recvd successfully");
if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
{
OC_LOG(INFO, TAG, "Callback Context for PUT recvd successfully");
}
if(clientResponse)
{
......@@ -131,9 +135,12 @@ OCStackApplicationResult putReqCB(void* ctx, OCDoHandle handle, OCClientResponse
return OC_STACK_DELETE_TRANSACTION;
}
OCStackApplicationResult postReqCB(void *ctx, OCDoHandle handle, OCClientResponse *clientResponse)
OCStackApplicationResult postReqCB(void *ctx, OCDoHandle /*handle*/, OCClientResponse *clientResponse)
{
OC_LOG(INFO, TAG, "Callback Context for POST recvd successfully");
if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
{
OC_LOG(INFO, TAG, "Callback Context for POST recvd successfully");
}
if(clientResponse)
{
......@@ -144,9 +151,12 @@ OCStackApplicationResult postReqCB(void *ctx, OCDoHandle handle, OCClientRespons
return OC_STACK_DELETE_TRANSACTION;
}
OCStackApplicationResult getReqCB(void* ctx, OCDoHandle handle, OCClientResponse * clientResponse)
OCStackApplicationResult getReqCB(void* ctx, OCDoHandle /*handle*/, OCClientResponse * clientResponse)
{
OC_LOG(INFO, TAG, "Callback Context for GET query recvd successfully");
if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
{
OC_LOG(INFO, TAG, "Callback Context for GET recvd successfully");
}
if(clientResponse)
{
......@@ -159,10 +169,13 @@ OCStackApplicationResult getReqCB(void* ctx, OCDoHandle handle, OCClientResponse
}
// This is a function called back when a device is discovered
OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle handle,
OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle /*handle*/,
OCClientResponse * clientResponse)
{
OC_LOG(INFO, TAG, "Callback Context for DISCOVER query recvd successfully");
if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
{
OC_LOG(INFO, TAG, "Callback Context for DISCOVER recvd successfully");
}
if (clientResponse)
{
......@@ -358,7 +371,7 @@ int main(int argc, char* argv[])
// Initialize Persistent Storage for SVR database
OCPersistentStorage ps = {};
OCPersistentStorage ps = OCPersistentStorage();
ps.open = client_fopen;
ps.read = fread;
ps.write = fwrite;
......
......@@ -23,6 +23,11 @@
#include "ocstack.h"
//-----------------------------------------------------------------------------
// Defines
//-----------------------------------------------------------------------------
#define DEFAULT_CONTEXT_VALUE 0x99
//-----------------------------------------------------------------------------
// Typedefs
//-----------------------------------------------------------------------------
......
......@@ -30,6 +30,7 @@
#include "ocserverbasicops.h"
#include "common.h"
int gQuitFlag = 0;
static LEDResource LED;
......@@ -226,12 +227,12 @@ OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest,
OCEntityHandlerResult
OCEntityHandlerCb (OCEntityHandlerFlag flag,
OCEntityHandlerRequest *entityHandlerRequest,
void* callbackParam)
void* /*callbackParam*/)
{
OC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag);
OCEntityHandlerResult ehResult = OC_EH_ERROR;
OCEntityHandlerResponse response = {};
OCEntityHandlerResponse response = OCEntityHandlerResponse();
// Validate pointer
if (!entityHandlerRequest)
......@@ -311,14 +312,14 @@ FILE* server_fopen(const char *path, const char *mode)
return fopen(CRED_FILE, mode);
}
int main(int argc, char* argv[])
int main(int /*argc*/, char* /*argv*/[])
{
struct timespec timeout;
OC_LOG(DEBUG, TAG, "OCServer is starting...");
// Initialize Persistent Storage for SVR database
OCPersistentStorage ps = {};
OCPersistentStorage ps = OCPersistentStorage();
ps.open = server_fopen;
ps.read = fread;
ps.write = fwrite;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment