Skip to content

Commit fb241ec

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 e9e5efd commit fb241ec

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
@@ -311,7 +311,7 @@ command_cb(const gchar *option_name, const gchar *optarg, gpointer data,
311311
options.rsc_cmd = cmd_digests;
312312

313313
if (options.override_params == NULL) {
314-
options.override_params = pcmk__strkey_table(free, free);
314+
options.override_params = pcmk__strkey_table(g_free, g_free);
315315
}
316316

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

326326
if (options.override_params == NULL) {
327-
options.override_params = pcmk__strkey_table(free, free);
327+
options.override_params = pcmk__strkey_table(g_free, g_free);
328328
}
329329

330330
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
@@ -2237,6 +2237,7 @@ apply_overrides(GHashTable *params, GHashTable *overrides)
22372237
}
22382238
}
22392239

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

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

0 commit comments

Comments
 (0)