mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
chExtractVersion: use g_auto*
There are two variables that can be freed automatically: @cmd (which allows us to drop explicit virCommandFree() call at the end of the function) and @help which was never freed (and thus leaked). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
7a90431d7d
commit
4292d4b786
@ -196,10 +196,10 @@ chExtractVersion(virCHDriver *driver)
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
unsigned long version;
|
unsigned long version;
|
||||||
char *help = NULL;
|
g_autofree char *help = NULL;
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
g_autofree char *ch_cmd = g_find_program_in_path(CH_CMD);
|
g_autofree char *ch_cmd = g_find_program_in_path(CH_CMD);
|
||||||
virCommand *cmd = NULL;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
|
|
||||||
if (!ch_cmd)
|
if (!ch_cmd)
|
||||||
return -2;
|
return -2;
|
||||||
@ -236,6 +236,5 @@ chExtractVersion(virCHDriver *driver)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virCommandFree(cmd);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user