[libvirt PATCHv2] qemu: process: use g_new0
Ján Tomko
jtomko at redhat.com
Tue Oct 6 11:39:31 UTC 2020
On a Tuesday in 2020, John Ferlan wrote:
>[...]
>
>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.
>
Actually, there's no way to error at all - VIR_REALLOC_N aborts on OOM.
I don't think it's worth deleting in the meantime.
Jano
>
>John
>
>[...]
-------------- 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/20201006/02d06be7/attachment-0001.sig>
More information about the libvir-list
mailing list