On Mon, Dec 11, 2017 at 07:51:43AM -0600, Eric Blake wrote: > On 12/11/2017 04:16 AM, Stefan Hajnoczi wrote: > > >>> I don't understand the need for the qemu_lock_guard_is_taken(&name) > >>> condition, why not do the following? > >>> > >>> for (QEMU_LOCK_GUARD(type, name, lock); > >>> ; > >>> qemu_lock_guard_unlock(&name)) > >> > >> Because that would be an infinite loop. :) > > > > Sorry, I mean for (...; false; ...). Is there any reason to do > > qemu_lock_guard_is_taken(&name)? > > You need the loop to execute at least once ;) > > But I proposed an alternative that doesn't need is_taken, by: > > for (bool name##done = false, QEMU_LOCK_GUARD(type, name, lock); > ! name##done; name##done = true) > > if we still like the form that declares a for-loop scope.
Okay guys, for loops are hard. I give up programming. Stefan
signature.asc
Description: PGP signature