[PATCH 2/2] lib: Don't check for virCapabilitiesAddGuestDomain() retval

Ján Tomko jtomko at redhat.com
Mon Nov 1 14:57:19 UTC 2021


On a Thursday in 2021, Michal Privoznik wrote:
>The virCapabilitiesAddGuestDomain() function can't fail. It
>aborts on OOM. Therefore, there's no need to check for its
>return value.
>
>Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
>---
> src/bhyve/bhyve_capabilities.c |  5 ++---
> src/ch/ch_conf.c               | 10 ++--------
> src/esx/esx_driver.c           |  8 ++++----
> src/hyperv/hyperv_driver.c     |  8 ++++----
> src/libxl/libxl_capabilities.c |  9 ++-------
> src/lxc/lxc_conf.c             | 18 ++++--------------
> src/openvz/openvz_conf.c       |  9 ++-------
> src/qemu/qemu_capabilities.c   | 20 ++++----------------
> src/security/virt-aa-helper.c  | 11 ++---------
> src/test/test_driver.c         |  9 ++-------
> src/vbox/vbox_common.c         |  9 ++-------
> src/vmware/vmware_conf.c       | 12 ++++--------
> src/vz/vz_driver.c             |  4 +---
> tests/testutils.c              | 29 ++++++++++++-----------------
> tests/testutilslxc.c           |  8 ++------
> tests/testutilsqemu.c          | 19 +++++--------------
> tests/testutilsxen.c           | 15 ++++++---------
> tests/vmx2xmltest.c            | 18 ++++--------------
> tests/xml2vmxtest.c            | 19 ++++---------------
> 19 files changed, 68 insertions(+), 172 deletions(-)
>
>diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c
>index cc1c7b66b3..bbcdee724f 100644
>--- a/src/bhyve/bhyve_capabilities.c
>+++ b/src/bhyve/bhyve_capabilities.c
>@@ -54,9 +54,8 @@ virBhyveCapsBuild(void)
>                                     VIR_ARCH_X86_64, "bhyve",
>                                     NULL, 0, NULL);
>
>-    if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_BHYVE,
>-                                      NULL, NULL, 0, NULL) == NULL)
>-        goto error;
>+    virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_BHYVE,
>+                                  NULL, NULL, 0, NULL);
>

This removes the last usage of 'error' in this function.

>     if (!(caps->host.cpu = virCPUProbeHost(caps->host.arch)))
>         VIR_WARN("Failed to get host CPU");

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20211101/87556518/attachment-0001.sig>


More information about the libvir-list mailing list