now code compiles with -ansi -pedantic and has less warnings

This commit is contained in:
Christian Kruse
2014-01-09 14:29:14 +01:00
parent 6e3fe059d8
commit 4c3d7f80ed
6 changed files with 16 additions and 12 deletions

View File

@@ -225,12 +225,12 @@ is_pg_dir(char *dir)
struct stat sb;
int r;
// test pgdata
/* test pgdata */
xsnprintf(path, buf_sz, "%s/PG_VERSION", dir);
if (stat(path, &sb) == 0)
return true;
// test tablespace dir
/* test tablespace dir */
sprintf(path, "ls %s/PG_*/ -I*", dir);
r = system(path);
if (r == 0)

View File

@@ -44,6 +44,8 @@ typedef struct
char pgctl_options[MAXLEN];
} t_configuration_options;
#define T_CONFIGURATION_OPTIONS_INITIALIZER { "", -1, "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", "", -1, -1, -1, "", "" }
void parse_config(const char *config_file, t_configuration_options *options);
void parse_line(char *buff, char *name, char *value);
char *trim(char *s);

View File

@@ -138,7 +138,7 @@ is_pgup(PGconn *conn, int timeout)
{
if (twice)
return false;
PQreset(conn); // reconnect
PQreset(conn); /* reconnect */
twice = true;
}
else
@@ -164,10 +164,10 @@ is_pgup(PGconn *conn, int timeout)
break;
failed:
// we need to retry, because we might just have loose the connection once
/* we need to retry, because we might just have loose the connection once */
if (twice)
return false;
PQreset(conn); // reconnect
PQreset(conn); /* reconnect */
twice = true;
}
}

View File

@@ -85,8 +85,8 @@ bool need_a_node = true;
bool require_password = false;
/* Initialization of runtime options */
t_runtime_options runtime_options = { "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, "", "", 0 };
t_configuration_options options = { "", -1, "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", "", -1, -1, -1, "", "" };
t_runtime_options runtime_options = T_RUNTIME_OPTIONS_INITIALIZER;
t_configuration_options options = T_CONFIGURATION_OPTIONS_INITIALIZER;
static char *server_mode = NULL;
static char *server_cmd = NULL;

View File

@@ -69,6 +69,8 @@ typedef struct
int keep_history;
} t_runtime_options;
#define T_RUNTIME_OPTIONS_INITIALIZER { "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, "", "", 0 }
#define SLEEP_MONITOR 2
#endif

View File

@@ -112,7 +112,7 @@ char *pid_file = NULL;
* should initialize with {0} to be ANSI complaint ? but this raises
* error with gcc -Wall
*/
t_configuration_options config = {};
t_configuration_options config = T_CONFIGURATION_OPTIONS_INITIALIZER;
static void help(const char* progname);
static void usage(void);
@@ -220,7 +220,7 @@ main(int argc, char **argv)
exit(ERR_SYS_FAILURE);
break;
case 0: // child process
case 0: /* child process */
pid = setsid();
if (pid == (pid_t)-1)
{
@@ -229,7 +229,7 @@ main(int argc, char **argv)
}
break;
default: // parent process
default: /* parent process */
exit(0);
}
}
@@ -461,7 +461,7 @@ WitnessMonitor(void)
* Check if the master is still available, if after 5 minutes of retries
* we cannot reconnect, return false.
*/
CheckPrimaryConnection(); // this take up to local_options.reconnect_attempts * local_options.reconnect_intvl seconds
CheckPrimaryConnection(); /* this take up to local_options.reconnect_attempts * local_options.reconnect_intvl seconds */
if (PQstatus(primaryConn) != CONNECTION_OK)
{
@@ -546,7 +546,7 @@ StandbyMonitor(void)
* Check if the master is still available, if after 5 minutes of retries
* we cannot reconnect, try to get a new master.
*/
CheckPrimaryConnection(); // this take up to local_options.reconnect_attempts * local_options.reconnect_intvl seconds
CheckPrimaryConnection(); /* this take up to local_options.reconnect_attempts * local_options.reconnect_intvl seconds */
if (PQstatus(primaryConn) != CONNECTION_OK)
{