[libvirt] [PATCH 2/4] remote: Replace VIR_ALLOC_N with g_new0 in remoteRelayDomainEventGraphics

Peter Krempa posted 4 patches 6 years, 3 months ago
[libvirt] [PATCH 2/4] remote: Replace VIR_ALLOC_N with g_new0 in remoteRelayDomainEventGraphics
Posted by Peter Krempa 6 years, 3 months ago
Allocate the array of graphics identity objects using g_new0 to allow
droppint the 'error' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/remote/remote_daemon_dispatch.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index f53c79fec8..392a32fed8 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -596,8 +596,7 @@ remoteRelayDomainEventGraphics(virConnectPtr conn,
     data.remote.service = g_strdup(remote->service);

     data.subject.subject_len = subject->nidentity;
-    if (VIR_ALLOC_N(data.subject.subject_val, data.subject.subject_len) < 0)
-        goto error;
+    data.subject.subject_val = g_new0(remote_domain_event_graphics_identity, data.subject.subject_len);

     for (i = 0; i < data.subject.subject_len; i++) {
         data.subject.subject_val[i].type = g_strdup(subject->identities[i].type);
@@ -619,11 +618,6 @@ remoteRelayDomainEventGraphics(virConnectPtr conn,
     }

     return 0;
-
- error:
-    xdr_free((xdrproc_t)xdr_remote_domain_event_lifecycle_msg,
-             (char *) &data);
-    return -1;
 }

 static int
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 2/4] remote: Replace VIR_ALLOC_N with g_new0 in remoteRelayDomainEventGraphics
Posted by Eric Blake 6 years, 3 months ago
On 10/22/19 9:45 AM, Peter Krempa wrote:
> Allocate the array of graphics identity objects using g_new0 to allow
> droppint the 'error' label.

dropping

> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>   src/remote/remote_daemon_dispatch.c | 8 +-------
>   1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
> index f53c79fec8..392a32fed8 100644
> --- a/src/remote/remote_daemon_dispatch.c
> +++ b/src/remote/remote_daemon_dispatch.c
> @@ -596,8 +596,7 @@ remoteRelayDomainEventGraphics(virConnectPtr conn,
>       data.remote.service = g_strdup(remote->service);
> 
>       data.subject.subject_len = subject->nidentity;
> -    if (VIR_ALLOC_N(data.subject.subject_val, data.subject.subject_len) < 0)
> -        goto error;
> +    data.subject.subject_val = g_new0(remote_domain_event_graphics_identity, data.subject.subject_len);

Long line

> 
>       for (i = 0; i < data.subject.subject_len; i++) {
>           data.subject.subject_val[i].type = g_strdup(subject->identities[i].type);
> @@ -619,11 +618,6 @@ remoteRelayDomainEventGraphics(virConnectPtr conn,
>       }
> 
>       return 0;
> -
> - error:
> -    xdr_free((xdrproc_t)xdr_remote_domain_event_lifecycle_msg,
> -             (char *) &data);
> -    return -1;
>   }

otherwise,
ACK

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list