mirror of
https://github.com/perk11/runwhenidle.git
synced 2026-01-08 21:27:57 -05:00
Fix passing invalid value to pause-method argument not causing an error
This commit is contained in:
@@ -111,13 +111,14 @@ char *parse_command_line_arguments(int argc, char *argv[]) {
|
||||
for (int i = 0; i < sizeof(method); i++) {
|
||||
method[i] = toupper(method[i]);
|
||||
}
|
||||
pause_method = PAUSE_METHOD_UNKNOWN;
|
||||
for (int i = 1; pause_method_string[i] != NULL; i++) {
|
||||
if (strcmp(pause_method_string[i], method) == 0) {
|
||||
pause_method = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!pause_method) {
|
||||
if (pause_method == PAUSE_METHOD_UNKNOWN) {
|
||||
fprintf_error("Invalid value for --pause-method|m argument: \"%s\". Supported values: ", optarg);
|
||||
for (int i = 1; pause_method_string[i] != NULL; i++) {
|
||||
fprintf_error(pause_method_string[i]);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#define RUNWHENIDLE_PAUSE_METHODS_H
|
||||
|
||||
enum pause_method {
|
||||
PAUSE_METHOD_UNKNOWN = 0,
|
||||
//order must match order in pause_method_string
|
||||
PAUSE_METHOD_SIGTSTP = 1,
|
||||
PAUSE_METHOD_SIGSTOP = 2,
|
||||
|
||||
Reference in New Issue
Block a user