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.
pull/17/merge
Tom Lane 9 years ago
parent 5639ceddcb
commit 9e3755ecb2
  1. 12
      contrib/fuzzystrmatch/dmetaphone.c
  2. 4
      contrib/ltree/crc32.c
  3. 1
      contrib/pgcrypto/px.h
  4. 1
      src/backend/access/transam/timeline.c
  5. 1
      src/backend/access/transam/twophase.c
  6. 1
      src/backend/access/transam/xlogarchive.c
  7. 1
      src/backend/commands/dbcommands.c
  8. 1
      src/backend/commands/tablespace.c
  9. 1
      src/backend/libpq/ifaddr.c
  10. 1
      src/backend/port/atomics.c
  11. 1
      src/backend/port/dynloader/freebsd.h
  12. 1
      src/backend/port/dynloader/netbsd.h
  13. 1
      src/backend/port/dynloader/openbsd.h
  14. 3
      src/backend/port/win32/crashdump.c
  15. 1
      src/backend/postmaster/autovacuum.c
  16. 1
      src/backend/replication/basebackup.c
  17. 1
      src/backend/replication/logical/snapbuild.c
  18. 1
      src/backend/replication/walreceiverfuncs.c
  19. 1
      src/backend/storage/ipc/dsm.c
  20. 1
      src/backend/storage/ipc/dsm_impl.c
  21. 1
      src/backend/storage/ipc/latch.c
  22. 1
      src/backend/utils/adt/cash.c
  23. 1
      src/backend/utils/adt/dbsize.c
  24. 1
      src/backend/utils/adt/inet_cidr_ntop.c
  25. 1
      src/backend/utils/adt/inet_net_pton.c
  26. 1
      src/backend/utils/adt/pg_locale.c
  27. 1
      src/backend/utils/init/miscinit.c
  28. 1
      src/bin/initdb/initdb.c
  29. 1
      src/bin/pg_basebackup/pg_basebackup.c
  30. 1
      src/bin/pg_basebackup/pg_receivewal.c
  31. 3
      src/bin/pg_basebackup/streamutil.c
  32. 11
      src/bin/pg_ctl/pg_ctl.c
  33. 14
      src/bin/pg_dump/parallel.c
  34. 16
      src/bin/pg_dump/pg_backup_archiver.c
  35. 3
      src/bin/pg_dump/pg_dump.c
  36. 4
      src/bin/pg_dump/pg_dumpall.c
  37. 15
      src/bin/pg_dump/pg_restore.c
  38. 1
      src/bin/pg_resetwal/pg_resetwal.c
  39. 2
      src/bin/pg_rewind/copy_fetch.c
  40. 1
      src/bin/pg_rewind/fetch.c
  41. 1
      src/bin/pg_rewind/file_ops.c
  42. 1
      src/bin/pg_rewind/filemap.c
  43. 1
      src/bin/pg_rewind/libpq_fetch.c
  44. 1
      src/bin/pg_upgrade/dump.c
  45. 5
      src/bin/pg_upgrade/exec.c
  46. 11
      src/bin/pg_upgrade/option.c
  47. 9
      src/bin/pg_upgrade/parallel.c
  48. 2
      src/bin/pg_upgrade/tablespace.c
  49. 6
      src/bin/pgevent/pgevent.c
  50. 2
      src/bin/psql/command.c
  51. 2
      src/bin/psql/crosstabview.c
  52. 1
      src/bin/psql/help.c
  53. 4
      src/bin/psql/startup.c
  54. 1
      src/common/ip.c
  55. 2
      src/common/username.c
  56. 2
      src/common/wait_error.c
  57. 1
      src/fe_utils/print.c
  58. 1
      src/include/libpq/libpq.h
  59. 1
      src/include/port/atomics/generic-msvc.h
  60. 1
      src/include/utils/pg_locale.h
  61. 2
      src/interfaces/ecpg/ecpglib/data.c
  62. 1
      src/interfaces/ecpg/ecpglib/execute.c
  63. 1
      src/interfaces/ecpg/ecpglib/typename.c
  64. 2
      src/interfaces/ecpg/preproc/ecpg.c
  65. 1
      src/interfaces/ecpg/preproc/pgc.l
  66. 1
      src/interfaces/libpq/fe-connect.c
  67. 1
      src/interfaces/libpq/libpq-int.h
  68. 1
      src/interfaces/libpq/pthread-win32.c
  69. 1
      src/pl/plperl/plperl.c
  70. 5
      src/port/chklocale.c
  71. 1
      src/port/dirmod.c
  72. 1
      src/port/inet_net_ntop.c
  73. 1
      src/port/open.c
  74. 1
      src/port/system.c
  75. 3
      src/test/isolation/isolationtester.c
  76. 1
      src/timezone/strftime.c
  77. 1
      src/timezone/zic.c

@ -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 **);

@ -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))

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

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

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

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

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

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

@ -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>

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

@ -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>

@ -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>

@ -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>

@ -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.

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

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

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

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

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

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

@ -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

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

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

@ -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>

@ -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>

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

@ -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>

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

@ -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>

@ -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"

@ -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 */

@ -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;

@ -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

@ -21,24 +21,22 @@
*/
#include "postgres_fe.h"
#include "parallel.h"
#include "pg_backup_archiver.h"
#include "pg_backup_db.h"
#include "pg_backup_utils.h"
#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 "parallel.h"
#include "pg_backup_archiver.h"
#include "pg_backup_db.h"
#include "pg_backup_utils.h"
#include "dumputils.h"
#include "fe_utils/string_utils.h"
#include "libpq/libpq-fs.h"
#define TEXT_DUMP_HEADER "--\n-- PostgreSQL database dump\n--\n\n"

@ -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

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

@ -40,21 +40,16 @@
*/
#include "postgres_fe.h"
#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
#include "getopt_long.h"
#include "dumputils.h"
#include "parallel.h"
#include "pg_backup_utils.h"
static void usage(const char *progname);

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

@ -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"

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

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

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

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

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

@ -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);

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

@ -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

@ -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);

@ -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 */

@ -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

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

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

@ -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"

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

@ -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"

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

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

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

@ -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

@ -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

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

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

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

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

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

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

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

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

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

@ -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

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

@ -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>

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

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

@ -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>

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

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

Loading…
Cancel
Save