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

Kevin Locke <[email protected]> Thu, 22 Sep 2016 21:33:14 -0600
Newsgroups org.ozlabs.lists.ccan
Message-ID <054fcecdae96c41af557f6e7e2981074a69317a9.1474600863.git.kevin@kevinlocke.name>
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]>
---
 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"
-- 
2.9.3

_______________________________________________
ccan mailing list
[email protected]
https://lists.ozlabs.org/listinfo/ccan