summaryrefslogtreecommitdiff
path: root/tests/securityselinuxtest.c
diff options
context:
space:
mode:
authorMichal Privoznik <mprivozn@redhat.com>2021-11-29 09:07:44 +0100
committerMichal Privoznik <mprivozn@redhat.com>2021-12-03 17:18:26 +0100
commitcc2a3c2a946bbbd7d6c152d8e6bb939eac14b3d0 (patch)
tree5ca6e98b555dd066945f00ae7e3ef64dda0d061c /tests/securityselinuxtest.c
parent7f80ff3d9685d900e7b87ff7473fe5f8a9dbdd12 (diff)
downloadlibvirt-cc2a3c2a946bbbd7d6c152d8e6bb939eac14b3d0.tar.gz
lib: Use g_autoptr() for virDomainDef
Instead of calling virDomainDefFree() explicitly, we can annotate variables with g_autoptr(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
Diffstat (limited to 'tests/securityselinuxtest.c')
-rw-r--r--tests/securityselinuxtest.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/tests/securityselinuxtest.c b/tests/securityselinuxtest.c
index 119ad6df34..4912cc3483 100644
--- a/tests/securityselinuxtest.c
+++ b/tests/securityselinuxtest.c
@@ -64,7 +64,7 @@ testBuildDomainDef(bool dynamic,
const char *label,
const char *baselabel)
{
- virDomainDef *def;
+ g_autoptr(virDomainDef) def = NULL;
virSecurityLabelDef *secdef = NULL;
if (!(def = virDomainDefNew(NULL)))
@@ -86,10 +86,9 @@ testBuildDomainDef(bool dynamic,
def->seclabels[0] = secdef;
def->nseclabels++;
- return def;
+ return g_steal_pointer(&def);
error:
- virDomainDefFree(def);
virSecurityLabelDefFree(secdef);
return NULL;
}
@@ -211,7 +210,7 @@ testSELinuxGenLabel(const void *opaque)
{
const struct testSELinuxGenLabelData *data = opaque;
int ret = -1;
- virDomainDef *def;
+ g_autoptr(virDomainDef) def = NULL;
context_t con = NULL;
context_t imgcon = NULL;
@@ -255,7 +254,6 @@ testSELinuxGenLabel(const void *opaque)
cleanup:
context_free(con);
context_free(imgcon);
- virDomainDefFree(def);
return ret;
}