Fix compiler warnings on 64-bit Windows
authorPeter Eisentraut <peter@eisentraut.org>
Fri, 21 Feb 2020 18:49:44 +0000 (19:49 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Fri, 21 Feb 2020 18:58:39 +0000 (19:58 +0100)
commit3f9c1697dca0b4964f1f5ba624d361d4e0e53051
tree9fee74a5edd45f3e25e8d424f0dbe7b21d26342a
parentb7fabe80df9a65010bfe5e5d0a979bacebfec382
Fix compiler warnings on 64-bit Windows

GCC reports various instances of

warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

and MSVC equivalently

warning C4312: 'type cast': conversion from 'int' to 'void *' of greater size
warning C4311: 'type cast': pointer truncation from 'void *' to 'long'

in ECPG test files.  This is because void* and long are cast back and
forth, but on 64-bit Windows, these have different sizes.  Fix by
using intptr_t instead.

The code actually worked fine because the integer values in use are
all small.  So this is just to get the test code to compile warning-free.

This change is simplified by having made stdint.h required (commit
957338418b69e9774ccc1bab59f765a62f0aa6f9).  Before this it would have
been more complicated because the ecpg test source files don't use the
full pg_config.h.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/5d398bbb-262a-5fed-d839-d0e5cff3c0d7%402ndquadrant.com
src/interfaces/ecpg/test/expected/thread-alloc.c
src/interfaces/ecpg/test/expected/thread-prep.c
src/interfaces/ecpg/test/expected/thread-thread.c
src/interfaces/ecpg/test/expected/thread-thread_implicit.c
src/interfaces/ecpg/test/thread/alloc.pgc
src/interfaces/ecpg/test/thread/prep.pgc
src/interfaces/ecpg/test/thread/thread.pgc
src/interfaces/ecpg/test/thread/thread_implicit.pgc