There are a few glib functions that abort on OOM and thus there's no point in checking their retval against NULL. Nevertheless, we do have those checks in a few places. Remove them. Generated using the following spatch: @@ expression x; identifier n; expression r; @@ ( x = g_strdup_printf(...); | x = g_strdup_vprintf(...); | x = g_strdup(...); | x = g_strndup(...); | x = g_new0(...); | x = g_realloc(...); ) ... when != x - if(!x) ( - return r; | - goto n; ) Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/hyperv/hyperv_driver.c | 14 -------------- src/util/virprocess.c | 2 -- 2 files changed, 16 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 3327f0132e..7b684e04ba 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -482,8 +482,6 @@ hypervDomainAddVirtualDiskParent(virDomainPtr domain, parent__PATH = g_strdup_printf("\\\\%s\\Root\\Virtualization\\V2:" "Msvm_ResourceAllocationSettingData.InstanceID=\"%s\"", hostname, parentInstanceIDEscaped); - if (!parent__PATH) - return -1; if (hypervSetEmbeddedProperty(controllerResource, "Parent", parent__PATH) < 0) return -1; @@ -529,9 +527,6 @@ hypervDomainAddVirtualHardDisk(virDomainPtr domain, "Msvm_ResourceAllocationSettingData.InstanceID=\"%s\"", hostname, vhdInstanceIdEscaped); - if (!vhd__PATH) - return -1; - if (hypervSetEmbeddedProperty(volumeResource, "Parent", vhd__PATH) < 0) return -1; @@ -660,8 +655,6 @@ hypervDomainAttachPhysicalDisk(virDomainPtr domain, controller__PATH = g_strdup_printf("\\\\%s\\Root\\Virtualization\\V2:" "Msvm_ResourceAllocationSettingData.InstanceID=\"%s\"", hostname, controllerInstanceIdEscaped); - if (!controller__PATH) - return -1; if (hypervSetEmbeddedProperty(diskResource, "Parent", controller__PATH) < 0) return -1; @@ -711,8 +704,6 @@ hypervDomainAddOpticalDrive(virDomainPtr domain, parent__PATH = g_strdup_printf("\\\\%s\\Root\\Virtualization\\V2:" "Msvm_ResourceAllocationSettingData.InstanceID=\"%s\"", hostname, parentInstanceIDEscaped); - if (!parent__PATH) - return -1; if (hypervSetEmbeddedProperty(driveResource, "Parent", parent__PATH) < 0) return -1; @@ -756,8 +747,6 @@ hypervDomainAddOpticalDisk(virDomainPtr domain, vhd__PATH = g_strdup_printf("\\\\%s\\Root\\Virtualization\\V2:" "Msvm_ResourceAllocationSettingData.InstanceID=\"%s\"", hostname, vhdInstanceIdEscaped); - if (!vhd__PATH) - return -1; if (hypervSetEmbeddedProperty(volumeResource, "Parent", vhd__PATH) < 0) return -1; @@ -829,9 +818,6 @@ hypervDomainAttachFloppy(virDomainPtr domain, "Msvm_ResourceAllocationSettingData.InstanceID=\"%s\"", hostname, vhdInstanceIdEscaped); - if (!vfd__PATH) - return -1; - if (hypervSetEmbeddedProperty(volumeResource, "Parent", vfd__PATH) < 0) return -1; diff --git a/src/util/virprocess.c b/src/util/virprocess.c index c74bd16fe6..66b20b0a33 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -1826,8 +1826,6 @@ virProcessGetSchedInfo(unsigned long long *cpuWait, proc = g_strdup_printf("/proc/%d/task/%d/sched", (int) pid, (int) tid); else proc = g_strdup_printf("/proc/%d/sched", (int) pid); - if (!proc) - return -1; /* The file is not guaranteed to exist (needs CONFIG_SCHED_DEBUG) */ if (access(proc, R_OK) < 0) { -- 2.34.1