From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> |
Cc: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | Re: pgsql: Remove check for accept() argument types |
Date: | 2021-11-12 17:50:53 |
Message-ID: | 1731092.1636739453@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
I wrote:
> Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> writes:
>> What does the man page say the correct type
>> would be? size_t?
> The machine's not booted up right now :-(. But I'm pretty sure we
> shouldn't consider using size_t here, as it's not real clear that that
> couldn't be 64 bits on any affected platforms. Your previous research
> said that the desired type is 32 bits on all such platforms, so I think
> that "int" is correct; we need only debate signedness.
Hmm ... now that I'm in my office, I checked this and HPUX 10.20's
accept(2) man page saith
SYNOPSIS
#include <sys/socket.h>
AF_CCITT only
#include <x25/x25addrstr.h>
int accept(int s, void *addr, int *addrlen);
_XOPEN_SOURCE_EXTENDED only
int accept(int s, struct sockaddr *addr, size_t *addrlen);
gaur is using -D_XOPEN_SOURCE_EXTENDED and hence building against the
latter definition. (I found out quite a long time ago that without
_XOPEN_SOURCE_EXTENDED, this platform has a LOT of discrepancies from
SUS v2.) Further down, there's
FUTURE DIRECTION
The default behavior in this release is still the classic HP-UX BSD
Sockets, however it will be changed to X/Open Sockets in some future
release. At that time, any HP-UX BSD Sockets behavior which is
incompatible with X/Open Sockets may be obsoleted. HP customers are
advised to migrate their applications to conform to X/Open
specification (see xopen_networking(7)).
So what it looks like to me is
(1) Original BSD Sockets defined the argument as "int *addrlen".
(I confirmed this by looking in an ancient copy of Stevens'
Unix Network Programming.)
(2) X/Open thought it'd be better to use size_t.
(3) POSIX decided to resolve the conflict by inventing socklen_t.
However, SUS v2 says specifically that socklen_t "is an unsigned opaque
integral type of length of at least 32 bits". The "unsigned" part
was removed in later POSIX editions, which surprises me --- they don't
usually change the standard in the direction of less definiteness.
On the whole, I still think "unsigned int" is our best compromise.
But maybe we should use size_t and cite X/Open as authority.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2021-11-12 19:56:02 | pgsql: Make psql's \password default to CURRENT_USER, not PQuser(conn). |
Previous Message | Tom Lane | 2021-11-12 16:50:56 | pgsql: postgres_fdw: suppress casts on constants in limited cases. |