Replace MAXFILENAME with MAXPGPATH

This commit is contained in:
Ian Barwick
2016-03-31 20:10:39 +09:00
parent aaa8d70cef
commit 4b5c84921c
3 changed files with 29 additions and 33 deletions

View File

@@ -12,9 +12,6 @@ DATA = repmgr.sql uninstall_repmgr.sql
PG_CPPFLAGS = -I$(libpq_srcdir) PG_CPPFLAGS = -I$(libpq_srcdir)
PG_LIBS = $(libpq_pgport) PG_LIBS = $(libpq_pgport)
$(repmgr_OBJS): $(HEADERS)
$(repmgr_OBJS): $(HEADERS)
all: repmgrd repmgr all: repmgrd repmgr
$(MAKE) -C sql $(MAKE) -C sql

View File

@@ -291,7 +291,7 @@ main(int argc, char **argv)
strncpy(runtime_options.superuser, optarg, MAXLEN); strncpy(runtime_options.superuser, optarg, MAXLEN);
break; break;
case 'D': case 'D':
strncpy(runtime_options.dest_dir, optarg, MAXFILENAME); strncpy(runtime_options.dest_dir, optarg, MAXPGPATH);
break; break;
case 'l': case 'l':
/* -l/--local-port is deprecated */ /* -l/--local-port is deprecated */
@@ -415,7 +415,7 @@ main(int argc, char **argv)
case 6: case 6:
if (optarg != NULL) if (optarg != NULL)
{ {
strncpy(runtime_options.pg_rewind, optarg, MAXFILENAME); strncpy(runtime_options.pg_rewind, optarg, MAXPGPATH);
} }
pg_rewind_supplied = true; pg_rewind_supplied = true;
break; break;
@@ -1306,23 +1306,23 @@ do_standby_clone(void)
bool target_directory_provided = false; bool target_directory_provided = false;
bool external_config_file_copy_required = false; bool external_config_file_copy_required = false;
char master_data_directory[MAXFILENAME]; char master_data_directory[MAXPGPATH];
char local_data_directory[MAXFILENAME]; char local_data_directory[MAXPGPATH];
char master_config_file[MAXFILENAME] = ""; char master_config_file[MAXPGPATH] = "";
char local_config_file[MAXFILENAME] = ""; char local_config_file[MAXPGPATH] = "";
bool config_file_outside_pgdata = false; bool config_file_outside_pgdata = false;
char master_hba_file[MAXFILENAME] = ""; char master_hba_file[MAXPGPATH] = "";
char local_hba_file[MAXFILENAME] = ""; char local_hba_file[MAXPGPATH] = "";
bool hba_file_outside_pgdata = false; bool hba_file_outside_pgdata = false;
char master_ident_file[MAXFILENAME] = ""; char master_ident_file[MAXPGPATH] = "";
char local_ident_file[MAXFILENAME] = ""; char local_ident_file[MAXPGPATH] = "";
bool ident_file_outside_pgdata = false; bool ident_file_outside_pgdata = false;
char master_control_file[MAXFILENAME] = ""; char master_control_file[MAXPGPATH] = "";
char local_control_file[MAXFILENAME] = ""; char local_control_file[MAXPGPATH] = "";
char *first_wal_segment = NULL; char *first_wal_segment = NULL;
char *last_wal_segment = NULL; char *last_wal_segment = NULL;
@@ -1490,7 +1490,7 @@ do_standby_clone(void)
{ {
if (strcmp(PQgetvalue(res, i, 0), "data_directory") == 0) if (strcmp(PQgetvalue(res, i, 0), "data_directory") == 0)
{ {
strncpy(master_data_directory, PQgetvalue(res, i, 1), MAXFILENAME); strncpy(master_data_directory, PQgetvalue(res, i, 1), MAXPGPATH);
} }
else if (strcmp(PQgetvalue(res, i, 0), "config_file") == 0) else if (strcmp(PQgetvalue(res, i, 0), "config_file") == 0)
{ {
@@ -1498,7 +1498,7 @@ do_standby_clone(void)
{ {
config_file_outside_pgdata = true; config_file_outside_pgdata = true;
external_config_file_copy_required = true; external_config_file_copy_required = true;
strncpy(master_config_file, PQgetvalue(res, i, 1), MAXFILENAME); strncpy(master_config_file, PQgetvalue(res, i, 1), MAXPGPATH);
} }
} }
else if (strcmp(PQgetvalue(res, i, 0), "hba_file") == 0) else if (strcmp(PQgetvalue(res, i, 0), "hba_file") == 0)
@@ -1507,7 +1507,7 @@ do_standby_clone(void)
{ {
hba_file_outside_pgdata = true; hba_file_outside_pgdata = true;
external_config_file_copy_required = true; external_config_file_copy_required = true;
strncpy(master_hba_file, PQgetvalue(res, i, 1), MAXFILENAME); strncpy(master_hba_file, PQgetvalue(res, i, 1), MAXPGPATH);
} }
} }
else if (strcmp(PQgetvalue(res, i, 0), "ident_file") == 0) else if (strcmp(PQgetvalue(res, i, 0), "ident_file") == 0)
@@ -1516,7 +1516,7 @@ do_standby_clone(void)
{ {
ident_file_outside_pgdata = true; ident_file_outside_pgdata = true;
external_config_file_copy_required = true; external_config_file_copy_required = true;
strncpy(master_ident_file, PQgetvalue(res, i, 1), MAXFILENAME); strncpy(master_ident_file, PQgetvalue(res, i, 1), MAXPGPATH);
} }
} }
else else
@@ -1532,20 +1532,20 @@ do_standby_clone(void)
*/ */
if (target_directory_provided) if (target_directory_provided)
{ {
strncpy(local_data_directory, runtime_options.dest_dir, MAXFILENAME); strncpy(local_data_directory, runtime_options.dest_dir, MAXPGPATH);
strncpy(local_config_file, runtime_options.dest_dir, MAXFILENAME); strncpy(local_config_file, runtime_options.dest_dir, MAXPGPATH);
strncpy(local_hba_file, runtime_options.dest_dir, MAXFILENAME); strncpy(local_hba_file, runtime_options.dest_dir, MAXPGPATH);
strncpy(local_ident_file, runtime_options.dest_dir, MAXFILENAME); strncpy(local_ident_file, runtime_options.dest_dir, MAXPGPATH);
} }
/* /*
* Otherwise use the same data directory as on the remote host * Otherwise use the same data directory as on the remote host
*/ */
else else
{ {
strncpy(local_data_directory, master_data_directory, MAXFILENAME); strncpy(local_data_directory, master_data_directory, MAXPGPATH);
strncpy(local_config_file, master_config_file, MAXFILENAME); strncpy(local_config_file, master_config_file, MAXPGPATH);
strncpy(local_hba_file, master_hba_file, MAXFILENAME); strncpy(local_hba_file, master_hba_file, MAXPGPATH);
strncpy(local_ident_file, master_ident_file, MAXFILENAME); strncpy(local_ident_file, master_ident_file, MAXPGPATH);
log_notice(_("setting data directory to: %s\n"), local_data_directory); log_notice(_("setting data directory to: %s\n"), local_data_directory);
log_hint(_("use -D/--data-dir to explicitly specify a data directory\n")); log_hint(_("use -D/--data-dir to explicitly specify a data directory\n"));
@@ -2253,7 +2253,7 @@ do_standby_follow(void)
int r, int r,
retval; retval;
char data_dir[MAXFILENAME]; char data_dir[MAXPGPATH];
bool success; bool success;
@@ -2336,7 +2336,7 @@ do_standby_follow(void)
master_id = get_master_node_id(master_conn, options.cluster_name); master_id = get_master_node_id(master_conn, options.cluster_name);
strncpy(data_dir, runtime_options.dest_dir, MAXFILENAME); strncpy(data_dir, runtime_options.dest_dir, MAXPGPATH);
} }

