pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix compiler warnings on 64-bit Windows
Date: Fri, 21 Feb 2020 19:02:27 +0000
Message-ID: <E1j5DZD-0003ah-IT@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3f9c1697dca0b4964f1f5ba624d361d4e0e53051

Modified Files
--------------
src/interfaces/ecpg/test/expected/thread-alloc.c   | 41 ++++++-------
src/interfaces/ecpg/test/expected/thread-prep.c    | 67 +++++++++++-----------
src/interfaces/ecpg/test/expected/thread-thread.c  | 61 ++++++++++----------
.../ecpg/test/expected/thread-thread_implicit.c    |  8 +--
src/interfaces/ecpg/test/thread/alloc.pgc          |  7 ++-
src/interfaces/ecpg/test/thread/prep.pgc           |  7 ++-
src/interfaces/ecpg/test/thread/thread.pgc         |  7 ++-
.../ecpg/test/thread/thread_implicit.pgc           |  8 +--
8 files changed, 106 insertions(+), 100 deletions(-)



Message-ID: <E1j5DZD-0003ah-IT@gemulon.postgresql.org>
Permalink:  ../E1j5DZD-0003ah-IT@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1j5DZD-0003ah-IT@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: peter@eisentraut.org
  Subject: Re: pgsql: Fix compiler warnings on 64-bit Windows
  In-Reply-To: <E1j5DZD-0003ah-IT@gemulon.postgresql.org>
  References: <E1j5DZD-0003ah-IT@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox