From: Jon Griffiths Date: Mon, 22 Aug 2016 14:39:38 +0000 (+1200) Subject: generator: Don't print variable unless the generator returned a value X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=2b54b296f064c14287a7585535aa4b097cf89a6a;hp=03f100b281441a953d4ec858389f82e25a95c043 generator: Don't print variable unless the generator returned a value clang warns that the generator assignment is conditional which could lead to passing an undefined variable to printf. Signed-off-by: Jon Griffiths --- diff --git a/ccan/generator/test/compile_fail-4.c b/ccan/generator/test/compile_fail-4.c index f7297cff..71218026 100644 --- a/ccan/generator/test/compile_fail-4.c +++ b/ccan/generator/test/compile_fail-4.c @@ -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); }