osu: Modify to do nothing if no argument passed 10/313010/1 accepted/tizen/unified/20240620.050718 accepted/tizen/unified/toolchain/20240624.121646 accepted/tizen/unified/x/20240620.061617 accepted/tizen/unified/x/asan/20240625.092842
authorSangYoun Kwak <sy.kwak@samsung.com>
Tue, 18 Jun 2024 08:06:35 +0000 (17:06 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Tue, 18 Jun 2024 08:12:11 +0000 (17:12 +0900)
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 <sy.kwak@samsung.com>
tools/osu/osu.c

index b08f63907d36e956ea5fc019bb8725aaa79924fe..2f35d7244e4327f173d7a2253805a9a90b7632a0 100644 (file)
@@ -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,29 +81,29 @@ 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);
 }
 
 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();
+
+       if (args.update)
+               return do_update();
+
+       print_help(argv[0]);
 
-       return ret;
+       return 1;
 }