On 01/03/20 20:21, Julio Faracco wrote:
> +    assert(vm_id < 0);
> +
> +    if (snprintf(name, sizeof HAX_VM_DEVFS, "/dev/hax_vm/vm%02d",
> +                 vm_id) < 0)
> +        return NULL;
> +
>      return name;
>  }
>  
> @@ -140,8 +145,12 @@ static char *hax_vcpu_devfs_string(int vm_id, int 
> vcpu_id)
>          return NULL;
>      }
>  
> -    snprintf(name, sizeof HAX_VCPU_DEVFS, "/dev/hax_vm%02d/vcpu%02d",
> -             vm_id, vcpu_id);
> +    assert(vm_id < 0 || vcpu_id < 0);
> +
> +    if (snprintf(name, sizeof HAX_VCPU_DEVFS, "/dev/hax_vm%02d/vcpu%02d",
> +                 vm_id, vcpu_id) < 0)


Can you just replace snprintf with g_strdup_printf instead?  Then you
can also remove MAX_VM_ID and MAX_VCPU_ID.

Paolo


Reply via email to