From 21730899da69a107c15b2b126062f93bc13041bb Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Tue, 10 Feb 2015 10:08:49 +0900 Subject: [PATCH] Clarify error message. Avoid implying there's a configuration file if none was provided. --- config.c | 6 ++++-- config.h | 2 +- repmgr.c | 17 +++++++++++++---- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/config.c b/config.c index 52c62d81..ceb93bb3 100644 --- a/config.c +++ b/config.c @@ -24,7 +24,7 @@ static void tablespace_list_append(t_configuration_options *options, const char *arg); -void +bool parse_config(const char *config_file, t_configuration_options * options) { char *s, @@ -74,7 +74,7 @@ parse_config(const char *config_file, t_configuration_options * options) log_notice(_("No configuration file provided and default file '%s' not found - " "continuing with default values\n"), config_file); - return; + return false; } /* Read next line */ @@ -187,6 +187,8 @@ parse_config(const char *config_file, t_configuration_options * options) log_err(_("Reconnect intervals must be zero or greater. Check the configuration file.\n")); exit(ERR_BAD_CONFIG); } + + return true; } diff --git a/config.h b/config.h index 78af51f9..c9c61306 100644 --- a/config.h +++ b/config.h @@ -67,7 +67,7 @@ typedef struct #define T_CONFIGURATION_OPTIONS_INITIALIZER { "", -1, NO_UPSTREAM_NODE, "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", "", -1, -1, -1, "", "", "", "", 0, 0, 0, {NULL, NULL} } -void parse_config(const char *config_file, t_configuration_options * options); +bool parse_config(const char *config_file, t_configuration_options * options); void parse_line(char *buff, char *name, char *value); char *trim(char *s); bool reload_config(char *config_file, t_configuration_options * orig_options); diff --git a/repmgr.c b/repmgr.c index b09ddd1d..fe38694a 100644 --- a/repmgr.c +++ b/repmgr.c @@ -133,7 +133,8 @@ main(int argc, char **argv) int c, targ; int action = NO_ACTION; bool check_master_config = false; - bool wal_keep_segments_used = false; + bool wal_keep_segments_used = false; + bool config_file_parsed = false; char *ptr = NULL; progname = get_progname(argv[0]); @@ -388,7 +389,7 @@ main(int argc, char **argv) * however if available we'll parse it anyway for options like 'log_level', * 'use_replication_slots' etc. */ - parse_config(runtime_options.config_file, &options); + config_file_parsed = parse_config(runtime_options.config_file, &options); /* * Initialise pg_bindir - command line parameter will override @@ -441,8 +442,16 @@ main(int argc, char **argv) { if (options.node == -1) { - log_err(_("Node information is missing. " - "Check the configuration file.\n")); + if(config_file_parsed == true) + { + log_err(_("No node information was found. " + "Check the configuration file.\n")); + } + else + { + log_err(_("No node information was found. " + "Please supply a configuration file.\n")); + } exit(ERR_BAD_CONFIG); } }