[pgpool-hackers: 3109] Re: Compile warns

Takuma Hoshiai hoshiai at sraoss.co.jp
Thu Nov 8 10:08:39 JST 2018


Hi Ishii-san,

On Thu, 08 Nov 2018 09:13:55 +0900 (JST)
Tatsuo Ishii <ishii at sraoss.co.jp> wrote:

> Hi Hoshiai-san,
> 
> From: Takuma Hoshiai <hoshiai at sraoss.co.jp>
> Subject: [pgpool-hackers: 3104] Re: Compile warns
> Date: Mon, 5 Nov 2018 17:36:23 +0900
> Message-ID: <20181105173623.090e4fef86c57eb261b3ad51 at sraoss.co.jp>
> 
> >  src/auth/pool_auth.c            |  8 ++++++++
> >  src/auth/pool_hba.c             | 19 -------------------
> >  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, 32 insertions(+), 73 deletions(-)
> > 
> > diff --git a/src/auth/pool_auth.c b/src/auth/pool_auth.c
> > index 598b03b..9975822 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 2d7bbac..a628b5f 100644
> > --- a/src/auth/pool_hba.c
> > +++ b/src/auth/pool_hba.c
> > @@ -128,7 +128,6 @@ 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);
> > -static POOL_STATUS CheckUserExist(char *username);
> >  
> >  #ifdef USE_PAM
> >  #ifdef HAVE_PAM_PAM_APPL_H
> > @@ -2062,21 +2061,3 @@ static POOL_STATUS CheckPAMAuth(POOL_CONNECTION * frontend, char *user, char *pa
> >  }
> >  
> >  #endif							/* USE_PAM */
> > -
> > -
> > -
> 
> I suggest not to remove CheckUserExist(), rather #ifdef out unless
> explict authorization of removing from Usama. He may have feature plan
> to use this function.

Sorry, I understood.
I recreated a patch. This patch used "#ifdef NOT_USED" instead of remove CheckUserExist().

 
> > -static POOL_STATUS CheckUserExist(char *username)
> > -{
> > -	char	   *passwd;
> > -
> > -	/* Look for the entry in pool_passwd */
> > -	passwd = pool_get_passwd(username);
> > -
> > -	if (passwd == NULL)
> > -		return POOL_ERROR;
> > -
> > -	/*
> > -	 * Ok for now. Actual authentication will be performed later.
> > -	 */
> > -	return POOL_CONTINUE;
> > -}
> > diff --git a/src/auth/pool_passwd.c b/src/auth/pool_passwd.c
> > index b31de5e..c84136b 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 844e998..af3d153 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 36f3841..78df76c 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 47715b6..50c5bf7 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 5392dac..eec3c3e 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 8182fc6..2c04d29 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 13c6da9..fbfb449 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 12c2361..a7eaebb 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 11c5a8f..d0ffee3 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);
> > @@ -251,19 +250,6 @@ read_int32(PGconn *conn)
> >  }
> >  
> >  /*
> > - * 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 77faad7..b090c0d 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 724b449..8126754 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 734b12f..1f1ac7e 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;
> 


-- 
Takuma Hoshiai <hoshiai at sraoss.co.jp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Compile-warns_fixed_v2.patch
Type: application/octet-stream
Size: 11212 bytes
Desc: not available
URL: <http://www.sraoss.jp/pipermail/pgpool-hackers/attachments/20181108/6667d0e8/attachment-0001.obj>


More information about the pgpool-hackers mailing list