Re: [PATCH v2 11/13] configurator: Return pointer difference as ptrdiff_t

David Gibson <[email protected]> Tue, 27 Sep 2016 15:10:39 +1000
Newsgroups org.ozlabs.lists.ccan
Message-ID <[email protected]>
On Thu, Sep 22, 2016 at 09:33:14PM -0600, Kevin Locke wrote:
> On LLP64 systems (like 64-bit Windows) long is 32 bits while pointers
> are 64 bits, which results in a warning similar to the following:
> 
> warning C4244: 'return': conversion from '__int64' to 'long', possible loss of data
> 
> for HAVE_STACK_GROWS_UPWARDS.  Fix this by using the ptrdiff_t type
> introduced by C99 for this purpose.
> 
> Signed-off-by: Kevin Locke <[email protected]>

Applying.

> ---
>  tools/configurator/configurator.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/configurator/configurator.c b/tools/configurator/configurator.c
> index a43061b..2acb0b2 100644
> --- a/tools/configurator/configurator.c
> +++ b/tools/configurator/configurator.c
> @@ -298,7 +298,8 @@ static struct test tests[] = {
>  	  "	return __stop_mysec - __start_mysec;\n"
>  	  "}\n" },
>  	{ "HAVE_STACK_GROWS_UPWARDS", DEFINES_EVERYTHING|EXECUTE, NULL, NULL,
> -	  "static long nest(const void *base, unsigned int i)\n"
> +	  "#include <stddef.h>\n"
> +	  "static ptrdiff_t nest(const void *base, unsigned int i)\n"
>  	  "{\n"
>  	  "	if (i == 0)\n"
>  	  "		return (const char *)&i - (const char *)base;\n"

-- 
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

_______________________________________________
ccan mailing list
[email protected]
https://lists.ozlabs.org/listinfo/ccan
signature.asc (application/pgp-signature, 819 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJX6f9OAAoJEGw4ysog2bOSyB8QAL14C6+d4siBqgbEvDthrec0
cbXkDWiUaK+r/R1sTUd/InOABUGud5OfJK7d3OJ2D/YIQueE5eWvTN/Oc2kbpd1+
SKsQ1iJS6gNXf605jNeVaxTDn+MdtXgGuIpYd8Y0dobW1RNd0bk/H13o0GvbkCeQ
WpHZQwlI8Emy/81RRY6DnzQJ1LQBtQ874QfC6srsWCYBi6MQZITu8VdkuHHAA89a
L4lqlfNtpzBVtdRA4zQJnZAXXKIxKTyK91EJQKQ3xDyyNw59H8DC9cVhlJ0nXOnu
7ukFD83EvseNw4ecyAaFxdrrf4Sg9NoDEIoEKTG9nBc0iJgadHlaqivPRXIiViRw
Jf2HpnMd8QkyNSbIg3Ex0qjcdjfPxDxuzwIyM9QODP9pEpMrEZgZsdNcsByWOfT4
rXwT55TOv6VlxsvWykxukbC83A8dwce78Akxz7BKpUElsGapJq7bZRVekIcHio90
QPjwzt+IZFL7+i/5QRtFq3CRdMYld9ScAvgCvgdwgXgDT59GwPqaJadAazpXRofB
Id1rE4qO173w7D2Sa9BhW5RW1iwWCdRsL0Cnj7KE+dOu7iaTdbkyoXJGH2Qp4w1O
gZyvbVdgdj4D8203mbX6tMQ43v4MlX/wy3l3gqvYWweCxH77rXF8TOn8dlxNBh1J
/M0FNvnnHRhSmH79MtXB
=PHKR
-----END PGP SIGNATURE-----