[libvirt PATCH 3/4] tests: use g_new0 instead of VIR_ALLOC_N

Peter Krempa pkrempa at redhat.com
Wed Sep 23 07:33:21 UTC 2020


On Wed, Sep 23, 2020 at 01:04:17 +0200, Ján Tomko wrote:
> Signed-off-by: Ján Tomko <jtomko at redhat.com>
> ---

[...]

> diff --git a/tests/securityselinuxtest.c b/tests/securityselinuxtest.c
> index ae4b08b9d8..fd746d1ca1 100644
> --- a/tests/securityselinuxtest.c
> +++ b/tests/securityselinuxtest.c
> @@ -71,8 +71,7 @@ testBuildDomainDef(bool dynamic,
>          goto error;
>  
>      def->virtType = VIR_DOMAIN_VIRT_KVM;
> -    if (VIR_ALLOC_N(def->seclabels, 1) < 0)
> -        goto error;
> +    def->seclabels = g_new0(char, 1);

'def' is virDomainDefPtr thus 'def->seclabels' is not char but 'virSecurityLabelDefPtr *'

The compiler didn't moan because it's a double pointer, but it certainly
doens't have enough size nor the correct type.

>  
>      if (VIR_ALLOC(secdef) < 0)
>          goto error;




More information about the libvir-list mailing list