diff options
| author | Peter Eisentraut <peter@eisentraut.org> | 2020-02-21 19:49:44 +0100 |
|---|---|---|
| committer | Peter Eisentraut <peter@eisentraut.org> | 2020-02-21 19:58:39 +0100 |
| commit | 3f9c1697dca0b4964f1f5ba624d361d4e0e53051 (patch) | |
| tree | 9fee74a5edd45f3e25e8d424f0dbe7b21d26342a /src/interfaces/ecpg/test/expected/thread-thread_implicit.c | |
| parent | b7fabe80df9a65010bfe5e5d0a979bacebfec382 (diff) | |
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
Diffstat (limited to 'src/interfaces/ecpg/test/expected/thread-thread_implicit.c')
| -rw-r--r-- | src/interfaces/ecpg/test/expected/thread-thread_implicit.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/interfaces/ecpg/test/expected/thread-thread_implicit.c b/src/interfaces/ecpg/test/expected/thread-thread_implicit.c index d0352765486..6c7adb062c8 100644 --- a/src/interfaces/ecpg/test/expected/thread-thread_implicit.c +++ b/src/interfaces/ecpg/test/expected/thread-thread_implicit.c @@ -11,7 +11,7 @@ * Thread test program * by Lee Kindness. */ - +#include <stdint.h> #include <stdlib.h> #include "ecpg_config.h" @@ -53,7 +53,7 @@ int main() #else HANDLE *threads; #endif - int n; + intptr_t n; /* exec sql begin declare section */ @@ -97,7 +97,7 @@ int main() for( n = 0; n < nthreads; n++ ) { #ifndef WIN32 - pthread_create(&threads[n], NULL, test_thread, (void *) (long) (n + 1)); + pthread_create(&threads[n], NULL, test_thread, (void *) (n + 1)); #else threads[n] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) test_thread, (void *) (n+1), 0, NULL); #endif @@ -139,7 +139,7 @@ int main() void *test_thread(void *arg) { - long threadnum = (long)arg; + long threadnum = (intptr_t) arg; /* exec sql begin declare section */ |
