Remove unnecessary loop 08/144208/2
authorSeungha Son <seungha.son@samsung.com>
Wed, 16 Aug 2017 01:59:07 +0000 (10:59 +0900)
committerSeungha Son <seungha.son@samsung.com>
Wed, 16 Aug 2017 06:47:44 +0000 (15:47 +0900)
 - Loop body cannot be executed more than once

Signed-off-by: Seungha Son <seungha.son@samsung.com>
Change-Id: I03262226f4e32976e41a3ac68fe3315fd79643a1

test/src/test_app2ext.c

index e07e186..97e5184 100644 (file)
@@ -561,58 +561,55 @@ int main(int argc, char **argv)
 
        /* Parse argv */
        optind = 1;  /* Initialize optind to clear prev. index */
-       while (1) {
-               c = getopt_long(argc, argv, "", long_opts, &opt_idx);
-               if (-1 == c) {
-                       usage();
-                       break;  /* Parse is end */
-               }
-               switch (c) {
-               case OPTVAL_PRE_INSTALL:
-                       pre_app_install();
-                       break;
-               case OPTVAL_POST_INSTALL:
-                       post_app_install();
-                       break;
-               case OPTVAL_PRE_UNINSTALL:
-                       pre_app_uninstall();
-                       break;
-               case OPTVAL_POST_UNINSTALL:
-                       post_app_uninstall();
-                       break;
-               case OPTVAL_PRE_UPGRADE:
-                       pre_app_upgrade();
-                       break;
-               case OPTVAL_POST_UPGRADE:
-                       post_app_upgrade();
-                       break;
-               case OPTVAL_MOVE_TO_EXTERNAL:
-                       app_move_to_external();
-                       break;
-               case OPTVAL_MOVE_TO_INTERNAL:
-                       app_move_to_internal();
-                       break;
-               case OPTVAL_ENABLE_APP:
-                       app_enable();
-                       break;
-               case OPTVAL_DISABLE_APP:
-                       app_disable();
-                       break;
-               case OPTVAL_ENABLE_FULL:
-                       fullpkg_enable();
-                       break;
-               case OPTVAL_DISABLE_FULL:
-                       fullpkg_disable();
-                       break;
-               case OPTVAL_MIGRATE_ALL:
-                       migrate_all();
-                       break;
-               case OPTVAL_USAGE:
-               default:
-                       usage();
-                       break;
-               }
-
+       c = getopt_long(argc, argv, "", long_opts, &opt_idx);
+       if (-1 == c) {
+               usage();
+               app2ext_deinit(handle);
+               return 0;  /* Parse is end */
+       }
+       switch (c) {
+       case OPTVAL_PRE_INSTALL:
+               pre_app_install();
+               break;
+       case OPTVAL_POST_INSTALL:
+               post_app_install();
+               break;
+       case OPTVAL_PRE_UNINSTALL:
+               pre_app_uninstall();
+               break;
+       case OPTVAL_POST_UNINSTALL:
+               post_app_uninstall();
+               break;
+       case OPTVAL_PRE_UPGRADE:
+               pre_app_upgrade();
+               break;
+       case OPTVAL_POST_UPGRADE:
+               post_app_upgrade();
+               break;
+       case OPTVAL_MOVE_TO_EXTERNAL:
+               app_move_to_external();
+               break;
+       case OPTVAL_MOVE_TO_INTERNAL:
+               app_move_to_internal();
+               break;
+       case OPTVAL_ENABLE_APP:
+               app_enable();
+               break;
+       case OPTVAL_DISABLE_APP:
+               app_disable();
+               break;
+       case OPTVAL_ENABLE_FULL:
+               fullpkg_enable();
+               break;
+       case OPTVAL_DISABLE_FULL:
+               fullpkg_disable();
+               break;
+       case OPTVAL_MIGRATE_ALL:
+               migrate_all();
+               break;
+       case OPTVAL_USAGE:
+       default:
+               usage();
                break;
        }