util: don't consider -h an execution failure 38/171838/1
authorMichal Bloch <m.bloch@samsung.com>
Wed, 7 Mar 2018 13:04:40 +0000 (14:04 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Wed, 7 Mar 2018 13:04:43 +0000 (14:04 +0100)
Explicitly requesting help is no longer considered a program execution failure.
Being shown the help due to invalid parameters is still considered a failure.

Change-Id: Iacfbbcd8249926ec9607dee84299ea48c5aa13f3
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
src/logutil/logutil.c

index 3e05c02..2cce252 100755 (executable)
@@ -259,12 +259,10 @@ int parse_options(int argc, char **argv, struct log_file *l_file, struct sort_ve
                        if (sscanf(optarg, "%zu", &l_file->max_rotated) != 1)
                                err_arg_nondigit = 1;
                        break;
-
-               case '?':
-                       // invald option or missing argument - pass to default, show help & break
                case 'h':
-                       // help - pass thru & break
-               default:
+                       show_help(argv[0]);
+                       return 1;
+               default: // invalid option or missing mandatory parameter
                        show_help(argv[0]);
                        return -EINVAL;
                }
@@ -396,8 +394,9 @@ int main(int argc, char **argv)
        else
                sort_vector_apply_config(&logs, &conf);
 
-       if (parse_options(argc, argv, &l_file, &logs, &enabled_buffers, &file_input_names, &action, &dump, &filters) < 0)
-               return 1;
+       r = parse_options(argc, argv, &l_file, &logs, &enabled_buffers, &file_input_names, &action, &dump, &filters);
+       if (r)
+               return r < 0 ? 1 : 0;
 
        if (!validate_buffer_set(&enabled_buffers, list_count(file_input_names)))
                return 1;