From b57e6d0d8d7a479d377fca71537998ef238d733e Mon Sep 17 00:00:00 2001 From: George Nash Date: Tue, 7 Mar 2017 12:45:32 -0800 Subject: [PATCH] csdk: cleanup compiler warnings in occlient and occlientcoll warnings -Wconversion-null and -Wmissing-field-initializers were caused by trying to set a char array to NULL. Its now set to an empty string. It is not removed so the entry count in the queryInterface is the same as the number of test casses. The value is no longer used out of the queryInterface. If the TEST_GET_NULL test case is used it is special cased to use the new InitGetRequestOnNullResource. OC_UNUSED macro has been added to prevent the -Wunused-parameter warning. Change-Id: I4a32e663bca574a6735f3efad2de42046328cc57 Signed-off-by: George Nash Reviewed-on: https://gerrit.iotivity.org/gerrit/17749 Reviewed-by: Joseph Morrow Tested-by: jenkins-iotivity Reviewed-by: Dan Mihai Reviewed-by: Rick Bell --- .../samples/linux/SimpleClientServer/occlient.cpp | 1 + .../linux/SimpleClientServer/occlientcoll.cpp | 32 +++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp b/resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp index 5caedf7..2dd4e52 100644 --- a/resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp +++ b/resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp @@ -618,6 +618,7 @@ int InitGetRequestToUnavailableResource(OCQualityOfService qos) int InitIntrospection(OCDiscoveryPayload* dis) { + OC_UNUSED(dis); std::ostringstream query; query << coapIntrospectionResource; OIC_LOG_V(INFO, TAG, "\nExecuting %s with query %s", __func__, query.str().c_str()); diff --git a/resource/csdk/stack/samples/linux/SimpleClientServer/occlientcoll.cpp b/resource/csdk/stack/samples/linux/SimpleClientServer/occlientcoll.cpp index 5063181..4cb7e1f 100644 --- a/resource/csdk/stack/samples/linux/SimpleClientServer/occlientcoll.cpp +++ b/resource/csdk/stack/samples/linux/SimpleClientServer/occlientcoll.cpp @@ -95,7 +95,8 @@ testToTextMap queryInterface[] = { {"?if=oic.if.b", TEST_PUT_BATCH}, {"?if=oic.if.ll", TEST_PUT_LINK_LIST}, {"", TEST_GET_EMPTY}, - {NULL, TEST_GET_NULL}, + {"", TEST_GET_NULL}, // testToTextMap.text[30] can not be set to NULL. + // This is a special case see InitGetRequestOnNullResource. }; @@ -124,6 +125,7 @@ OCStackApplicationResult getReqCB(void* ctx, OCDoHandle handle, OCClientResponse int InitGetRequestToUnavailableResource(OCClientResponse * clientResponse); int InitObserveRequest(OCClientResponse * clientResponse); int InitPutRequest(OCClientResponse * clientResponse); +int InitGetRequestOnNullResource(OCClientResponse * clientResponse); int InitGetRequest(OCClientResponse * clientResponse); int InitDiscovery(); @@ -252,6 +254,10 @@ OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle /*handle*/, { InitGetRequestToUnavailableResource(clientResponse); } + else if(TestType == TEST_GET_NULL) + { + InitGetRequestOnNullResource(clientResponse); + } else { InitGetRequest(clientResponse); @@ -340,6 +346,30 @@ int InitPutRequest(OCClientResponse * clientResponse) return ret; } +int InitGetRequestOnNullResource(OCClientResponse * clientResponse) +{ + OCStackResult ret; + OCCallbackData cbData; + + //* Make a GET query*/ + std::ostringstream getQuery; + char* nullResource = NULL; + getQuery << "/a/room" << nullResource; + + std::cout << "Get Query: " << getQuery.str() << std::endl; + + cbData.cb = getReqCB; + cbData.context = (void*)DEFAULT_CONTEXT_VALUE; + cbData.cd = NULL; + ret = OCDoRequest(NULL, OC_REST_GET, getQuery.str().c_str(), + &clientResponse->devAddr, 0, ConnType, OC_LOW_QOS, + &cbData, NULL, 0); + if (ret != OC_STACK_OK) + { + OIC_LOG(ERROR, TAG, "OCStack resource error"); + } + return ret; +} int InitGetRequest(OCClientResponse * clientResponse) { -- 2.7.4