mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Replace most usages of ntoh[ls] and hton[sl] with pg_bswap.h.
All postgres internal usages are replaced, it's just libpq example usages that haven't been converted. External users of libpq can't generally rely on including postgres internal headers. Note that this includes replacing open-coded byte swapping of 64bit integers (using two 32 bit swaps) with a single 64bit swap. Where it looked applicable, I have removed netinet/in.h and arpa/inet.h usage, which previously provided the relevant functionality. It's perfectly possible that I missed other reasons for including those, the buildfarm will tell. Author: Andres Freund Discussion: https://postgr.es/m/20170927172019.gheidqy6xvlxb325@alap3.anarazel.de
This commit is contained in:
@ -47,7 +47,6 @@
|
||||
#ifdef HAVE_NETINET_TCP_H
|
||||
#include <netinet/tcp.h>
|
||||
#endif
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
@ -73,6 +72,7 @@ static int ldapServiceLookup(const char *purl, PQconninfoOption *options,
|
||||
|
||||
#include "common/ip.h"
|
||||
#include "mb/pg_wchar.h"
|
||||
#include "port/pg_bswap.h"
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
@ -2443,7 +2443,7 @@ keep_going: /* We will come back to here until there is
|
||||
* shouldn't since we only got here if the socket is
|
||||
* write-ready.
|
||||
*/
|
||||
pv = htonl(NEGOTIATE_SSL_CODE);
|
||||
pv = pg_hton32(NEGOTIATE_SSL_CODE);
|
||||
if (pqPacketSend(conn, 0, &pv, sizeof(pv)) != STATUS_OK)
|
||||
{
|
||||
appendPQExpBuffer(&conn->errorMessage,
|
||||
@ -3838,10 +3838,10 @@ retry3:
|
||||
|
||||
/* Create and send the cancel request packet. */
|
||||
|
||||
crp.packetlen = htonl((uint32) sizeof(crp));
|
||||
crp.cp.cancelRequestCode = (MsgType) htonl(CANCEL_REQUEST_CODE);
|
||||
crp.cp.backendPID = htonl(be_pid);
|
||||
crp.cp.cancelAuthCode = htonl(be_key);
|
||||
crp.packetlen = pg_hton32((uint32) sizeof(crp));
|
||||
crp.cp.cancelRequestCode = (MsgType) pg_hton32(CANCEL_REQUEST_CODE);
|
||||
crp.cp.backendPID = pg_hton32(be_pid);
|
||||
crp.cp.cancelAuthCode = pg_hton32(be_key);
|
||||
|
||||
retry4:
|
||||
if (send(tmpsock, (char *) &crp, sizeof(crp), 0) != (int) sizeof(crp))
|
||||
|
Reference in New Issue
Block a user