Skip to content

Commit 485a300

Browse files
committed
Refactor: tools: Use gchar for override_params in crm_resource.c
Allows us to avoid duplicating strings in main() Signed-off-by: Reid Wahl <[email protected]>
1 parent d115d5d commit 485a300

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

tools/crm_resource.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ command_cb(const gchar *option_name, const gchar *optarg, gpointer data,
312312
options.rsc_cmd = cmd_digests;
313313

314314
if (options.override_params == NULL) {
315-
options.override_params = pcmk__strkey_table(free, free);
315+
options.override_params = pcmk__strkey_table(g_free, g_free);
316316
}
317317

318318
} else if (pcmk__str_any_of(option_name,
@@ -325,7 +325,7 @@ command_cb(const gchar *option_name, const gchar *optarg, gpointer data,
325325
options.operation = g_strdup(option_name + 2); // skip "--"
326326

327327
if (options.override_params == NULL) {
328-
options.override_params = pcmk__strkey_table(free, free);
328+
options.override_params = pcmk__strkey_table(g_free, g_free);
329329
}
330330

331331
if (optarg != NULL) {
@@ -1851,9 +1851,7 @@ main(int argc, char **argv)
18511851
goto done;
18521852
}
18531853

1854-
pcmk__insert_dup(options.override_params, name, value);
1855-
g_free(name);
1856-
g_free(value);
1854+
g_hash_table_insert(options.override_params, name, value);
18571855
}
18581856
}
18591857

tools/crm_resource_print.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ override_xml(pcmk__output_t *out, va_list args) {
362362
return pcmk_rc_ok;
363363
}
364364

365+
// Does not modify overrides or its contents
365366
PCMK__OUTPUT_ARGS("resource-agent-action", "int", "const char *", "const char *",
366367
"const char *", "const char *", "const char *", "GHashTable *",
367368
"crm_exit_t", "int", "const char *", "const char *", "const char *")
@@ -422,6 +423,7 @@ resource_agent_action_default(pcmk__output_t *out, va_list args) {
422423
return pcmk_rc_ok;
423424
}
424425

426+
// Does not modify overrides or its contents
425427
PCMK__OUTPUT_ARGS("resource-agent-action", "int", "const char *", "const char *",
426428
"const char *", "const char *", "const char *", "GHashTable *",
427429
"crm_exit_t", "int", "const char *", "const char *", "const char *")

tools/crm_resource_runtime.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,6 +2238,7 @@ apply_overrides(GHashTable *params, GHashTable *overrides)
22382238
}
22392239
}
22402240

2241+
// Does not modify override_hash or its contents
22412242
crm_exit_t
22422243
cli_resource_execute_from_params(pcmk__output_t *out, const char *rsc_name,
22432244
const char *rsc_class, const char *rsc_prov,
@@ -2330,6 +2331,7 @@ get_action_timeout(pcmk_resource_t *rsc, const char *action)
23302331
return (guint) QB_MIN(timeout_ms, UINT_MAX);
23312332
}
23322333

2334+
// Does not modify override_hash or its contents
23332335
crm_exit_t
23342336
cli_resource_execute(pcmk_resource_t *rsc, const char *requested_name,
23352337
const char *rsc_action, GHashTable *override_hash,

0 commit comments

Comments
 (0)