]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: remove unnecessary null check
authorJonathon Jongsma <jjongsma@redhat.com>
Tue, 13 Apr 2021 16:19:00 +0000 (11:19 -0500)
committerJonathon Jongsma <jjongsma@redhat.com>
Thu, 15 Apr 2021 13:51:37 +0000 (08:51 -0500)
virMediatedDeviceGetSysfsPath() (via g_strdup_printf()) is guaranteed to
return a non-NULL value, so remove the unnecessary checks for NULL.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/qemu/qemu_command.c
src/util/virmdev.c

index fbf8f0fa530d02a8d2dce6ead89db6917d8d06ef..489b15a2839d55b9adc16cd440a1b1d6cc80af07 100644 (file)
@@ -5138,9 +5138,7 @@ qemuBuildHostdevMediatedDevStr(const virDomainDef *def,
     g_autofree char *mdevPath = NULL;
     const char *dev_str = NULL;
 
-    if (!(mdevPath = virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr)))
-        return NULL;
-
+    mdevPath = virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr);
     dev_str = qemuBuildHostdevMdevModelTypeString(mdevsrc);
 
     if (!dev_str)
index 7f4a499536532dbe0a81f3f3a90fb69a210bde87..5f112c775f2dc9bfd031ef9d5606543820236039 100644 (file)
@@ -140,9 +140,7 @@ virMediatedDeviceNew(const char *uuidstr, virMediatedDeviceModelType model)
     g_autoptr(virMediatedDevice) dev = NULL;
     g_autofree char *sysfspath = NULL;
 
-    if (!(sysfspath = virMediatedDeviceGetSysfsPath(uuidstr)))
-        return NULL;
-
+    sysfspath = virMediatedDeviceGetSysfsPath(uuidstr);
     if (!virFileExists(sysfspath)) {
         virReportError(VIR_ERR_DEVICE_MISSING,
                        _("mediated device '%s' not found"), uuidstr);
@@ -208,9 +206,6 @@ virMediatedDeviceGetIOMMUGroupDev(const char *uuidstr)
     g_autofree char *iommu_path = NULL;
     g_autofree char *dev_path = virMediatedDeviceGetSysfsPath(uuidstr);
 
-    if (!dev_path)
-        return NULL;
-
     iommu_path = g_strdup_printf("%s/iommu_group", dev_path);
 
     if (!virFileExists(iommu_path)) {