Since functions virQEMUCapsFillDomainFeatureSEVCaps() and
virQEMUCapsSEVInfoCopy() essentially do the same thing it does
not make sense to have the code duplicated. This patch replaces
the relevant code in the first function with the function call to
the second one.
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
---
Notes:
Pointed out by Michal
src/qemu/qemu_capabilities.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index b002fb98ed..53223417ae 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -6495,18 +6495,7 @@ virQEMUCapsFillDomainFeatureSEVCaps(virQEMUCaps *qemuCaps,
if (!cap)
return;
- domCaps->sev = g_new0(virSEVCapability, 1);
-
- domCaps->sev->pdh = g_strdup(cap->pdh);
- domCaps->sev->cert_chain = g_strdup(cap->cert_chain);
- if (cap->cpu0_id != NULL) {
- domCaps->sev->cpu0_id = g_strdup(cap->cpu0_id);
- }
-
- domCaps->sev->cbitpos = cap->cbitpos;
- domCaps->sev->reduced_phys_bits = cap->reduced_phys_bits;
- domCaps->sev->max_guests = cap->max_guests;
- domCaps->sev->max_es_guests = cap->max_es_guests;
+ virQEMUCapsSEVInfoCopy(&domCaps->sev, cap);
}
--
2.37.1
On 8/2/22 10:50 AM, Kristina Hanicova wrote: > Since functions virQEMUCapsFillDomainFeatureSEVCaps() and > virQEMUCapsSEVInfoCopy() essentially do the same thing it does > not make sense to have the code duplicated. This patch replaces > the relevant code in the first function with the function call to > the second one. > > Signed-off-by: Kristina Hanicova <khanicov@redhat.com> > --- > > Notes: > Pointed out by Michal > > src/qemu/qemu_capabilities.c | 13 +------------ > 1 file changed, 1 insertion(+), 12 deletions(-) > > diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c > index b002fb98ed..53223417ae 100644 > --- a/src/qemu/qemu_capabilities.c > +++ b/src/qemu/qemu_capabilities.c > @@ -6495,18 +6495,7 @@ virQEMUCapsFillDomainFeatureSEVCaps(virQEMUCaps *qemuCaps, > if (!cap) > return; > > - domCaps->sev = g_new0(virSEVCapability, 1); > - > - domCaps->sev->pdh = g_strdup(cap->pdh); > - domCaps->sev->cert_chain = g_strdup(cap->cert_chain); > - if (cap->cpu0_id != NULL) { > - domCaps->sev->cpu0_id = g_strdup(cap->cpu0_id); > - } > - > - domCaps->sev->cbitpos = cap->cbitpos; > - domCaps->sev->reduced_phys_bits = cap->reduced_phys_bits; > - domCaps->sev->max_guests = cap->max_guests; > - domCaps->sev->max_es_guests = cap->max_es_guests; > + virQEMUCapsSEVInfoCopy(&domCaps->sev, cap); > } > > The function virQEMUCapsSEVInfoCopy() already checks whether src is NULL, so you could theoretically just call that function directly without the temporary 'cap' variable, at which point this function just becomes an adapter function. Another quirk: virQEMUCapsSEVInfoCopy() has an int return type, but always returns 0. Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
© 2016 - 2024 Red Hat, Inc.