>>> On 28.11.18 at 16:43, <jgr...@suse.com> wrote:
> On 28/11/2018 16:17, Jan Beulich wrote:
>>>>> On 22.11.18 at 17:40, <jgr...@suse.com> wrote:
>>> @@ -50,7 +55,28 @@ static unsigned long __init parse_amt(const char *s, 
>>> const char **ps,
>>>                                        unsigned long avail)
>>>  {
>>>      unsigned int minus = (*s == '-') ? 1 : 0;
>>> -    unsigned long pages = parse_size_and_unit(s + minus, ps) >> PAGE_SHIFT;
>>> +    unsigned long val, pages = 0;
>>> +
>>> +    /* Avoid accessing s[-1] in case value starts with '%'. */
>>> +    if ( *s == '%' )
>>> +        return 0;
>>> +
>>> +    s += minus;
>>> +    while ( isdigit(*s) )
>>> +    {
>>> +        val = parse_size_and_unit(s, ps);
>>> +        s = *ps;
>>> +        if ( *s == '%' && isdigit(*(s - 1)) && val < (100 << 10) )
>> 
>> In the comment above you talk about s[-1] - why do you use a more
>> complicated (even if just slightly) expression here?
> 
> I dislike using s[-1] in code. In case you prefer it I can use it here.

It makes more obvious what is meant imo. And we have a number
of instances in the tree already.

Jan



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to