View File

@@ -33,7 +33,6 @@
#define MIN_SUPPORTED_VERSION_NUM 90300 #define MIN_SUPPORTED_VERSION_NUM 90300
#include "config.h" #include "config.h"
#define MAXFILENAME 1024
#define ERRBUFF_SIZE 512 #define ERRBUFF_SIZE 512
#define DEFAULT_WAL_KEEP_SEGMENTS "5000" #define DEFAULT_WAL_KEEP_SEGMENTS "5000"
@@ -57,8 +56,8 @@ typedef struct
char dbname[MAXLEN]; char dbname[MAXLEN];
char host[MAXLEN]; char host[MAXLEN];
char username[MAXLEN]; char username[MAXLEN];
char dest_dir[MAXFILENAME]; char dest_dir[MAXPGPATH];
char config_file[MAXFILENAME]; char config_file[MAXPGPATH];
char remote_user[MAXLEN]; char remote_user[MAXLEN];
char superuser[MAXLEN]; char superuser[MAXLEN];
char wal_keep_segments[MAXLEN]; char wal_keep_segments[MAXLEN];
@@ -81,7 +80,7 @@ typedef struct
/* parameter used by STANDBY SWITCHOVER */ /* parameter used by STANDBY SWITCHOVER */
char remote_config_file[MAXLEN]; char remote_config_file[MAXLEN];
char pg_rewind[MAXFILENAME]; char pg_rewind[MAXPGPATH];
/* parameter used by STANDBY {ARCHIVE_CONFIG | RESTORE_CONFIG} */ /* parameter used by STANDBY {ARCHIVE_CONFIG | RESTORE_CONFIG} */
char config_archive_dir[MAXLEN]; char config_archive_dir[MAXLEN];
/* parameter used by CLUSTER CLEANUP */ /* parameter used by CLUSTER CLEANUP */