[libvirt PATCHv2] qemu: process: use g_new0

John Ferlan jferlan at redhat.com
Tue Oct 6 11:01:41 UTC 2020


[...]

Coverity notes...

> @@ -1074,20 +1070,17 @@ qemuProcessHandleGraphics(qemuMonitorPtr mon G_GNUC_UNUSED,
>      virDomainEventGraphicsSubjectPtr subject = NULL;
>      size_t i;
>  
> -    if (VIR_ALLOC(localAddr) < 0)
> -        goto error;
> +    localAddr = g_new0(virDomainEventGraphicsAddress, 1);
>      localAddr->family = localFamily;
>      localAddr->service = g_strdup(localService);
>      localAddr->node = g_strdup(localNode);
>  
> -    if (VIR_ALLOC(remoteAddr) < 0)
> -        goto error;
> +    remoteAddr = g_new0(virDomainEventGraphicsAddress, 1);
>      remoteAddr->family = remoteFamily;
>      remoteAddr->service = g_strdup(remoteService);
>      remoteAddr->node = g_strdup(remoteNode);
>  
> -    if (VIR_ALLOC(subject) < 0)
> -        goto error;
> +    subject = g_new0(virDomainEventGraphicsSubject, 1);
>      if (x509dname) {
>          if (VIR_REALLOC_N(subject->identities, subject->nidentity+1) < 0)
>              goto error;

There's no way to error: now w/o @localAddr, @remoteAddr, & @subject
being allocated, thus there's no need to check whether they're non-null
before accessing.


John

[...]




More information about the libvir-list mailing list