[ccan] [PATCH v2 10/13] configurator: Fix warning in HAVE_FOR_LOOP_DECLARATION

David Gibson david at gibson.dropbear.id.au
Tue Sep 27 15:10:11 AEST 2016


On Thu, Sep 22, 2016 at 09:33:13PM -0600, Kevin Locke wrote:
> Visual C++ prints "warning C4702: unreachable code" due to the return
> statement after the for loop which is never reached.  Fix this by
> setting a variable returned by a single return statement at the end.
> 
> Signed-off-by: Kevin Locke <kevin at kevinlocke.name>

Applying.

> ---
>  tools/configurator/configurator.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/configurator/configurator.c b/tools/configurator/configurator.c
> index d3e01cd..a43061b 100644
> --- a/tools/configurator/configurator.c
> +++ b/tools/configurator/configurator.c
> @@ -222,8 +222,9 @@ static struct test tests[] = {
>  	  "	return sizeof(off_t) == 8 ? 0 : 1;\n"
>  	  "}\n" },
>  	{ "HAVE_FOR_LOOP_DECLARATION", INSIDE_MAIN, NULL, NULL,
> -	  "for (int i = 0; i < argc; i++) { return 0; };\n"
> -	  "return 1;" },
> +	  "int ret = 1;\n"
> +	  "for (int i = 0; i < argc; i++) { ret = 0; };\n"
> +	  "return ret;" },
>  	{ "HAVE_FLEXIBLE_ARRAY_MEMBER", OUTSIDE_MAIN, NULL, NULL,
>  	  "struct foo { unsigned int x; int arr[]; };" },
>  	{ "HAVE_GETPAGESIZE", DEFINES_FUNC, NULL, NULL,

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/ccan/attachments/20160927/c3227259/attachment.sig>


More information about the ccan mailing list