From 1760b96368ae41e76e89a7064254f995713a41e5 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 14 Nov 2019 17:17:09 +0100 Subject: [PATCH] hints: no need to check for NULL before free free() itself checks for NULL. --- lib/label/hints.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/label/hints.c b/lib/label/hints.c index c6039d555..ac2c0895b 100644 --- a/lib/label/hints.c +++ b/lib/label/hints.c @@ -688,13 +688,11 @@ static int _read_hint_file(struct cmd_context *cmd, struct dm_list *hints, int * _filter_to_str(cmd, devices_global_filter_CFG, &filter_str); if (!filter_str || strcmp(filter_str, _hint_line + keylen)) { log_debug("ignore hints with different global_filter"); - if (filter_str) - free(filter_str); + free(filter_str); *needs_refresh = 1; break; } - if (filter_str) - free(filter_str); + free(filter_str); continue; } @@ -703,13 +701,11 @@ static int _read_hint_file(struct cmd_context *cmd, struct dm_list *hints, int * _filter_to_str(cmd, devices_filter_CFG, &filter_str); if (!filter_str || strcmp(filter_str, _hint_line + keylen)) { log_debug("ignore hints with different filter"); - if (filter_str) - free(filter_str); + free(filter_str); *needs_refresh = 1; break; } - if (filter_str) - free(filter_str); + free(filter_str); continue; } @@ -907,13 +903,11 @@ int write_hint_file(struct cmd_context *cmd, int newhints) _filter_to_str(cmd, devices_global_filter_CFG, &filter_str); fprintf(fp, "global_filter:%s\n", filter_str ?: "-"); - if (filter_str) - free(filter_str); + free(filter_str); _filter_to_str(cmd, devices_filter_CFG, &filter_str); fprintf(fp, "filter:%s\n", filter_str ?: "-"); - if (filter_str) - free(filter_str); + free(filter_str); fprintf(fp, "scan_lvs:%d\n", cmd->scan_lvs);