mirror of
https://github.com/postgres/postgres.git
synced 2025-10-27 00:12:01 +03:00
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
This commit is contained in:
@@ -64,7 +64,7 @@ typedef struct
|
||||
{
|
||||
pg_atomic_uint32 pss_pid;
|
||||
int pss_cancel_key_len; /* 0 means no cancellation is possible */
|
||||
char pss_cancel_key[MAX_CANCEL_KEY_LENGTH];
|
||||
uint8 pss_cancel_key[MAX_CANCEL_KEY_LENGTH];
|
||||
volatile sig_atomic_t pss_signalFlags[NUM_PROCSIGNALS];
|
||||
slock_t pss_mutex; /* protects the above fields */
|
||||
|
||||
@@ -163,7 +163,7 @@ ProcSignalShmemInit(void)
|
||||
* Register the current process in the ProcSignal array
|
||||
*/
|
||||
void
|
||||
ProcSignalInit(char *cancel_key, int cancel_key_len)
|
||||
ProcSignalInit(const uint8 *cancel_key, int cancel_key_len)
|
||||
{
|
||||
ProcSignalSlot *slot;
|
||||
uint64 barrier_generation;
|
||||
@@ -729,7 +729,7 @@ procsignal_sigusr1_handler(SIGNAL_ARGS)
|
||||
* fields in the ProcSignal slots.
|
||||
*/
|
||||
void
|
||||
SendCancelRequest(int backendPID, char *cancel_key, int cancel_key_len)
|
||||
SendCancelRequest(int backendPID, const uint8 *cancel_key, int cancel_key_len)
|
||||
{
|
||||
Assert(backendPID != 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user