pgpool2.git / summary / log / commit / refs
commit bc9119f61b187577d64b63ebffb6f5412202f24f
Author: Takuma Hoshiai <hoshiai@sraoss.co.jp>
Date: Tue Nov 13 06:54:57 2018 +0000
Fix compiler warnings with gcc 8.x.
src/auth/pool_auth.c | 8 ++++++++
src/auth/pool_hba.c | 6 ++++--
src/auth/pool_passwd.c | 1 +
src/include/pool_config.h | 3 +++
src/include/watchdog/watchdog.h | 2 +-
src/libs/pcp/pcp.c | 6 +++---
src/main/main.c | 18 +++---------------
src/main/pgpool_main.c | 8 ++++----
src/protocol/child.c | 2 +-
src/tools/pgenc/pg_enc.c | 2 +-
src/tools/pgproto/read.c | 14 --------------
src/tools/pgproto/send.c | 18 +++++-------------
src/watchdog/watchdog.c | 2 +-
src/watchdog/wd_json_data.c | 2 +-
14 files changed, 36 insertions(+), 56 deletions(-)
diff --git a/src/auth/pool_auth.c b/src/auth/pool_auth.c
index 598b03bfe..99758222c 100644
--- a/src/auth/pool_auth.c
+++ b/src/auth/pool_auth.c
@@ -1440,6 +1440,14 @@ authenticate_frontend(POOL_CONNECTION * frontend)
break;
case uaTrust:
frontend->frontend_authenticated = true;
+ break;
+#ifdef USE_PAM
+ case uaPAM:
+ ereport(ERROR,
+ (errmsg("authenticate_frontend called with PAM")));
+ break;
+#endif /* USE_PAM */
+
}
}
diff --git a/src/auth/pool_hba.c b/src/auth/pool_hba.c
index 2d7bbac6d..06b372782 100644
--- a/src/auth/pool_hba.c
+++ b/src/auth/pool_hba.c
@@ -128,7 +128,9 @@ static bool next_token(char **lineptr, char *buf, int bufsz,
int elevel, char **err_msg);
static List *next_field_expand(const char *filename, char **lineptr,
int elevel, char **err_msg);
+#ifdef NOT_USED
static POOL_STATUS CheckUserExist(char *username);
+#endif
#ifdef USE_PAM
#ifdef HAVE_PAM_PAM_APPL_H
@@ -2063,8 +2065,7 @@ static POOL_STATUS CheckPAMAuth(POOL_CONNECTION * frontend, char *user, char *pa
#endif /* USE_PAM */
-
-
+#ifdef NOT_USED
static POOL_STATUS CheckUserExist(char *username)
{
char *passwd;
@@ -2080,3 +2081,4 @@ static POOL_STATUS CheckUserExist(char *username)
*/
return POOL_CONTINUE;
}
+#endif
diff --git a/src/auth/pool_passwd.c b/src/auth/pool_passwd.c
index b31de5e51..c84136bb4 100644
--- a/src/auth/pool_passwd.c
+++ b/src/auth/pool_passwd.c
@@ -577,6 +577,7 @@ get_decrypted_password(const char *shadow_pass)
{
ereport(ERROR,
(errmsg("unable to decrypt password")));
+ return NULL;
}
#endif
diff --git a/src/include/pool_config.h b/src/include/pool_config.h
index 844e998d0..af3d153bb 100644
--- a/src/include/pool_config.h
+++ b/src/include/pool_config.h
@@ -26,12 +26,15 @@
#ifndef POOL_CONFIG_H
#define POOL_CONFIG_H
+#include <sys/utsname.h>
+
#include "pcp/libpcp_ext.h"
/*
* watchdog
*/
#define WD_MAX_HOST_NAMELEN (128)
+#define WD_MAX_NODE_NAMELEN (WD_MAX_HOST_NAMELEN + POOLCONFIG_MAXPORTLEN + sizeof(((struct utsname *)NULL)->sysname) + sizeof(((struct utsname *)NULL)->nodename) + 3)
#define WD_MAX_PATH_LEN (128)
#define MAX_WATCHDOG_NUM (128)
#define WD_SEND_TIMEOUT (1)
diff --git a/src/include/watchdog/watchdog.h b/src/include/watchdog/watchdog.h
index 36f384116..78df76c88 100644
--- a/src/include/watchdog/watchdog.h
+++ b/src/include/watchdog/watchdog.h
@@ -111,7 +111,7 @@ typedef struct WatchdogNode
* from the node */
struct timeval last_sent_time; /* timestamp when last packet was sent on
* the node */
- char nodeName[WD_MAX_HOST_NAMELEN]; /* name of this node */
+ char nodeName[WD_MAX_NODE_NAMELEN]; /* name of this node */
char hostname[WD_MAX_HOST_NAMELEN]; /* host name */
int wd_port; /* watchdog port */
int pgpool_port; /* pgpool port */
diff --git a/src/libs/pcp/pcp.c b/src/libs/pcp/pcp.c
index 47715b6c3..50c5bf7c1 100644
--- a/src/libs/pcp/pcp.c
+++ b/src/libs/pcp/pcp.c
@@ -1,5 +1,5 @@
/*
- * $Header$
+FILE * $Header$
*
* Handles PCP connection, and protocol communication with pgpool-II
* These are client APIs. Server program should use APIs in pcp_stream.c
@@ -1826,7 +1826,7 @@ getPoolPassFilename(char *pgpassfile)
if (!get_home_directory(homedir, sizeof(homedir)))
return false;
- snprintf(pgpassfile, MAXPGPATH, "%s/%s", homedir, PCPPASSFILE);
+ snprintf(pgpassfile, MAXPGPATH + sizeof(PCPPASSFILE) + 1, "%s/%s", homedir, PCPPASSFILE);
}
return true;
}
@@ -1839,7 +1839,7 @@ static char *
PasswordFromFile(PCPConnInfo * pcpConn, char *hostname, char *port, char *username)
{
FILE *fp;
- char pgpassfile[MAXPGPATH];
+ char pgpassfile[MAXPGPATH + sizeof(PCPPASSFILE) + 1];
struct stat stat_buf;
#define LINELEN NAMEDATALEN*5
char buf[LINELEN];
diff --git a/src/main/main.c b/src/main/main.c
index 5392dac22..eec3c3e48 100644
--- a/src/main/main.c
+++ b/src/main/main.c
@@ -83,7 +83,7 @@ main(int argc, char **argv)
char pcp_conf_file_path[POOLMAXPATHLEN + 1];
char conf_file_path[POOLMAXPATHLEN + 1];
char hba_file_path[POOLMAXPATHLEN + 1];
- char pool_passwd_key_file_path[POOLMAXPATHLEN + 1];
+ char pool_passwd_key_file_path[POOLMAXPATHLEN + 1 + sizeof(POOLKEYFILE) + 1];
static struct option long_options[] = {
{"hba-file", required_argument, NULL, 'a'},
@@ -204,19 +204,7 @@ main(int argc, char **argv)
}
}
-#ifdef NOT_USED
-/* #ifdef USE_SSL */
- /* /* global ssl init */ */
-/* #if (OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined (LIBRESSL_VERSION_NUMBER)) */
-/* OPENSSL_init_ssl(0, NULL); */
-/* #else */
-/* SSL_library_init(); */
-/* #endif */
-/* SSL_load_error_strings(); */
- /* #endif /* USE_SSL */ */
-#endif
-
- myargv = save_ps_display_args(myargc, myargv);
+ myargv = save_ps_display_args(myargc, myargv);
/* create MemoryContexts */
MemoryContextInit();
@@ -434,7 +422,7 @@ get_pool_key_filename(char *poolKeyFile)
if (!get_home_directory(homedir, sizeof(homedir)))
return false;
- snprintf(poolKeyFile, POOLMAXPATHLEN, "%s/%s", homedir, POOLKEYFILE);
+ snprintf(poolKeyFile, POOLMAXPATHLEN + sizeof(POOLKEYFILE) + 1, "%s/%s", homedir, POOLKEYFILE);
}
return true;
}
diff --git a/src/main/pgpool_main.c b/src/main/pgpool_main.c
index 8182fc6d1..2c04d2958 100644
--- a/src/main/pgpool_main.c
+++ b/src/main/pgpool_main.c
@@ -910,21 +910,21 @@ create_inet_domain_socket(const char *hostname, const int port)
if (status == -1)
{
int saved_errno = errno;
- char hostname[NI_MAXHOST],
+ char host[NI_MAXHOST],
servname[NI_MAXSERV];
- if ((status = getnameinfo((struct sockaddr *) &addr, len, hostname, sizeof(hostname), servname, sizeof(servname), 0)))
+ if ((status = getnameinfo((struct sockaddr *) &addr, len, host, sizeof(host), servname, sizeof(servname), 0)))
{
ereport(NOTICE,
(errmsg("getnameinfo failed while creating INET domain socket"),
errdetail("getnameinfo failed with reason: \"%s\"", gai_strerror(status))));
snprintf(servname, sizeof(servname), "%d", port);
- snprintf(hostname, sizeof(hostname), "%s", hostname);
+ snprintf(host, sizeof(host), "%s", hostname);
}
ereport(FATAL,
(errmsg("failed to create INET domain socket"),
- errdetail("bind on host:\"%s\" server:\"%s\" failed with error \"%s\"", hostname, servname, strerror(saved_errno))));
+ errdetail("bind on host:\"%s\" server:\"%s\" failed with error \"%s\"", host, servname, strerror(saved_errno))));
}
backlog = pool_config->num_init_children * pool_config->listen_backlog_multiplier;
diff --git a/src/protocol/child.c b/src/protocol/child.c
index 13c6da92e..fbfb44969 100644
--- a/src/protocol/child.c
+++ b/src/protocol/child.c
@@ -107,7 +107,7 @@ static int child_unix_fd = 0;
extern int myargc;
extern char **myargv;
-char remote_ps_data[NI_MAXHOST]; /* used for set_ps_display */
+char remote_ps_data[NI_MAXHOST + NI_MAXSERV + 2]; /* used for set_ps_display */
volatile sig_atomic_t got_sighup = 0;
diff --git a/src/tools/pgenc/pg_enc.c b/src/tools/pgenc/pg_enc.c
index 12c2361f5..a7eaebb23 100644
--- a/src/tools/pgenc/pg_enc.c
+++ b/src/tools/pgenc/pg_enc.c
@@ -450,7 +450,7 @@ get_pool_key_filename(char *poolKeyFile)
if (!get_home_directory(homedir, sizeof(homedir)))
return false;
- snprintf(poolKeyFile, POOLMAXPATHLEN, "%s/%s", homedir, POOLKEYFILE);
+ snprintf(poolKeyFile, POOLMAXPATHLEN + sizeof(POOLKEYFILE) + 1, "%s/%s", homedir, POOLKEYFILE);
}
return true;
}
diff --git a/src/tools/pgproto/read.c b/src/tools/pgproto/read.c
index 11c5a8f98..d0ffee39d 100644
--- a/src/tools/pgproto/read.c
+++ b/src/tools/pgproto/read.c
@@ -29,7 +29,6 @@
static char read_char(PGconn *conn);
static int read_int32(PGconn *conn);
-static int read_int16(PGconn *conn);
static char *read_bytes(int len, PGconn *conn);
static void read_and_discard(PGconn *conn);
static void read_it(PGconn *conn, char *buf, int len);
@@ -250,19 +249,6 @@ read_int32(PGconn *conn)
return ntohl(len);
}
-/*
- * Read a short integer from connection.
- */
-static int
-read_int16(PGconn *conn)
-{
- short len;
-
- read_it(conn, (char *) &len, sizeof(len));
-
- return ntohs(len);
-}
-
/*
* Read specified length of bytes from connection.
* pg_malloc'ed buffer is returned.
diff --git a/src/tools/pgproto/send.c b/src/tools/pgproto/send.c
index 77faad7b6..b090c0dee 100644
--- a/src/tools/pgproto/send.c
+++ b/src/tools/pgproto/send.c
@@ -34,9 +34,7 @@
void
send_char(char c, PGconn *conn)
{
- int status;
-
- status = write(PQsocket(conn), &c, 1);
+ write(PQsocket(conn), &c, 1);
}
/*
@@ -45,10 +43,9 @@ send_char(char c, PGconn *conn)
void
send_int(int intval, PGconn *conn)
{
- int status;
int l = htonl(intval);
- status = write(PQsocket(conn), &l, sizeof(l));
+ write(PQsocket(conn), &l, sizeof(l));
}
/*
@@ -57,10 +54,9 @@ send_int(int intval, PGconn *conn)
void
send_int16(short shortval, PGconn *conn)
{
- int status;
short s = htons(shortval);
- status = write(PQsocket(conn), &s, sizeof(s));
+ write(PQsocket(conn), &s, sizeof(s));
}
/*
@@ -69,9 +65,7 @@ send_int16(short shortval, PGconn *conn)
void
send_string(char *buf, PGconn *conn)
{
- int status;
-
- status = write(PQsocket(conn), buf, strlen(buf) + 1);
+ write(PQsocket(conn), buf, strlen(buf) + 1);
}
/*
@@ -80,7 +74,5 @@ send_string(char *buf, PGconn *conn)
void
send_byte(char *buf, int len, PGconn *conn)
{
- int status;
-
- status = write(PQsocket(conn), buf, len);
+ write(PQsocket(conn), buf, len);
}
diff --git a/src/watchdog/watchdog.c b/src/watchdog/watchdog.c
index 724b44920..8126754d3 100644
--- a/src/watchdog/watchdog.c
+++ b/src/watchdog/watchdog.c
@@ -678,7 +678,7 @@ wd_cluster_initialize(void)
struct utsname unameData;
uname(&unameData);
- snprintf(g_cluster.localNode->nodeName, WD_MAX_HOST_NAMELEN, "%s:%d %s %s",
+ snprintf(g_cluster.localNode->nodeName, sizeof(g_cluster.localNode->nodeName), "%s:%d %s %s",
pool_config->wd_hostname,
pool_config->port,
unameData.sysname,
diff --git a/src/watchdog/wd_json_data.c b/src/watchdog/wd_json_data.c
index 734b12ff1..7f3cb6625 100644
--- a/src/watchdog/wd_json_data.c
+++ b/src/watchdog/wd_json_data.c
@@ -796,7 +796,7 @@ parse_wd_node_function_json(char *json_data, int data_len, char **func_name, int
}
*func_name = pstrdup(ptr);
/* If it is a node function ? */
- if (json_get_int_value_for_key(root, "Flags", flags))
+ if (json_get_int_value_for_key(root, "Flags", (int *)flags))
{
/* node count not found, But we don't care much about this */
*flags = 0;
[parent: 1d8d03237a2a]