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

Re: [Xen-devel] [PATCH v12 15/23] x86: refactor psr: CDP: implement set value callback function.



On 17-07-03 03:18:05, Jan Beulich wrote:
> >>> On 03.07.17 at 10:40, <yi.y.sun@xxxxxxxxxxxxxxx> wrote:
> > On 17-07-03 01:01:09, Jan Beulich wrote:
> >> >>> On 03.07.17 at 08:33, <yi.y.sun@xxxxxxxxxxxxxxx> wrote:
> >> > On 17-06-30 06:02:32, Jan Beulich wrote:
> >> >> >>> Yi Sun <yi.y.sun@xxxxxxxxxxxxxxx> 06/30/17 1:30 PM >>>
> > 
> > To decide the return value, we have to know if input 'type' is correct or 
> > not.
> > There are two ways:
> > 1. Check if input 'type' without iteration, like the above codes. Becaue you
> >    don't agree the ordering assumptions, this way is not good.
> > 2. Use iteration, like the original codes. Record if the statement is hit.
> >    If yes, return 0. Otherwise, return -EINVAL. The original codes are 
> > below:
> >     for ( i = 0; i < props->cos_num; i++ )
> >     {
> >         if ( type == props->type[i] || type == props->alt_type )
> >         {
> >             val[i] = new_val;
> >             ret = 0;
> >         }
> >     }
> > 
> > I think the main issue you don't like in the original codes is that
> > the 'ret = 0' may happen for several times. How about below change?
> >     for ( i = 0; i < props->cos_num; i++ )
> >     {
> >         if ( type == props->type[i] || type == props->alt_type )
> >         {
> >             val[i] = new_val;
> >             if ( ret )
> >                 ret = 0;
> >         }
> >     }
> 
> No, the multiple assignments would be no issue at all. As said
> before, what I dislike is the wrongness of the return value if
> the first iteration sets ret to zero, but a subsequent one
> wouldn't. In that case, an error should be signaled.
> 
Ok. Then, how about below change? Thanks!
    int ret = 0;
    for ( i = 0; i < props->cos_num; i++ )
    {
        if ( type == props->type[i] )
        {
            val[i] = new_val;
            ret = 0;
            break;
        }
        else if ( type == props->alt_type )
            val[i] = new_val;
        else
            ret = -EINVAL;
    }

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.