Hi hackers,

while reviewing [1], I noticed a remaining "cast discards ‘volatile’" outside of
c.h:

$ grep " warning: cast discards ‘volatile’" make.log
vacuum.c:1885:46: warning: cast discards ‘volatile’ qualifier from pointer 
target type [-Wcast-qual]
c.h:1263:10: warning: cast discards ‘volatile’ qualifier from pointer target 
type [-Wcast-qual]
c.h:1039:35: warning: cast discards ‘volatile’ qualifier from pointer target 
type [-Wcast-qual]
c.h:1039:35: warning: cast discards ‘volatile’ qualifier from pointer target 
type [-Wcast-qual]
c.h:1263:10: warning: cast discards ‘volatile’ qualifier from pointer target 
type [-Wcast-qual]
c.h:1263:10: warning: cast discards ‘volatile’ qualifier from pointer target 
type [-Wcast-qual]
c.h:1263:10: warning: cast discards ‘volatile’ qualifier from pointer target 
type [-Wcast-qual]

That indicated that unvolatize() is not being used in vacuum.c. Indeed, 
481018f2804
introduced unvolatize() but its usage has been missed in c66a7d75e652.

This patch makes use of unvolatize() in vac_truncate_clog().

Note that it does not remove the warning but moves it to c.h (where unvolatize()
is defined) but that's consistent with what 481018f2804 did too.

[1]: 
https://postgr.es/m/aZw4fcj1qBYgN41V%40ip-10-97-1-34.eu-west-3.compute.internal

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
>From 369328747aa6d0a30093e79199f60d034e5eab85 Mon Sep 17 00:00:00 2001
From: Bertrand Drouvot <[email protected]>
Date: Tue, 24 Feb 2026 16:44:30 +0000
Subject: [PATCH v1] Make use of unvolatize() in vac_truncate_clog()

481018f2804 introduced unvolatize() but c66a7d75e652 forgot to make use of
it.

Reported by -Wcast-qual. Note that that does not remove the warning (481018f2804
also did not remove them), but move it from vacuum.c:1885 to c.h:1263.
---
 src/backend/commands/vacuum.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
 100.0% src/backend/commands/

diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 03932f45c8a..edef3396aae 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -1882,7 +1882,7 @@ vac_truncate_clog(TransactionId frozenXID,
 		 * anymore. Therefore we don't need to take it into account here.
 		 * Which is good, because it can't be processed by autovacuum either.
 		 */
-		if (database_is_invalid_form((Form_pg_database) dbform))
+		if (database_is_invalid_form(unvolatize(FormData_pg_database *, dbform)))
 		{
 			elog(DEBUG2,
 				 "skipping invalid database \"%s\" while computing relfrozenxid",
-- 
2.34.1

Reply via email to