mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-03-14 03:22:06 +01:00
CLEANUP: tree-wide: drop a few useless null-checks before free()
We only support platforms where free(NULL) is a NOP so that null checks are useless before free(). Let's drop them to keep the code clean. There were a few in cfgparse-global, flt_trace, ssl_sock and stats.
This commit is contained in:
parent
709c3be845
commit
fb5e280e0d
@ -456,9 +456,7 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
||||
for (i = 1; *args[i]; i++)
|
||||
len += strlen(args[i]) + 1;
|
||||
|
||||
if (global.desc)
|
||||
free(global.desc);
|
||||
|
||||
free(global.desc);
|
||||
global.desc = d = calloc(1, len);
|
||||
|
||||
d += snprintf(d, global.desc + len - d, "%s", args[1]);
|
||||
@ -487,9 +485,7 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (global.node)
|
||||
free(global.node);
|
||||
|
||||
free(global.node);
|
||||
global.node = strdup(args[1]);
|
||||
}
|
||||
else if (strcmp(args[0], "unix-bind") == 0) {
|
||||
|
||||
@ -688,8 +688,7 @@ parse_trace_flt(char **args, int *cur_arg, struct proxy *px,
|
||||
return 0;
|
||||
|
||||
error:
|
||||
if (conf->name)
|
||||
free(conf->name);
|
||||
free(conf->name);
|
||||
free(conf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1582,9 +1582,7 @@ out:
|
||||
if (ocsp)
|
||||
ssl_sock_free_ocsp(ocsp);
|
||||
|
||||
if (warn)
|
||||
free(warn);
|
||||
|
||||
free(warn);
|
||||
free(err);
|
||||
|
||||
return ret;
|
||||
|
||||
@ -1315,8 +1315,7 @@ static void deinit_stats(void)
|
||||
for (i = 0; i < STATS_DOMAIN_COUNT; ++i) {
|
||||
const int domain = domains[i];
|
||||
|
||||
if (stat_cols[domain])
|
||||
free(stat_cols[domain]);
|
||||
free(stat_cols[domain]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1324,8 +1323,7 @@ REGISTER_POST_DEINIT(deinit_stats);
|
||||
|
||||
static void free_trash_counters(void)
|
||||
{
|
||||
if (trash_counters)
|
||||
free(trash_counters);
|
||||
free(trash_counters);
|
||||
}
|
||||
|
||||
REGISTER_PER_THREAD_FREE(free_trash_counters);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user