1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-07 19:06:32 +03:00

Add macro to cast away volatile without allowing changes to underlying type

This adds unvolatize(), which works just like unconstify() but for volatile.

Discussion: https://www.postgresql.org/message-id/flat/7a5cbea7-b8df-e910-0f10-04014bcad701%402ndquadrant.com
This commit is contained in:
Peter Eisentraut
2019-03-25 09:35:29 +01:00
parent 572e3e6634
commit 481018f280
3 changed files with 9 additions and 3 deletions

View File

@@ -3311,7 +3311,7 @@ pgstat_read_current_status(void)
localentry->backendStatus.st_procpid = beentry->st_procpid;
if (localentry->backendStatus.st_procpid > 0)
{
memcpy(&localentry->backendStatus, (char *) beentry, sizeof(PgBackendStatus));
memcpy(&localentry->backendStatus, unvolatize(PgBackendStatus *, beentry), sizeof(PgBackendStatus));
/*
* strcpy is safe even if the string is modified concurrently,

View File

@@ -134,7 +134,7 @@ PMSignalShmemInit(void)
if (!found)
{
MemSet(PMSignalState, 0, PMSignalShmemSize());
MemSet(unvolatize(PMSignalData *, PMSignalState), 0, PMSignalShmemSize());
PMSignalState->num_child_flags = MaxLivePostmasterChildren();
}
}