IOT-2351 CA: Parse all interfaces 37/20337/3
authorDan Mihai <Daniel.Mihai@microsoft.com>
Tue, 23 May 2017 20:49:32 +0000 (13:49 -0700)
committerUze Choi <uzchoi@samsung.com>
Wed, 24 May 2017 02:07:34 +0000 (02:07 +0000)
The local variable interfaces gets decremented during the loop,
but the entire iflist has to be parsed.

Fixes new test errors that started on my machine with recent change
e3a3f65569f15fdf711c9d0a3123e6951f6499ba :

[ RUN      ] CATests.GetNetworkInformationTest
resource\csdk\connectivity\test\ca_api_unittest.cpp(517): error:
Value of: tempInfo[index].adapter != 0
  Actual: false
Expected: true
resource\csdk\connectivity\test\ca_api_unittest.cpp(518): error:
Value of: strlen(tempInfo[index].addr) != 0
  Actual: false
Expected: true
resource\csdk\connectivity\test\ca_api_unittest.cpp(517): error:
Value of: tempInfo[index].adapter != 0
  Actual: false
Expected: true
resource\csdk\connectivity\test\ca_api_unittest.cpp(518): error:
Value of: strlen(tempInfo[index].addr) != 0
  Actual: false
Expected: true
resource\csdk\connectivity\test\ca_api_unittest.cpp(517): error:
Value of: tempInfo[index].adapter != 0
  Actual: false
Expected: true
resource\csdk\connectivity\test\ca_api_unittest.cpp(518): error:
Value of: strlen(tempInfo[index].addr) != 0
  Actual: false
Expected: true
resource\csdk\connectivity\test\ca_api_unittest.cpp(517): error: Value of:
tempInfo[index].adapter != 0
  Actual: false
Expected: true
resource\csdk\connectivity\test\ca_api_unittest.cpp(518): error: Value of:
strlen(tempInfo[index].addr) != 0
  Actual: false
Expected: true
[  FAILED  ] CATests.GetNetworkInformationTest (5 ms)

Change-Id: If3a74a0739be6a53373f8b25436a50304029d751
Signed-off-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/20337
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
resource/csdk/connectivity/src/ip_adapter/caipserver.c
resource/csdk/connectivity/src/tcp_adapter/catcpserver.c

index f8c3e14..670db81 100644 (file)
@@ -1543,7 +1543,7 @@ CAResult_t CAGetIPInterfaceInformation(CAEndpoint_t **info, size_t *size)
 #endif
 
     size_t interfaces = u_arraylist_length(iflist);
-    for (size_t i = 0; i < interfaces; i++)
+    for (size_t i = 0; i < u_arraylist_length(iflist); i++)
     {
         CAInterface_t *ifitem = (CAInterface_t *)u_arraylist_get(iflist, i);
         if (!ifitem)
index c96e09c..54b6ab8 100644 (file)
@@ -1320,7 +1320,7 @@ CAResult_t CAGetTCPInterfaceInformation(CAEndpoint_t **info, size_t *size)
 #endif
 
     size_t interfaces = u_arraylist_length(iflist);
-    for (size_t i = 0; i < interfaces; i++)
+    for (size_t i = 0; i < u_arraylist_length(iflist); i++)
     {
         CAInterface_t *ifitem = (CAInterface_t *)u_arraylist_get(iflist, i);
         if (!ifitem)