Remove useless duplicate inclusions of system header files.

c.h #includes a number of core libc header files, such as <stdio.h>.
There's no point in re-including these after having read postgres.h,
postgres_fe.h, or c.h; so remove code that did so.

While at it, also fix some places that were ignoring our standard pattern
of "include postgres[_fe].h, then system header files, then other Postgres
header files".  While there's not any great magic in doing it that way
rather than system headers last, it's silly to have just a few files
deviating from the general pattern.  (But I didn't attempt to enforce this
globally, only in files I was touching anyway.)

I'd be the first to say that this is mostly compulsive neatnik-ism,
but over time it might save enough compile cycles to be useful.
This commit is contained in:
Tom Lane 2017-02-25 16:12:24 -05:00
parent 5639ceddcb
commit 9e3755ecb2
77 changed files with 43 additions and 157 deletions

View File

@ -93,9 +93,6 @@ The remaining code is authored by Andrew Dunstan <amdunstan@ncshp.org> and
***********************************************************************/
/* include these first, according to the docs */
#ifndef DMETAPHONE_MAIN
@ -105,14 +102,19 @@ The remaining code is authored by Andrew Dunstan <amdunstan@ncshp.org> and
/* turn off assertions for embedded function */
#define NDEBUG
#endif
#else /* DMETAPHONE_MAIN */
/* we need these if we didn't get them from postgres.h */
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#endif /* DMETAPHONE_MAIN */
#include <assert.h>
#include <ctype.h>
/* prototype for the main function we got from the perl module */
static void DoubleMetaphone(char *, char **);

View File

@ -9,10 +9,6 @@
#include "postgres.h"
#include <sys/types.h>
#include <stdio.h>
#include <sys/types.h>
#ifdef LOWER_NODE
#include <ctype.h>
#define TOLOWER(x) tolower((unsigned char) (x))

View File

@ -32,7 +32,6 @@
#ifndef __PX_H
#define __PX_H
#include <sys/types.h>
#include <sys/param.h>
/* keep debug messages? */

View File

@ -32,7 +32,6 @@
#include "postgres.h"
#include <sys/stat.h>
#include <stdio.h>
#include <unistd.h>
#include "access/timeline.h"

View File

@ -54,7 +54,6 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>

View File

@ -14,7 +14,6 @@
#include "postgres.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <signal.h>

View File

@ -20,7 +20,6 @@
#include "postgres.h"
#include <fcntl.h>
#include <locale.h>
#include <unistd.h>
#include <sys/stat.h>

View File

@ -48,7 +48,6 @@
#include <unistd.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "access/heapam.h"

View File

@ -20,7 +20,6 @@
#include "postgres.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netdb.h>

View File

@ -21,7 +21,6 @@
#ifdef WIN32
#error "barriers are required (and provided) on WIN32 platforms"
#endif
#include <sys/types.h>
#include <signal.h>
#endif

View File

@ -13,7 +13,6 @@
#ifndef PORT_PROTOS_H
#define PORT_PROTOS_H
#include <sys/types.h>
#include <nlist.h>
#include <link.h>
#include <dlfcn.h>

View File

@ -14,7 +14,6 @@
#ifndef PORT_PROTOS_H
#define PORT_PROTOS_H
#include <sys/types.h>
#include <nlist.h>
#include <link.h>
#include <dlfcn.h>

View File

@ -13,7 +13,6 @@
#ifndef PORT_PROTOS_H
#define PORT_PROTOS_H
#include <sys/types.h>
#include <nlist.h>
#include <link.h>
#include <dlfcn.h>

View File

@ -39,8 +39,7 @@
#include "postgres.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <string.h>
/*
* Some versions of the MS SDK contain "typedef enum { ... } ;" which the MS
* compiler quite sanely complains about. Well done, Microsoft.

View File

@ -62,7 +62,6 @@
#include "postgres.h"
#include <signal.h>
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>

View File

@ -12,7 +12,6 @@
*/
#include "postgres.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <time.h>

View File

