[libvirt PATCH 4/6] tests: reduce variable scope in testSELinuxCheckLabels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



And use g_auto.

Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 tests/securityselinuxlabeltest.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c
index f7dd3c866a..3d886fd827 100644
--- a/tests/securityselinuxlabeltest.c
+++ b/tests/securityselinuxlabeltest.c
@@ -246,10 +246,9 @@ static int
 testSELinuxCheckLabels(testSELinuxFile *files, size_t nfiles)
 {
     size_t i;
-    char *ctx;
 
     for (i = 0; i < nfiles; i++) {
-        ctx = NULL;
+        g_autofree char *ctx = NULL;
         if (getfilecon(files[i].file, &ctx) < 0) {
             if (errno == ENODATA) {
                 /* nothing to do */
@@ -266,10 +265,8 @@ testSELinuxCheckLabels(testSELinuxFile *files, size_t nfiles)
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            "File %s context '%s' did not match expected '%s'",
                            files[i].file, ctx, files[i].context);
-            VIR_FREE(ctx);
             return -1;
         }
-        VIR_FREE(ctx);
     }
     return 0;
 }
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux