Skip to content

Commit 06e1d62

Browse files
committed
Fix a whole bunch of #includes that were either wrong or redundant.
The first rule of portability for us is 'thou shalt have no other gods before c.h', and a whole lot of these files were either not including c.h at all, or including random system headers beforehand, either of which sins can mess up largefile support nicely. Once you have included c.h, there is no need to re-include what it includes, either.
1 parent 420cfd0 commit 06e1d62

19 files changed

+44
-57
lines changed

src/port/crypt.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ __RCSID("$NetBSD: crypt.c,v 1.18 2001/03/01 14:37:35 wiz Exp $");
4343

4444
#include "c.h"
4545

46-
#include <stddef.h>
47-
#include <sys/types.h>
4846
#include <limits.h>
49-
#include <stdlib.h>
5047

5148
#ifndef WIN32
5249
#include <unistd.h>

src/port/fseeko.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/port/fseeko.c,v 1.17 2004/12/31 22:03:53 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/port/fseeko.c,v 1.18 2005/07/28 04:03:14 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -24,10 +24,8 @@
2424
#ifdef bsdi
2525
#include <pthread.h>
2626
#endif
27-
#include <stdio.h>
28-
#include <sys/types.h>
2927
#include <sys/stat.h>
30-
#include <errno.h>
28+
3129

3230
/*
3331
* On BSD/OS and NetBSD, off_t and fpos_t are the same. Standards

src/port/getaddrinfo.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Copyright (c) 2003-2005, PostgreSQL Global Development Group
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/port/getaddrinfo.c,v 1.16 2005/01/01 20:44:33 tgl Exp $
15+
* $PostgreSQL: pgsql/src/port/getaddrinfo.c,v 1.17 2005/07/28 04:03:14 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -21,7 +21,6 @@
2121
#include "c.h"
2222

2323
#ifndef WIN32_CLIENT_ONLY
24-
#include <sys/types.h>
2524
#include <sys/socket.h>
2625
#include <netdb.h>
2726
#include <netinet/in.h>

src/port/gethostname.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/port/gethostname.c,v 1.6 2004/12/31 22:03:53 pgsql Exp $
10+
* $PostgreSQL: pgsql/src/port/gethostname.c,v 1.7 2005/07/28 04:03:14 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
1414

1515
#include "c.h"
1616

17-
#include <string.h>
18-
1917
#include <sys/utsname.h>
2018

2119
int

src/port/getopt.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,10 @@
3434

3535
#include "c.h"
3636

37-
3837
#if defined(LIBC_SCCS) && !defined(lint)
3938
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
4039
#endif /* LIBC_SCCS and not lint */
4140

42-
#include <stdio.h>
43-
#include <stdlib.h>
44-
#include <string.h>
4541

4642
int opterr = 1, /* if error message should be printed */
4743
optind = 1, /* index into parent argv vector */

src/port/getopt_long.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,22 @@
3535
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3636
* SUCH DAMAGE.
3737
*
38-
* $PostgreSQL: pgsql/src/port/getopt_long.c,v 1.3 2003/11/29 19:52:13 pgsql Exp $
38+
* $PostgreSQL: pgsql/src/port/getopt_long.c,v 1.4 2005/07/28 04:03:14 tgl Exp $
3939
*/
4040

41-
#include <stdio.h>
42-
#include <stdlib.h>
43-
#include <string.h>
41+
#include "c.h"
4442

4543
#include "getopt_long.h"
4644

45+
#ifndef HAVE_INT_OPTRESET
46+
int optreset;
47+
#endif
48+
4749
#define BADCH '?'
4850
#define BADARG ':'
4951
#define EMSG ""
5052

53+
5154
int
5255
getopt_long(int argc, char *const argv[],
5356
const char *optstring,

src/port/getrusage.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/port/getrusage.c,v 1.9 2005/05/16 05:52:13 neilc Exp $
11+
* $PostgreSQL: pgsql/src/port/getrusage.c,v 1.10 2005/07/28 04:03:14 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
1515

16-
#include <stdio.h>
17-
#include <errno.h>
18-
1916
#include "c.h"
17+
2018
#include "rusagestub.h"
2119

2220
/* This code works on:

src/port/memcmp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/port/memcmp.c,v 1.7 2004/12/31 22:03:53 pgsql Exp $
10+
* $PostgreSQL: pgsql/src/port/memcmp.c,v 1.8 2005/07/28 04:03:14 tgl Exp $
1111
*
1212
* This file was taken from NetBSD and is used by SunOS because memcmp
1313
* on that platform does not properly compare negative bytes. The
@@ -46,7 +46,8 @@
4646
* SUCH DAMAGE.
4747
*/
4848

49-
#include <string.h>
49+
#include "c.h"
50+
5051

5152
/*
5253
* Compare memory regions.

src/port/noblock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/port/noblock.c,v 1.6 2005/03/25 00:34:31 tgl Exp $
10+
* $PostgreSQL: pgsql/src/port/noblock.c,v 1.7 2005/07/28 04:03:14 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
1414

1515
#include "c.h"
1616

17-
#include <sys/types.h>
1817
#include <fcntl.h>
1918

19+
2020
bool
2121
pg_set_noblock(int sock)
2222
{

src/port/open.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
*
77
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
88
*
9-
* $PostgreSQL: pgsql/src/port/open.c,v 1.9 2005/03/24 04:36:20 momjian Exp $
9+
* $PostgreSQL: pgsql/src/port/open.c,v 1.10 2005/07/28 04:03:14 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
1313

1414
#ifdef WIN32
1515

16-
#include <postgres.h>
16+
#include "c.h"
17+
1718
#include <windows.h>
1819
#include <fcntl.h>
19-
#include <errno.h>
2020
#include <assert.h>
2121

2222
int win32_open(const char *fileName, int fileFlags, ...);

0 commit comments

Comments
 (0)