Skip to content

Commit 406369c

Browse files
committed
Refactor: fencer: Don't set build_port_aliases():value to NULL
It's about to go out of scope, so it doesn't get reused. It also doesn't get freed because the aliases table has taken ownership of it. Signed-off-by: Reid Wahl <[email protected]>
1 parent 65c7d99 commit 406369c

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

daemons/fenced/fenced_commands.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -938,10 +938,9 @@ build_port_aliases(const char *hostmap, GList ** targets)
938938
case ' ':
939939
case '\t':
940940
if (name) {
941-
char *value = NULL;
942941
int k = 0;
942+
char *value = pcmk__assert_alloc(1, 1 + i - last);
943943

944-
value = pcmk__assert_alloc(1, 1 + i - last);
945944
memcpy(value, hostmap + last, i - last);
946945

947946
for (int i = 0; value[i] != '\0'; i++) {
@@ -954,7 +953,6 @@ build_port_aliases(const char *hostmap, GList ** targets)
954953
crm_debug("Adding alias '%s'='%s'", name, value);
955954
g_hash_table_replace(aliases, name, value);
956955
*targets = g_list_append(*targets, pcmk__str_copy(value));
957-
value = NULL;
958956
name = NULL;
959957

960958
} else if (i > last) {

0 commit comments

Comments
 (0)