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:
Michal Privoznik 2022-01-07 08:52:57 +01:00
parent d7c64453aa
commit 9039b333f6
2 changed files with 0 additions and 16 deletions

View File

@ -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;

View File

@ -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) {