generator: Don't print variable unless the generator returned a value
[ccan] / ccan / generator / test / compile_fail-4.c
index f7297cffcd34f11ad5d3cf652ad8b52b5e228abe..712180265a62e9ea5ec5492a974a4d187f3e006f 100644 (file)
@@ -16,8 +16,8 @@ int main(int argc, char *argv[])
        int val;
 #endif
 
-       generator_next_val(val, g);
-       printf("%d", val);
+       if (generator_next_val(val, g))
+               printf("%d", val);
 
        exit(0);
 }