From 06e457d24109aeceb4747b242e5fcd01907929a7 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Wed, 16 Aug 2017 10:59:07 +0900 Subject: [PATCH] Remove unnecessary loop - Loop body cannot be executed more than once Signed-off-by: Seungha Son Change-Id: I03262226f4e32976e41a3ac68fe3315fd79643a1 --- test/src/test_app2ext.c | 101 +++++++++++++++++++++++------------------------- 1 file changed, 49 insertions(+), 52 deletions(-) diff --git a/test/src/test_app2ext.c b/test/src/test_app2ext.c index e07e186..97e5184 100644 --- a/test/src/test_app2ext.c +++ b/test/src/test_app2ext.c @@ -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; } -- 2.7.4