1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +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:
Andres Freund
2017-10-01 15:36:14 -07:00
parent 1f2830f9df
commit 0ba99c84e8
20 changed files with 99 additions and 175 deletions

View File

@ -19,12 +19,9 @@
#include "postgres_fe.h"
#endif
/* for htonl */
#include <netinet/in.h>
#include <arpa/inet.h>
#include "common/base64.h"
#include "common/scram-common.h"
#include "port/pg_bswap.h"
#define HMAC_IPAD 0x36
#define HMAC_OPAD 0x5C
@ -109,7 +106,7 @@ scram_SaltedPassword(const char *password,
uint8 *result)
{
int password_len = strlen(password);
uint32 one = htonl(1);
uint32 one = pg_hton32(1);
int i,
j;
uint8 Ui[SCRAM_KEY_LEN];