From 2b54b296f064c14287a7585535aa4b097cf89a6a Mon Sep 17 00:00:00 2001 From: Jon Griffiths Date: Tue, 23 Aug 2016 02:39:38 +1200 Subject: [PATCH] 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 --- ccan/generator/test/compile_fail-4.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); } -- 2.39.2