On Tue, Mar 08, 2016 at 06:38:54PM -0600, Chong Li wrote:
> >> +    if (scinfo->num_vcpus > 0) {
> >> +        num_vcpus = scinfo->num_vcpus;
> >> +        GCNEW_ARRAY(vcpus, num_vcpus);
> >> +        for (i = 0; i < num_vcpus; i++) {
> >> +            if (scinfo->vcpus[i].vcpuid < 0 ||
> >> +                scinfo->vcpus[i].vcpuid > max_vcpuid) {
> >> +                LOG(ERROR, "VCPU index is out of range, "
> >> +                           "valid values are within range from 0 to %d",
> >> +                           max_vcpuid);
> >> +                rc = ERROR_INVAL;
> >> +                goto out;
> >> +            }
> >> +            vcpus[i].vcpuid = scinfo->vcpus[i].vcpuid;
> >> +
> >
> > I would suggest you use a separate loop to validate the input, otherwise
> > you risk getting input partial success.
> 
> What do you mean by "partial success"?

You discover error half way through the array. All vcpus before the
error occurs would have been set to new parameters.

> Do you suggest to validate the entire input first, and then create &&
> set the vcpus array?
> 

Yes.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

Reply via email to