diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2025-05-08 22:01:25 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2025-05-08 22:01:25 +0300 |
commit | b28c59a6cd089902e66a91e0d0974da34d1c922b (patch) | |
tree | b114ea0f8fa89e2251b80ef7ba13a04ef0a25891 /src/interfaces/libpq/fe-misc.c | |
parent | 965213d9c56a671086525a65f5427653b4a66350 (diff) |
Use 'void *' for arbitrary buffers, 'uint8 *' for byte arrays
A 'void *' argument suggests that the caller might pass an arbitrary
struct, which is appropriate for functions like libc's read/write, or
pq_sendbytes(). 'uint8 *' is more appropriate for byte arrays that
have no structure, like the cancellation keys or SCRAM tokens. Some
places used 'char *', but 'uint8 *' is better because 'char *' is
commonly used for null-terminated strings. Change code around SCRAM,
MD5 authentication, and cancellation key handling to follow these
conventions.
Discussion: https://www.postgresql.org/message-id/61be9e31-7b7d-49d5-bc11-721800d89d64@eisentraut.org
Diffstat (limited to 'src/interfaces/libpq/fe-misc.c')
-rw-r--r-- | src/interfaces/libpq/fe-misc.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index 2648df93813..c14e3c95250 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -67,7 +67,7 @@ PQlibVersion(void) /* - * pqGetc: get 1 character from the connection + * pqGetc: read 1 character from the connection * * All these routines return 0 on success, EOF on error. * Note that for the Get routines, EOF only means there is not enough @@ -100,7 +100,7 @@ pqPutc(char c, PGconn *conn) /* * pqGets[_append]: - * get a null-terminated string from the connection, + * read a null-terminated string from the connection, * and store it in an expansible PQExpBuffer. * If we run out of memory, all of the string is still read, * but the excess characters are silently discarded. @@ -159,10 +159,10 @@ pqPuts(const char *s, PGconn *conn) /* * pqGetnchar: - * get a string of exactly len bytes in buffer s, no null termination + * read exactly len bytes in buffer s, no null termination */ int -pqGetnchar(char *s, size_t len, PGconn *conn) +pqGetnchar(void *s, size_t len, PGconn *conn) { if (len > (size_t) (conn->inEnd - conn->inCursor)) return EOF; @@ -199,7 +199,7 @@ pqSkipnchar(size_t len, PGconn *conn) * write exactly len bytes to the current message */ int -pqPutnchar(const char *s, size_t len, PGconn *conn) +pqPutnchar(const void *s, size_t len, PGconn *conn) { if (pqPutMsgBytes(s, len, conn)) return EOF; |