]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_cgroup: Avoid ternary operator when setting @deviceACL
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 21 Jul 2022 10:23:53 +0000 (12:23 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 21 Jul 2022 12:45:50 +0000 (14:45 +0200)
Inside of the qemuSetupDevicesCgroup() there's @deviceACL
variable, which points to a string list of devices that are
allowed in devices controller by default. This list can either
come from qemu.conf (cfg->cgroupDeviceACL) or from a builtin
@defaultDeviceACL. However, a multiline ternary operator is used
when setting the variable which is against our coding style.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_cgroup.c

index 2cc16a69d345d1d3374956aa8cf12f217a91e4b1..e012ba92c0e65b951f397bf591ce1fd2a3920362 100644 (file)
@@ -652,7 +652,7 @@ qemuSetupDevicesCgroup(virDomainObj *vm)
 {
     qemuDomainObjPrivate *priv = vm->privateData;
     g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(priv->driver);
-    const char *const *deviceACL = NULL;
+    const char *const *deviceACL = (const char *const *) cfg->cgroupDeviceACL;
     int rv = -1;
     size_t i;
 
@@ -686,9 +686,8 @@ qemuSetupDevicesCgroup(virDomainObj *vm)
     if (rv < 0)
         return -1;
 
-    deviceACL = cfg->cgroupDeviceACL ?
-                (const char *const *)cfg->cgroupDeviceACL :
-                defaultDeviceACL;
+    if (!deviceACL)
+        deviceACL = defaultDeviceACL;
 
     if (vm->def->nsounds &&
         ((!vm->def->ngraphics && cfg->nogfxAllowHostAudio) ||