mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +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:
@ -17,9 +17,6 @@
|
||||
*/
|
||||
#include "postgres.h"
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "access/htup_details.h"
|
||||
#include "access/xact.h"
|
||||
#include "catalog/objectaccess.h"
|
||||
@ -28,6 +25,7 @@
|
||||
#include "libpq/pqformat.h"
|
||||
#include "mb/pg_wchar.h"
|
||||
#include "miscadmin.h"
|
||||
#include "port/pg_bswap.h"
|
||||
#include "tcop/fastpath.h"
|
||||
#include "tcop/tcopprot.h"
|
||||
#include "utils/acl.h"
|
||||
@ -92,7 +90,7 @@ GetOldFunctionMessage(StringInfo buf)
|
||||
if (pq_getbytes((char *) &ibuf, 4))
|
||||
return EOF;
|
||||
appendBinaryStringInfo(buf, (char *) &ibuf, 4);
|
||||
nargs = ntohl(ibuf);
|
||||
nargs = pg_ntoh32(ibuf);
|
||||
/* For each argument ... */
|
||||
while (nargs-- > 0)
|
||||
{
|
||||
@ -102,7 +100,7 @@ GetOldFunctionMessage(StringInfo buf)
|
||||
if (pq_getbytes((char *) &ibuf, 4))
|
||||
return EOF;
|
||||
appendBinaryStringInfo(buf, (char *) &ibuf, 4);
|
||||
argsize = ntohl(ibuf);
|
||||
argsize = pg_ntoh32(ibuf);
|
||||
if (argsize < -1)
|
||||
{
|
||||
/* FATAL here since no hope of regaining message sync */
|
||||
|
Reference in New Issue
Block a user