aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/opendeco.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/opendeco.c')
-rw-r--r--src/opendeco.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/opendeco.c b/src/opendeco.c
index 79b1f98..8e22e4b 100644
--- a/src/opendeco.c
+++ b/src/opendeco.c
@@ -1,7 +1,9 @@
/* SPDX-License-Identifier: MIT-0 */
+#include <errno.h>
#include <locale.h>
#include <math.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
@@ -45,7 +47,7 @@ int register_gas_use(double depth, double time, const gas_t *gas, double rmv)
}
}
- return -1;
+ return -ENOSPC;
}
void print_gas_use(void)
@@ -129,7 +131,7 @@ int parse_gasses(gas_t **gasses, char *str)
if (scan_gas(&deco_gasses[gas_idx], gas_str)) {
wprintf(L"Invalid gas (%s). Aborting!\n", gas_str);
- exit(-1);
+ exit(EXIT_FAILURE);
}
gas_idx++;
@@ -158,6 +160,12 @@ int main(int argc, char *argv[])
char *gas_default = strdup("Air");
char *decogasses_default = strdup("");
+ if (!gas_default || !decogasses_default) {
+ errno = ENOMEM;
+ perror(__func__);
+ exit(EXIT_FAILURE);
+ }
+
struct arguments arguments = {
.depth = -1,
.time = -1,
@@ -196,7 +204,7 @@ int main(int argc, char *argv[])
if (scan_gas(&bottom_gas, arguments.gas)) {
wprintf(L"Invalid gas (%s). Aborting!\n", arguments.gas);
- exit(-1);
+ exit(EXIT_FAILURE);
}
/* override oxygen mod */