]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virSecuritySELinuxGetSecurityMountOptions: refactor printing
authorPeter Krempa <pkrempa@redhat.com>
Fri, 18 Jul 2025 14:49:11 +0000 (16:49 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 22 Jul 2025 14:52:36 +0000 (16:52 +0200)
Fix linebreaks and remove the use of ternary operator.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/security/security_selinux.c

index 9d14e33340637733d79c110e9f9a51334670efda..fa5d1568ebd1a07514fbef4e7eed80a5772874c2 100644 (file)
@@ -3526,23 +3526,24 @@ virSecuritySELinuxGetSecurityMountOptions(virSecurityManager *mgr,
 {
     char *opts = NULL;
     virSecurityLabelDef *secdef;
+    const char *imagelabel = NULL;
 
     if ((secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_SELINUX_NAME))) {
         if (!secdef->imagelabel)
             secdef->imagelabel = virSecuritySELinuxGenImageLabel(mgr, def);
 
         if (secdef->imagelabel) {
-            opts = g_strdup_printf(
-                                   ",context=\"%s\"",
+            opts = g_strdup_printf(",context=\"%s\"",
                                    (const char*) secdef->imagelabel);
         }
+
+        imagelabel = secdef->imagelabel;
     }
 
     if (!opts)
         opts = g_strdup("");
 
-    VIR_DEBUG("imageLabel=%s opts=%s",
-              secdef ? secdef->imagelabel : "(null)", opts);
+    VIR_DEBUG("imageLabel=%s opts=%s", NULLSTR(imagelabel), opts);
     return opts;
 }