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@xxxxxxxxxx> Reviewed-by: Laine Stump <laine@xxxxxxxxxx> --- Changes in v2: - remove NULL checks from 2 additional locations src/qemu/qemu_command.c | 4 +--- src/util/virmdev.c | 7 +------ 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 83bebdd2a8..fbe387253e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -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) diff --git a/src/util/virmdev.c b/src/util/virmdev.c index 7f4a499536..5f112c775f 100644 --- a/src/util/virmdev.c +++ b/src/util/virmdev.c @@ -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)) { -- 2.26.3