From 3fb31fb50e75074fe20eda6091e3c64bbfeb7657 Mon Sep 17 00:00:00 2001 From: Ray-Eldath Date: Mon, 11 Sep 2023 16:07:27 +0800 Subject: [PATCH] Fix portability issues on macOS with gcc-13 This PR solves portability issues causing CBDB failed to compile on macOS using gcc-13: - matrix.c: gcc-12 and newer enhanced -Waddress to warn more always-false bool expressions, which makes one line in matrix.c to be warned and GPDB is refused to compile using gcc-12 and newer toolchain. - log.c: on MacOS, timeval.tv_usec is defined differently which needs to be casted in order to be printed by %ld. - sm4.h: type definations conflict with the system header on various different platforms. See: https://gcc.gnu.org/gcc-12/changes.html --- src/backend/utils/adt/matrix.c | 2 +- src/fe_utils/log.c | 2 +- src/include/crypto/sm4.h | 9 --------- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/backend/utils/adt/matrix.c b/src/backend/utils/adt/matrix.c index 6a132fa49f8..41059511e4d 100644 --- a/src/backend/utils/adt/matrix.c +++ b/src/backend/utils/adt/matrix.c @@ -176,7 +176,7 @@ matrix_add(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("matrix_add: non-conformable arrays"))); } - if (ARR_NULLBITMAP(m) || ARR_NULLBITMAP(n)) + if (ARR_HASNULL(m) || ARR_HASNULL(n)) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), errmsg("matrix_add: null array element not allowed in this context"))); diff --git a/src/fe_utils/log.c b/src/fe_utils/log.c index a79ab4e13b9..1220c0e75e5 100644 --- a/src/fe_utils/log.c +++ b/src/fe_utils/log.c @@ -94,7 +94,7 @@ cbdb_log(cbdb_log_level level, const char* file, int line, const char* format, . gettimeofday(&tv, NULL); ptm = localtime(&tv.tv_sec); strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", ptm); - snprintf(timestamp, MAX_TIMESTAMP_LENGTH, "%s.%06ld", date, tv.tv_usec); + snprintf(timestamp, MAX_TIMESTAMP_LENGTH, "%s.%06ld", date, (long) tv.tv_usec); // record timestamp, file name, and line num len = snprintf(NULL, 0, fmt, timestamp, s_level[level], file, line); diff --git a/src/include/crypto/sm4.h b/src/include/crypto/sm4.h index 29d8873944c..3f18b13af9d 100644 --- a/src/include/crypto/sm4.h +++ b/src/include/crypto/sm4.h @@ -12,15 +12,6 @@ #define _SM4_H_ #include "c.h" -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef short int16_t; -typedef unsigned short uint16_t; -typedef int int32_t; -typedef unsigned int uint32_t; -typedef long int64_t; -typedef unsigned long int uint64_t; - # define SM4_ENCRYPT 1 # define SM4_DECRYPT 0