fix findresource failure issue.
authorjihwan.seo <jihwan.seo@samsung.com>
Wed, 16 Nov 2016 05:11:16 +0000 (14:11 +0900)
committerAshok Babu Channa <ashok.channa@samsung.com>
Fri, 18 Nov 2016 08:34:43 +0000 (08:34 +0000)
this fix is from https://gerrit.iotivity.org/gerrit/#/c/12283/

Change-Id: I322ec7f7a833134f5849eb2157f0025273ebed06
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14411
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Habib Virji <habib.virji@samsung.com>
Reviewed-by: Larry Sachs <larry.j.sachs@intel.com>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
Reviewed-by: Rick Bell <richard.s.bell@intel.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
resource/csdk/stack/src/ocresource.c

index d50d266f073cbf3f81e40590a4228261b985e0c8..773cafdcb76ae9b2e7af517a9552dbec0658108e 100755 (executable)
@@ -661,7 +661,7 @@ OCStackResult SendNonPersistantDiscoveryResponse(OCServerRequest *request, OCRes
 
     return OCDoResponse(&response);
 }
-
+#ifdef RD_SERVER
 /**
  * Find resource at the resource directory server. This resource is not local resource but a
  * remote resource.
@@ -677,7 +677,6 @@ OCStackResult SendNonPersistantDiscoveryResponse(OCServerRequest *request, OCRes
 static OCStackResult findResourceAtRD(const OCResource* resource, const char *interfaceQuery,
     const char *resourceTypeQuery, OCDiscoveryPayload *discPayload)
 {
-#ifdef RD_SERVER
     if (strcmp(resource->uri, OC_RSRVD_RD_URI) == 0)
     {
         if (OC_STACK_OK == OCRDDatabaseCheckResources(interfaceQuery, resourceTypeQuery, discPayload))
@@ -685,14 +684,10 @@ static OCStackResult findResourceAtRD(const OCResource* resource, const char *in
             return OC_STACK_OK;
         }
     }
-#else
-    OC_UNUSED(resource);
-    OC_UNUSED(interfaceQuery);
-    OC_UNUSED(resourceTypeQuery);
-    OC_UNUSED(discPayload);
-#endif
+
     return OC_STACK_NO_RESOURCE;
 }
+#endif
 
 /**
  * Creates a discovery payload and add device id information. This information is included in all
@@ -830,25 +825,23 @@ static OCStackResult HandleVirtualResource (OCServerRequest *request, OCResource
 #endif
         for (; resource && discoveryResult == OC_STACK_OK; resource = resource->next)
         {
+            discoveryResult = OC_STACK_NO_RESOURCE;
+#ifdef RD_SERVER
             discoveryResult = findResourceAtRD(resource, interfaceQuery, resourceTypeQuery,
                 discPayload);
+#endif
             if (OC_STACK_NO_RESOURCE == discoveryResult)
             {
                 if ((!baselineQuery && (resource->resourceProperties & prop)) ||
                     (baselineQuery && (includeThisResourceInResponse(resource, interfaceQuery,
                                                                      resourceTypeQuery))))
                 {
-                    if ((!baselineQuery && (resource->resourceProperties & prop)) ||
-                        (baselineQuery && (includeThisResourceInResponse(resource, interfaceQuery,
-                                                                         resourceTypeQuery))))
-                    {
-                        discoveryResult = BuildVirtualResourceResponse(resource, discPayload,
-                            &request->devAddr);
-                    }
-                    else
-                    {
-                        discoveryResult = OC_STACK_OK;
-                    }
+                    discoveryResult = BuildVirtualResourceResponse(resource, discPayload,
+                        &request->devAddr);
+                }
+                else
+                {
+                    discoveryResult = OC_STACK_OK;
                 }
             }
         }