]> git.ozlabs.org Git - ccan/blobdiff - ccan/coroutine/test/api-3.c
coroutine: Move total initialization outside coroutine
[ccan] / ccan / coroutine / test / api-3.c
index dcc3531250683d49c3ef3d9c52281917e9445598..129126549e3edb6ceefd39bb8d2e281dad80587e 100644 (file)
@@ -27,7 +27,6 @@ static void clobber(void *p)
                buf[i] = random() & 0xff;
        }
 
                buf[i] = random() & 0xff;
        }
 
-       s->total = 0;
        for (i = 0; i < sizeof(buf); i++) {
                s->total += buf[i];
        }
        for (i = 0; i < sizeof(buf); i++) {
                s->total += buf[i];
        }
@@ -48,6 +47,7 @@ static void test_metadata(struct coroutine_stack *stack)
        if (COROUTINE_AVAILABLE) {
                struct coroutine_state t;
                struct state s = {
        if (COROUTINE_AVAILABLE) {
                struct coroutine_state t;
                struct state s = {
+                       .total = 0,
                };
 
                coroutine_init(&t, clobber, &s, stack);
                };
 
                coroutine_init(&t, clobber, &s, stack);