vsh: Use g_auto(GStrv) to free string list returned by completer callback

This saves us explicit call of g_strfreev() in error path.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
Michal Privoznik 2021-01-26 17:12:50 +01:00
parent 58aeebe096
commit 268f16293c

View File

@ -2778,9 +2778,9 @@ vshReadlineParse(const char *text, int state)
list = vshReadlineOptionsGenerator(text, cmd, partial);
if (opt && opt->completer) {
char **completer_list = opt->completer(autoCompleteOpaque,
partial,
opt->completer_flags);
g_auto(GStrv) completer_list = opt->completer(autoCompleteOpaque,
partial,
opt->completer_flags);
/* Escape completions, if needed (i.e. argument
* we are completing wasn't started with a quote
@ -2805,7 +2805,6 @@ vshReadlineParse(const char *text, int state)
if (completer_list &&
(vshCompleterFilter(&completer_list, text) < 0 ||
virStringListMerge(&list, &completer_list) < 0)) {
g_strfreev(completer_list);
goto cleanup;
}
}