qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v3] i386: Fix GCC warning with snprintf when HAX is enabled


From: Julio Faracco
Subject: Re: [PATCH v3] i386: Fix GCC warning with snprintf when HAX is enabled
Date: Sun, 1 Mar 2020 22:58:29 -0300

Sorry my ignorance, Paolo.
But why should I remove MAX_{VM,VCPU}_ID?

Did you mean that check?
    if (vm_id > MAX_VM_ID || vcpu_id > MAX_VCPU_ID) {
        fprintf(stderr, "Too big vm id %x or vcpu id %x\n", vm_id, vcpu_id);
        return NULL;
    }

Wouldn't it be dangerous?

--
Julio Cesar Faracco

Em dom., 1 de mar. de 2020 às 21:05, Paolo Bonzini
<address@hidden> escreveu:
>
> 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

[Prev in Thread] Current Thread [Next in Thread]