]> git.ozlabs.org Git - ccan/commit
coroutine: Move total initialization outside coroutine
authorDavid Gibson <david@gibson.dropbear.id.au>
Tue, 24 Jan 2017 09:39:45 +0000 (20:39 +1100)
committerDavid Gibson <david@gibson.dropbear.id.au>
Tue, 24 Jan 2017 10:22:27 +0000 (21:22 +1100)
commitd24c5a0105b14dd20efd6c3c9f1ae0a35ca50c84
treeae17f50b255ba269f57d4dd4c502e69e26a8d3e5
parentace6131ed7d12a48fc6f019a0d69e94f30c5cd3e
coroutine: Move total initialization outside coroutine

The sample coroutine in api-3 initializes a total to 0, then adds up the
pseudo-random data it has placed into a stack buffer, to ensure that the
compiler won't elide the reading and writing of that buffer.  After the
coroutine has completed, we verify that total is non-zero so that we'll
detect if the coroutine failed to execute entirely.

Except that the initialization of total is within the coroutine itself,
so it could also be non-zero due to it simply being uninitialized.  This
moves the initialization outside the coroutine, to make the test a little
more robust.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
ccan/coroutine/test/api-3.c