On 14.10.2022 13:04, Henry Wang wrote:
>> -----Original Message-----
>> From: Jan Beulich <jbeul...@suse.com>
>>
>>> My initial thought is the "else if" part in p2m_set_allocation. It might be
>>> wrong. Would the code below seems ok to you?
>>>
>>> int err;
>>>
>>> do {
>>>     err = p2m_teardown_allocation(d)
>>> } while ( err == -ERESTART )
>>
>> Sure, one of several ways of doing it.
> 
> Thanks for your confirmation. Just to play safe if you have more simple
> Solutions please do raise it. It is a good opportunity for me to learn and
> personally I am not a big fan of either do-while or the introduced "err"
> which is used only by p2m_teardown_allocation(d), considering the
> p2m_final_teardown(d) has a void return type...

Personally I would probably have written

    while ( p2m_teardown_allocation(d) == -ERESTART )
        /* Nothing - no preemption support here. */;

or

    while ( p2m_teardown_allocation(d) == -ERESTART )
        continue; /* No preemption support here. */

. Otoh with the "err" variable you could ASSERT(!err) after the loop.

Jan

Reply via email to