[SSM] Fix SSM Sample App to handle invalid input for app menu (IOT-290)
authorMinji Park <minjii.park@samsung.com>
Fri, 6 Feb 2015 06:07:46 +0000 (15:07 +0900)
committerSudarshan Prasad <sudarshan.prasad@intel.com>
Fri, 20 Feb 2015 23:56:37 +0000 (23:56 +0000)
Modify SSM Linux Sample App to to prevent unexpected input values

Change-Id: Ic9de6e894a44a903f02d60f6eeaf0fa9035e0e5a
Signed-off-by: Minji Park <minjii.park@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/315
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
(cherry picked from commit d37ac7328d1f6bf0fc8da65aac9af8b0edcdd904)
Reviewed-on: https://gerrit.iotivity.org/gerrit/384
Reviewed-by: Sudarshan Prasad <sudarshan.prasad@intel.com>
service/soft-sensor-manager/SampleApp/linux/SSMTesterApp/src/SSMTestApp.cpp

index c4ed161015849cc5b0314b575a1a0a62f42702f9..7349d7cccea5cad86995acbcae0563bf7ac3d3c2 100644 (file)
@@ -211,6 +211,7 @@ int main()
     printf("searching SSMResource\n");
     SSMTestApp *SSMApp = new SSMTestApp();
     APPMenu::APPMenu menu = APPMenu::NONE;
+    std::string strMenu;
 
     std::string xmlDescription = "<SSMCore>"
                                  "<Device>"
@@ -227,9 +228,8 @@ int main()
     {
         SSMApp->displayMenu();
 
-        menu = (APPMenu::APPMenu) (getchar() - '0');
-        if ((APPMenu::APPMenu) 0 > menu || menu > APPMenu::EXIT)
-            menu = (APPMenu::APPMenu) (getchar() - '0');
+        getline(cin, strMenu);
+        menu = (APPMenu::APPMenu) (atoi(strMenu.c_str()));
 
         switch (menu)
         {