Skip to content

Commit e9e5efd

Browse files
committed
Refactor: tools: Use pcmk__scan_nvpair() in crm_resource.c:main()
Signed-off-by: Reid Wahl <[email protected]>
1 parent 6cab189 commit e9e5efd

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tools/crm_resource.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,21 +1839,21 @@ main(int argc, char **argv)
18391839
goto done;
18401840
}
18411841

1842-
for (gchar **s = options.remainder; *s; s++) {
1843-
char *name = pcmk__assert_alloc(1, strlen(*s));
1844-
char *value = pcmk__assert_alloc(1, strlen(*s));
1845-
int rc = sscanf(*s, "%[^=]=%s", name, value);
1842+
for (gchar **arg = options.remainder; *arg != NULL; arg++) {
1843+
gchar *name = NULL;
1844+
gchar *value = NULL;
1845+
int rc = pcmk__scan_nvpair(*arg, &name, &value);
18461846

1847-
if (rc != 2) {
1847+
if (rc != pcmk_rc_ok) {
18481848
exit_code = CRM_EX_USAGE;
18491849
g_set_error(&error, PCMK__EXITC_ERROR, exit_code,
1850-
_("Error parsing '%s' as a name=value pair"),
1851-
argv[optind]);
1852-
free(value);
1853-
free(name);
1850+
_("Error parsing '%s' as a name=value pair"), *arg);
18541851
goto done;
18551852
}
1856-
g_hash_table_replace(options.override_params, name, value);
1853+
1854+
pcmk__insert_dup(options.override_params, name, value);
1855+
g_free(name);
1856+
g_free(value);
18571857
}
18581858
}
18591859

0 commit comments

Comments
 (0)