From a459c60145da09d211671004acba2751e9e8c783 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Fri, 26 Oct 2018 10:09:45 +0900 Subject: [PATCH] Avoid defining variable-length arrays As of PostgreSQL commit d9dd406f, variable length arrays are no longer permitted. As they're not actually required anyway, just define appropriate constants. Also noted in GitHub #510. --- dbutils.c | 6 ++++-- repmgr.c | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dbutils.c b/dbutils.c index 0189b4e3..bef993f7 100644 --- a/dbutils.c +++ b/dbutils.c @@ -30,6 +30,8 @@ #include "controldata.h" #include "dirutil.h" +#define NODE_RECORD_PARAM_COUNT 11 + /* mainly for use by repmgrd */ int server_version_num = UNKNOWN_SERVER_VERSION_NUM; @@ -2478,8 +2480,8 @@ _create_update_node_record(PGconn *conn, char *action, t_node_info *node_info) char *slot_name_ptr = NULL; - int param_count = 11; - const char *param_values[param_count]; + int param_count = NODE_RECORD_PARAM_COUNT; + const char *param_values[NODE_RECORD_PARAM_COUNT]; PGresult *res; bool success = true; diff --git a/repmgr.c b/repmgr.c index 001c2848..8f2dad9f 100644 --- a/repmgr.c +++ b/repmgr.c @@ -58,7 +58,7 @@ #define TRANCHE_NAME "repmgrd" #define REPMGRD_STATE_FILE PGSTAT_STAT_PERMANENT_DIRECTORY "/repmgrd_state.txt" - +#define REPMGRD_STATE_FILE_BUF_SIZE 128 PG_MODULE_MAGIC; @@ -256,8 +256,8 @@ set_local_node_id(PG_FUNCTION_ARGS) if (file != NULL) { - int buffer_size = 128; - char buffer[buffer_size]; + int buffer_size = REPMGRD_STATE_FILE_BUF_SIZE; + char buffer[REPMGRD_STATE_FILE_BUF_SIZE]; if (fgets(buffer, buffer_size, file) != NULL) {