@ -107,7 +107,6 @@
#include "postgres.h"
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "miscadmin.h"

View File

@ -16,7 +16,6 @@
*/
#include "postgres.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <time.h>

View File

@ -27,7 +27,6 @@
#include "postgres.h"
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#ifndef WIN32
#include <sys/mman.h>

View File

@ -49,7 +49,6 @@
#include "postgres.h"
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#ifndef WIN32
#include <sys/mman.h>

View File

@ -40,7 +40,6 @@
#include <signal.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#ifdef HAVE_SYS_EPOLL_H
#include <sys/epoll.h>
#endif

View File

@ -21,7 +21,6 @@
#include <limits.h>
#include <ctype.h>
#include <math.h>
#include <locale.h>
#include "libpq/pqformat.h"
#include "utils/builtins.h"

View File

@ -11,7 +11,6 @@
#include "postgres.h"
#include <sys/types.h>
#include <sys/stat.h>
#include "access/heapam.h"

View File

@ -23,7 +23,6 @@ static const char rcsid[] = "Id: inet_net_ntop.c,v 1.1.2.2 2004/03/09 09:17:27 m
#include "postgres.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

View File

@ -23,7 +23,6 @@ static const char rcsid[] = "Id: inet_net_pton.c,v 1.4.2.3 2004/03/17 00:40:11 m
#include "postgres.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

View File

@ -51,7 +51,6 @@
#include "postgres.h"
#include <locale.h>
#include <time.h>
#include "access/htup_details.h"

View File

@ -20,7 +20,6 @@
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <grp.h>

View File

@ -52,7 +52,6 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <locale.h>
#include <signal.h>
#include <time.h>

View File

@ -16,7 +16,6 @@
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <time.h>

View File

@ -17,7 +17,6 @@
#include <dirent.h>
#include <signal.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "libpq-fe.h"

View File

@ -13,10 +13,7 @@
#include "postgres_fe.h"
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
/* for ntohl/htonl */

View File

@ -19,16 +19,9 @@
#include "postgres_fe.h"
#include "catalog/pg_control.h"
#include "common/controldata_utils.h"
#include "libpq-fe.h"
#include "pqexpbuffer.h"
#include <fcntl.h>
#include <locale.h>
#include <signal.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
@ -38,8 +31,12 @@
#include <sys/resource.h>
#endif
#include "catalog/pg_control.h"
#include "common/controldata_utils.h"
#include "getopt_long.h"
#include "libpq-fe.h"
#include "miscadmin.h"
#include "pqexpbuffer.h"
/* PID can be negative for standalone backend */
typedef long pgpid_t;

View File

@ -51,6 +51,12 @@
#include "postgres_fe.h"
#ifndef WIN32
#include <sys/wait.h>
#include <signal.h>
#include <unistd.h>
#include <fcntl.h>
#endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
@ -59,14 +65,6 @@
#include "pg_backup_utils.h"
#include "fe_utils/string_utils.h"
#ifndef WIN32
#include <sys/types.h>
#include <sys/wait.h>
#include "signal.h"
#include <unistd.h>
#include <fcntl.h>
#endif
/* Mnemonic macros for indexing the fd array returned by pipe(2) */
#define PIPE_READ 0
#define PIPE_WRITE 1

View File

@ -21,6 +21,15 @@
*/
#include "postgres_fe.h"
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/wait.h>
#ifdef WIN32
#include <io.h>
#endif
#include "parallel.h"
#include "pg_backup_archiver.h"
#include "pg_backup_db.h"
@ -28,17 +37,6 @@
#include "dumputils.h"
#include "fe_utils/string_utils.h"
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#ifdef WIN32
#include <io.h>
#endif
#include "libpq/libpq-fs.h"
#define TEXT_DUMP_HEADER "--\n-- PostgreSQL database dump\n--\n\n"

View File

@ -33,9 +33,6 @@
#include <unistd.h>
#include <ctype.h>
#ifdef ENABLE_NLS
#include <locale.h>
#endif
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#endif

View File

