From: SangYoun Kwak Date: Tue, 18 Jun 2024 08:06:35 +0000 (+0900) Subject: osu: Modify to do nothing if no argument passed X-Git-Tag: accepted/tizen/8.0/unified/20240619.075738^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F11%2F313011%2F1;p=platform%2Fcore%2Fsystem%2Fupdate-control.git osu: Modify to do nothing if no argument passed Previously, if osu command executed without any options, upgrade is triggered. This behavior may lead to mistake, the osu command modified to trigger upgrade only with --update option. Without any options, help page will be printed and return 1. Change-Id: I0ada77d5ecca92cdc16851e4d3b9a504416bb64c Signed-off-by: SangYoun Kwak --- diff --git a/tools/osu/osu.c b/tools/osu/osu.c index 744ba47..0322403 100644 --- a/tools/osu/osu.c +++ b/tools/osu/osu.c @@ -40,7 +40,7 @@ static int parse_args(int argc, char **argv, struct arguments *args) assert(args); args->resize = false; - args->update = true; + args->update = false; struct option long_options[] = { {"resize", no_argument, NULL, 'r'}, @@ -51,8 +51,6 @@ static int parse_args(int argc, char **argv, struct arguments *args) int opt; while ((opt = getopt_long_only(argc, argv, "rh", long_options, NULL)) !=-1) { - args->update = false; - switch (opt) { case 'r': { args->resize = true; @@ -73,7 +71,9 @@ static int parse_args(int argc, char **argv, struct arguments *args) } } - return 0; + print_help(argv[0]); + + return 1; } static void print_help(char *my_name) @@ -81,13 +81,12 @@ static void print_help(char *my_name) assert(my_name); printf("Usage:\n" - " %s [--resize|--update]\n\n" - "Possible arguments:\n" - " --help Print this help\n" - " --update Trigger the OS Upgrade\n" - " --resize Run resize2fs on the rootfs partition.\n" - " After that, performing the OS Upgrade will be impossible.\n\n" - "By default, without an argument, the OS Upgrade will be triggered.\n\n", my_name); + " %s [--help|--resize|--update]\n\n" + "Possible arguments:\n" + " --help Print this help\n" + " --update Trigger the OS Upgrade\n" + " --resize Run resize2fs on the rootfs partition.\n" + " After that, performing the OS Upgrade will be impossible.\n\n" ,my_name); } static int do_update() @@ -131,18 +130,19 @@ cleanup: int main(int argc, char **argv) { - int ret = 0; struct arguments args; if (parse_args(argc, argv, &args) != 0) { return 1; } - if (args.resize) { - ret = do_resize(); - } else if (args.update) { - ret = do_update(); - } + if (args.resize) + return do_resize(); - return ret; + if (args.update) + return do_update(); + + print_help(argv[0]); + + return 1; }