Browse Source

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 <jon_p_griffiths@yahoo.com>
Jon Griffiths 9 years ago
parent
commit
2b54b296f0
1 changed files with 2 additions and 2 deletions
  1. 2 2
      ccan/generator/test/compile_fail-4.c

+ 2 - 2
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);
 }