Fixed Klocwork errors in InProcClientWrapper.cpp
authorErich Keane <erich.keane@intel.com>
Mon, 2 Mar 2015 21:04:47 +0000 (13:04 -0800)
committerSashi Penta <sashi.kumar.penta@intel.com>
Fri, 6 Mar 2015 15:33:13 +0000 (15:33 +0000)
Klocworks identified a number of issues as memory leaks, so
this fix updates the calls to use the newer version of OCDoResource
which permits passing of a NULL rather than using the out parameter.

Change-Id: I02cf1d83d4dfafca0773e6e3385881d180335de4
Signed-off-by: Erich Keane <erich.keane@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/428
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Sakthivel Samidurai <sakthivel.samidurai@intel.com>
Reviewed-by: Sashi Penta <sashi.kumar.penta@intel.com>
resource/src/InProcClientWrapper.cpp

index 0fd1176..2eb81fb 100644 (file)
@@ -209,8 +209,7 @@ namespace OC
         if(cLock)
         {
             std::lock_guard<std::recursive_mutex> lock(*cLock);
-            OCDoHandle handle;
-            result = OCDoResource(&handle, OC_REST_GET,
+            result = OCDoResource(nullptr, OC_REST_GET,
                                   resourceType.c_str(),
                                   nullptr, nullptr, connectivityType,
                                   static_cast<OCQualityOfService>(QoS),
@@ -355,12 +354,11 @@ namespace OC
             os << host << assembleSetResourceUri(uri, queryParams).c_str();
 
             std::lock_guard<std::recursive_mutex> lock(*cLock);
-            OCDoHandle handle;
             OCHeaderOption options[MAX_HEADER_OPTIONS];
 
             assembleHeaderOptions(options, headerOptions);
 
-            result = OCDoResource(&handle, OC_REST_GET, os.str().c_str(),
+            result = OCDoResource(nullptr, OC_REST_GET, os.str().c_str(),
                                   nullptr, nullptr, connectivityType,
                                   static_cast<OCQualityOfService>(QoS),
                                   &cbdata,
@@ -465,10 +463,9 @@ namespace OC
         {
             std::lock_guard<std::recursive_mutex> lock(*cLock);
             OCHeaderOption options[MAX_HEADER_OPTIONS];
-            OCDoHandle handle;
 
             assembleHeaderOptions(options, headerOptions);
-            result = OCDoResource(&handle, OC_REST_POST,
+            result = OCDoResource(nullptr, OC_REST_POST,
                                   os.str().c_str(), nullptr,
                                   assembleSetResourcePayload(rep).c_str(), connectivityType,
                                   static_cast<OCQualityOfService>(QoS),