@ -18,10 +18,6 @@
#include <time.h>
#include <unistd.h>
#ifdef ENABLE_NLS
#include <locale.h>
#endif
#include "getopt_long.h"
#include "dumputils.h"

View File

@ -40,22 +40,17 @@
*/
#include "postgres_fe.h"
#include <ctype.h>
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#endif
#include "getopt_long.h"
#include "dumputils.h"
#include "parallel.h"
#include "pg_backup_utils.h"
#include <ctype.h>
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#endif
#ifdef ENABLE_NLS
#include <locale.h>
#endif
static void usage(const char *progname);

View File

@ -39,7 +39,6 @@
#include <dirent.h>
#include <fcntl.h>
#include <locale.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <time.h>

View File

@ -9,12 +9,10 @@
*/
#include "postgres_fe.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include "datapagemap.h"
#include "fetch.h"

View File

@ -16,7 +16,6 @@
*/
#include "postgres_fe.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

View File

@ -14,7 +14,6 @@
*/
#include "postgres_fe.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

View File

@ -10,7 +10,6 @@
#include "postgres_fe.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

View File

@ -9,7 +9,6 @@
*/
#include "postgres_fe.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <fcntl.h>

View File

@ -11,7 +11,6 @@
#include "pg_upgrade.h"
#include <sys/types.h>
#include "fe_utils/string_utils.h"

View File

@ -9,10 +9,9 @@
#include "postgres_fe.h"
#include "pg_upgrade.h"
#include <fcntl.h>
#include <sys/types.h>
#include "pg_upgrade.h"
static void check_data_dir(ClusterInfo *cluster);
static void check_bin_dir(ClusterInfo *cluster);

View File

