diff options
author | Tim Segers <tsegers@pm.me> | 2022-12-23 20:17:58 +0100 |
---|---|---|
committer | Tim Segers <tsegers@pm.me> | 2023-01-02 15:06:03 +0100 |
commit | 5473e3119d03d079e81fec7a05edfb38c52e1342 (patch) | |
tree | 5f6f2ec0757e16318f98f7bf25b6f935c8fede5a /src | |
parent | 72640eecc20e9babed3661335e2ea71dd10ee618 (diff) | |
download | opendeco-5473e3119d03d079e81fec7a05edfb38c52e1342.tar.gz |
Improve GF input validation
Diffstat (limited to 'src')
-rw-r--r-- | src/opendeco-cli.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/opendeco-cli.c b/src/opendeco-cli.c index e200fcd..8fb0ebd 100644 --- a/src/opendeco-cli.c +++ b/src/opendeco-cli.c @@ -60,10 +60,10 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) arguments->RMV_DIVE = arg ? atof(arg) : -1; break; case 'L': - arguments->gflow = arg ? atoi(arg) : 100; + arguments->gflow = arg ? atoi(arg) : -1; break; case 'H': - arguments->gfhigh = arg ? atoi(arg) : 100; + arguments->gfhigh = arg ? atoi(arg) : -1; break; case 'G': if (arguments->decogasses) @@ -93,6 +93,14 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) argp_failure(state, 1, 0, "Surface air pressure must be positive"); exit(ARGP_ERR_UNKNOWN); } + if (arguments->gflow <= 0) { + argp_failure(state, 1, 0, "GF Low invalid"); + exit(ARGP_ERR_UNKNOWN); + } + if (arguments->gfhigh <= 0) { + argp_failure(state, 1, 0, "GF High invalid"); + exit(ARGP_ERR_UNKNOWN); + } if (arguments->gflow > arguments->gfhigh) { argp_failure(state, 1, 0, "GF Low must not be greater than GF High"); exit(ARGP_ERR_UNKNOWN); |