Re: [PATCH v6 18/23] conf: support recording ports against virNetworkObjPtr

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

 



[...]

> +
> +
> +int
> +virNetworkObjDeleteAllPorts(virNetworkObjPtr net,
> +                            const char *stateDir)
> +{
> +    char *dir;
> +    DIR *dh;
> +    struct dirent *de;
> +    int rc;
> +    int ret = -1;
> +
> +    if (!(dir = virNetworkObjGetPortStatusDir(net, stateDir)))
> +        goto cleanup;
> +
> +    if ((rc = virDirOpenIfExists(&dh, dir)) <= 0) {

Coverity notes @dh is leaked (and would need init to NULL too)

> +        ret = rc;
> +        goto cleanup;
> +    }
> +
> +    while ((rc = virDirRead(dh, &de, dir)) > 0) {
> +        char *file = NULL;
> +
> +        if (!virStringStripSuffix(de->d_name, ".xml"))
> +            continue;
> +
> +        if (virAsprintf(&file, "%s/%s.xml", dir, de->d_name) < 0)
> +            goto cleanup;
> +
> +        if (unlink(file) < 0 && errno != ENOENT)
> +            VIR_WARN("Unable to delete %s", file);
> +
> +        VIR_FREE(file);
> +    }
> +
> +    virHashRemoveAll(net->ports);
> +
> +    ret = 0;
> + cleanup:
> +    return ret;
> +}
> +

[...]

> +
> +int
> +virNetworkObjPortListExport(virNetworkPtr net,
> +                            virNetworkObjPtr obj,
> +                            virNetworkPortPtr **ports,
> +                            virNetworkPortListFilter filter)
> +{
> +    virNetworkObjPortListExportData data = {
> +        net, obj->def, NULL, filter, 0, false,
> +    };
> +    int ret = -1;
> +
> +    *ports = NULL;
> +
> +    if (ports && VIR_ALLOC_N(data.ports, virHashSize(obj->ports) + 1) < 0)

Coverity notes that checking @ports here is a bit too late since *ports
deref above would have already caused a failure

John

> +        goto cleanup;
> +
> +    virHashForEach(obj->ports, virNetworkObjPortListExportCallback, &data);
> +

[...]

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



[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