@ -9,17 +9,16 @@
#include "postgres_fe.h"
#include <time.h>
#ifdef WIN32
#include <io.h>
#endif
#include "miscadmin.h"
#include "getopt_long.h"
#include "pg_upgrade.h"
#include <time.h>
#include <sys/types.h>
#ifdef WIN32
#include <io.h>
#endif
static void usage(void);
static void check_required_directory(char **dirpath, char **configpath,

View File

@ -9,17 +9,14 @@
#include "postgres_fe.h"
#include "pg_upgrade.h"
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#ifdef WIN32
#include <io.h>
#endif
#include "pg_upgrade.h"
static int parallel_jobs;
#ifdef WIN32

View File

@ -11,8 +11,6 @@
#include "pg_upgrade.h"
#include <sys/types.h>
static void get_tablespace_paths(void);
static void set_tablespace_directory_suffix(ClusterInfo *cluster);

View File

@ -10,15 +10,9 @@
*
*-------------------------------------------------------------------------
*/
#include "postgres_fe.h"
#include <windows.h>
#include <olectl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
/* Global variables */
HANDLE g_module = NULL; /* hModule of DLL */

View File

@ -18,7 +18,6 @@
#include <pwd.h>
#endif
#ifndef WIN32
#include <sys/types.h> /* for umask() */
#include <sys/stat.h> /* for stat() */
#include <fcntl.h> /* open() flags */
#include <unistd.h> /* for geteuid(), getpid(), stat() */
@ -27,7 +26,6 @@
#include <io.h>
#include <fcntl.h>
#include <direct.h>
#include <sys/types.h> /* for umask() */
#include <sys/stat.h> /* for stat() */
#endif

View File

@ -7,8 +7,6 @@
*/
#include "postgres_fe.h"
#include <string.h>
#include "common.h"
#include "crosstabview.h"
#include "pqexpbuffer.h"

View File

@ -8,7 +8,6 @@
#include "postgres_fe.h"
#ifndef WIN32
#include <sys/types.h> /* (ditto) */
#include <unistd.h> /* for geteuid() */
#else
#include <win32.h>

View File

@ -7,8 +7,6 @@
*/
#include "postgres_fe.h"
#include <sys/types.h>
#ifndef WIN32
#include <unistd.h>
#else /* WIN32 */
@ -18,8 +16,6 @@
#include "getopt_long.h"
#include <locale.h>
#include "command.h"
#include "common.h"
#include "describe.h"

View File

@ -24,7 +24,6 @@
#endif
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netdb.h>

View File

@ -18,10 +18,8 @@
#include "postgres_fe.h"
#endif
#include <errno.h>
#include <pwd.h>
#include <unistd.h>
#include <sys/types.h>
#include "common/username.h"

View File

@ -21,8 +21,6 @@
#endif
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/wait.h>
/*

View File

@ -18,7 +18,6 @@
#include "postgres_fe.h"
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <signal.h>
#include <unistd.h>

View File

@ -14,7 +14,6 @@
#ifndef LIBPQ_H
#define LIBPQ_H
#include <sys/types.h>
#include <netinet/in.h>
#include "lib/stringinfo.h"

View File

@ -17,7 +17,6 @@
*-------------------------------------------------------------------------
*/
#include <intrin.h>
#include <windows.h>
/* intentionally no include guards, should only be included by atomics.h */
#ifndef INSIDE_ATOMICS_H

View File

@ -12,7 +12,6 @@
#ifndef _PG_LOCALE_
#define _PG_LOCALE_
#include <locale.h>
#if defined(LOCALE_T_IN_XLOCALE) || defined(WCSTOMBS_L_IN_XLOCALE)
#include <xlocale.h>
#endif

View File

@ -3,8 +3,6 @@
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>

View File

@ -16,7 +16,6 @@
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
#include <locale.h>
#include <float.h>
#include <math.h>

View File

@ -3,7 +3,6 @@
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
#include <stdlib.h>
#include "ecpgtype.h"
#include "ecpglib.h"
#include "extern.h"

View File

@ -6,7 +6,7 @@
#include "postgres_fe.h"
#include <unistd.h>
#include <string.h>
#include "getopt_long.h"
#include "extern.h"

View File

@ -19,7 +19,6 @@
#include "postgres_fe.h"
#include <ctype.h>
#include <sys/types.h>
#include <limits.h>
#include "extern.h"

View File

@ -15,7 +15,6 @@
#include "postgres_fe.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <ctype.h>

View File

@ -25,7 +25,6 @@
#include "libpq-events.h"
#include <time.h>
#include <sys/types.h>
#ifndef WIN32
#include <sys/time.h>
#endif

View File

@ -12,7 +12,6 @@
#include "postgres_fe.h"
#include <windows.h>
#include "pthread-win32.h"
DWORD

View File

@ -13,7 +13,6 @@
#include <ctype.h>
#include <fcntl.h>
#include <limits.h>
#include <locale.h>
#include <unistd.h>
/* postgreSQL stuff */

View File

@ -19,11 +19,6 @@
#include "postgres_fe.h"
#endif
#if defined(WIN32) && (_MSC_VER >= 1900)
#include <windows.h>
#endif
#include <locale.h>
#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
#endif

View File

@ -34,7 +34,6 @@
#ifndef __CYGWIN__
#include <winioctl.h>
#else
#include <windows.h>
#include <w32api/winioctl.h>
#endif
#endif

View File

@ -27,7 +27,6 @@ static const char rcsid[] = "Id: inet_net_ntop.c,v 1.1.2.2 2004/03/09 09:17:27 m
#include "postgres_fe.h"
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

View File

@ -19,7 +19,6 @@
#include "postgres_fe.h"
#endif
#include <windows.h>
#include <fcntl.h>
#include <assert.h>

View File

@ -44,7 +44,6 @@
#include "postgres_fe.h"
#endif
#include <windows.h>
#include <fcntl.h>
#undef system

View File

@ -7,9 +7,6 @@
#include "postgres_fe.h"
#ifdef WIN32
#include <windows.h>
#endif
#include <sys/time.h>
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>

View File

@ -41,7 +41,6 @@
#include "postgres.h"
#include <fcntl.h>
#include <locale.h>
#include "private.h"
#include "tzfile.h"

View File

@ -9,7 +9,6 @@
#include "postgres_fe.h"
#include <fcntl.h>
#include <locale.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>