From b2328bf62b6465236e318d31a011ced5dccfd580 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 1 May 2018 19:38:26 -0400 Subject: [PATCH] Fix some assorted compiler warnings on Windows. Don't overflow the result type of constant expressions. Don't negate unsigned types. Define HAVE_STDBOOL_H for Visual C++ 2013 and later. Thomas Munro Reviewed-By: Michael Paquier and Tom Lane Discussion: https://postgr.es/m/CAEepm%3D3%3DTDYEXUEcHpEx%2BTwc31wo7PA0oBAiNt6sWmq93MW02A%40mail.gmail.com --- src/backend/replication/basebackup.c | 2 +- src/bin/pgbench/pgbench.c | 3 ++- src/include/pg_config.h.win32 | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c index bc9f585b85..5688cbe2e9 100644 --- a/src/backend/replication/basebackup.c +++ b/src/backend/replication/basebackup.c @@ -1361,7 +1361,7 @@ sendFile(const char *readfilename, const char *tarfilename, struct stat *statbuf char buf[TAR_SEND_SIZE]; uint16 checksum; int checksum_failures = 0; - size_t cnt; + off_t cnt; int i; pgoff_t len = 0; char *page; diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index 21a52c2020..c36556c497 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -67,6 +67,7 @@ #define FNV_PRIME UINT64CONST(0x100000001b3) #define FNV_OFFSET_BASIS UINT64CONST(0xcbf29ce484222325) #define MM2_MUL UINT64CONST(0xc6a4a7935bd1e995) +#define MM2_MUL_TIMES_8 UINT64CONST(0x35253c9ade8f4ca8) #define MM2_ROT 47 /* @@ -968,7 +969,7 @@ getHashFnv1a(int64 val, uint64 seed) static int64 getHashMurmur2(int64 val, uint64 seed) { - uint64 result = seed ^ (sizeof(int64) * MM2_MUL); + uint64 result = seed ^ MM2_MUL_TIMES_8; /* sizeof(int64) */ uint64 k = (uint64) val; k *= MM2_MUL; diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32 index bc437b08f0..e776b34f22 100644 --- a/src/include/pg_config.h.win32 +++ b/src/include/pg_config.h.win32 @@ -357,7 +357,9 @@ #define HAVE_SSL_GET_CURRENT_COMPRESSION 1 /* Define to 1 if stdbool.h conforms to C99. */ -/* #undef HAVE_STDBOOL_H */ +#if (_MSC_VER >= 1800) +#define HAVE_STDBOOL_H 1 +#endif /* Define to 1 if you have the header file. */ /* #undef HAVE_STDINT_H */ -- 2.40.0