mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
src: Don't check for retval of some glib functions
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@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
d7c64453aa
commit
9039b333f6
@ -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;
|
||||
|
||||
|
@ -1827,8 +1827,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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user