From 163b67306b5903ab83ad1de9f9eed2c582177d35 Mon Sep 17 00:00:00 2001 From: Tim Segers Date: Wed, 8 Feb 2023 23:26:35 +0100 Subject: Remove NULL checks before calling free() --- src/opendeco-cli.c | 8 ++------ src/opendeco-conf.c | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/opendeco-cli.c b/src/opendeco-cli.c index 579e013..e3fd852 100644 --- a/src/opendeco-cli.c +++ b/src/opendeco-cli.c @@ -79,9 +79,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) arguments->time = arg ? atof(arg) : -1; break; case 'g': - if (arguments->gas) - free(arguments->gas); - + free(arguments->gas); arguments->gas = strdup(arg); break; case 'p': @@ -100,9 +98,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) arguments->gfhigh = arg ? atoi(arg) : -1; break; case 'G': - if (arguments->decogasses) - free(arguments->decogasses); - + free(arguments->decogasses); arguments->decogasses = strdup(arg); break; case 'S': diff --git a/src/opendeco-conf.c b/src/opendeco-conf.c index d385bb0..e19440b 100644 --- a/src/opendeco-conf.c +++ b/src/opendeco-conf.c @@ -35,9 +35,7 @@ int opendeco_conf_parse(const char *confpath, struct arguments *arguments) toml_datum_t g = toml_string_in(dive, "gas"); if (g.ok) { - if (arguments->gas) - free(arguments->gas); - + free(arguments->gas); arguments->gas = g.u.s; } @@ -73,9 +71,7 @@ int opendeco_conf_parse(const char *confpath, struct arguments *arguments) toml_datum_t G = toml_string_in(deco, "decogasses"); if (G.ok) { - if (arguments->decogasses) - free(arguments->decogasses); - + free(arguments->decogasses); arguments->decogasses = G.u.s; } -- cgit v1.2.3-70-g09d2