Fix to print help message once 57/318557/2
authorSangYoun Kwak <sy.kwak@samsung.com>
Wed, 2 Oct 2024 07:15:42 +0000 (16:15 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Wed, 2 Oct 2024 07:18:16 +0000 (16:18 +0900)
Previously, when '--help' option is provided, the help message was
printed twice. To fix this issue, '--help' option is treated as an
argument like other options and print help message if '--help' option is
provided.

Change-Id: I5026fcdfc95a60ea093e15c3860f85eeda3ad2b9
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
tools/osu/osu.c

index 524dbc3819042dd969957f0934dcc5c824d946f1..58563df9fec0101062dd38d2a81c863e960a4acd 100644 (file)
@@ -28,6 +28,7 @@
 
 
 struct arguments {
+       bool help;
        bool resize;
        bool update;
        bool online;
@@ -40,6 +41,7 @@ static int parse_args(int argc, char **argv, struct arguments *args)
        assert(argv);
        assert(args);
 
+       args->help = false;
        args->resize = false;
        args->update = false;
        args->online = false;
@@ -71,7 +73,7 @@ static int parse_args(int argc, char **argv, struct arguments *args)
                                return 0;
                        }
                        case 'h': {
-                               print_help(argv[0]);
+                               args->help = true;
                                return 0;
                        }
                        case '?': {
@@ -109,6 +111,11 @@ int main(int argc, char **argv)
                return 1;
        }
 
+       if (args.help) {
+               print_help(argv[0]);
+               return 0;
+       }
+
        if (args.resize)
                return do_resize();