Re: [libvirt PATCHv2] qemu: process: use g_new0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[...]

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux