[libvirt] [PATCH v2 02/12] Fix build errors on FreeBSD

Laine Stump laine at laine.org
Sun Jan 5 02:01:04 UTC 2020


On 1/2/20 12:46 PM, Ryan Moeller wrote:
> From: Ryan Moeller <ryan at freqlabs.com>
>
> Don't free the file string until after it has been used to print the
> error message.
>
> Simplify PCI bus parsing to eliminate an unannotated switch fallthrough.


I don't think this^^^ comment belongs with this patch...


>
> Signed-off-by: Ryan Moeller <ryan at iXsystems.com>
> ---
>   src/conf/virnetworkobj.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
> index 5daf4a8cb1..5c45f49be0 100644
> --- a/src/conf/virnetworkobj.c
> +++ b/src/conf/virnetworkobj.c
> @@ -1895,13 +1895,14 @@ virNetworkObjLoadAllPorts(virNetworkObjPtr net,
>           file = g_strdup_printf("%s/%s.xml", dir, de->d_name);
>   
>           portdef = virNetworkPortDefParseFile(file);
> -        VIR_FREE(file);
> -        file = NULL;
> -
>           if (!portdef) {
>               VIR_WARN("Cannot parse port %s", file);
> +            VIR_FREE(file);
> +            file = NULL;


"file = NULL;" is superfluous, since it is already set to NULL by 
virFree() (which is called by VIR_FREE()).


>               continue;
>           }
> +        VIR_FREE(file);
> +        file = NULL;


Same here.


>   
>           virUUIDFormat(portdef->uuid, uuidstr);
>           if (virHashAddEntry(net->ports, uuidstr, portdef) < 0)






More information about the libvir-list mailing list