On Wednesday, 2021-03-17 at 18:19:58 +01, Paolo Bonzini wrote:

> On 17/03/21 16:17, David Edmondson wrote:
>>> +    if (tkt) {
>>> +        if (tkt->read) {
>>> +            if (lock->owners >= 0) {
>>> +                lock->owners++;
>>> +                co = tkt->co;
>>> +            }
>>> +        } else {
>>> +            if (lock->owners == 0) {
>>> +                lock->owners = -1;
>>> +                co = tkt->co;
>>> +            }
>>> +        }
>>> +    }
>>> +
>>> +    if (co) {
>>> +        QSIMPLEQ_REMOVE_HEAD(&lock->tickets, next);
>>> +        qemu_co_mutex_unlock(&lock->mutex);
>>> +        aio_co_wake(co);
>>> +    } else {
>>> +        qemu_co_mutex_unlock(&lock->mutex);
>>> +    }
>> 
>> This block could be pushed up into the earlier block, but I imagine that
>> the compiler will do it for you.
>
> I guess I could do
>
>      if (!tkt || (tkt->read ? lock->owners < 0 : lock->owners != 0)) {
>          qemu_co_mutex_unlock(&lock->mutex);
>          return;
>      }
>      if (tkt->read) {
>          lock->owners++;
>      } else {
>          lock->owners = -1;
>      }
>
>      co = tkt->co;
>      QSIMPLEQ_REMOVE_HEAD(&lock->tickets, next);
>      qemu_co_mutex_unlock(&lock->mutex);
>      aio_co_wake(co);
>
> but I find it less readable.

Agreed.

> So that leaves only the of/or typo, right?

Yes.

dme.
-- 
In heaven there is no beer, that's why we drink it here.

Reply via email to