Change while condition in resource broker
authorHun-je Yeon <hunje.yeon@samsung.com>
Wed, 7 Sep 2016 14:16:58 +0000 (23:16 +0900)
committerUze Choi <uzchoi@samsung.com>
Thu, 8 Sep 2016 08:29:30 +0000 (08:29 +0000)
Removing possible infinite loop with while(1) condition

Change-Id: I07a85de3a38fad3265fd8712a8ce1c912fccf690
Signed-off-by: Hun-je Yeon <hunje.yeon@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11517
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/resource-encapsulation/src/resourceBroker/src/ResourceBroker.cpp

index 2e3c3f9..62d9cfe 100644 (file)
@@ -222,12 +222,8 @@ namespace OIC
             BrokerID retID = 0;
             srand(time(NULL));
 
-            while(1)
+            while((retID==0)||( s_brokerIDMap->find(retID) != s_brokerIDMap->end()))
             {
-                if(retID != 0 && s_brokerIDMap->find(retID) == s_brokerIDMap->end())
-                {
-                    break;
-                }
                 retID = (unsigned int)rand();
             }