mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
vsh: Prefer g_strdup_printf() over g_snprintf() in vshReadlineOptionsGenerator()
The vshReadlineOptionsGenerator() function returns a string list of all --options for given command. But the way that individual items on the list are allocated can be written better. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
parent
6ba61373b7
commit
eac14234c8
@ -2627,7 +2627,6 @@ vshReadlineOptionsGenerator(const char *text,
|
|||||||
const char *name = cmd->opts[list_index].name;
|
const char *name = cmd->opts[list_index].name;
|
||||||
bool exists = false;
|
bool exists = false;
|
||||||
vshCmdOpt *opt = last->opts;
|
vshCmdOpt *opt = last->opts;
|
||||||
size_t name_len;
|
|
||||||
|
|
||||||
/* Skip aliases, we do not report them in help output either. */
|
/* Skip aliases, we do not report them in help output either. */
|
||||||
if (cmd->opts[list_index].type == VSH_OT_ALIAS)
|
if (cmd->opts[list_index].type == VSH_OT_ALIAS)
|
||||||
@ -2660,9 +2659,7 @@ vshReadlineOptionsGenerator(const char *text,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
name_len = strlen(name);
|
ret[ret_size] = g_strdup_printf("--%s", name);
|
||||||
ret[ret_size] = g_new0(char, name_len + 3);
|
|
||||||
g_snprintf(ret[ret_size], name_len + 3, "--%s", name);
|
|
||||||
ret_size++;
|
ret_size++;
|
||||||
/* Terminate the string list properly. */
|
/* Terminate the string list properly. */
|
||||||
ret[ret_size] = NULL;
|
ret[ret_size] = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user