Hi,

On Mon, Feb 23, 2026 at 08:24:22AM +0100, Peter Eisentraut wrote:
> I have another patch that removes some -Wcast-qual warnings, by adjusting
> some function APIs.
> 
> This is as far as I get without resorting to advanced tricks like
> unconstify() or _Generic.

Yeah, so the patch removes those:

jsonapi.c:2170:53: warning: cast discards ‘const’ qualifier from pointer target 
type [-Wcast-qual]
jsonapi.c:2171:52: warning: cast discards ‘const’ qualifier from pointer target 
type [-Wcast-qual]
jsonapi.c:2172:54: warning: cast discards ‘const’ qualifier from pointer target 
type [-Wcast-qual]
jsonapi.c:2170:53: warning: cast discards ‘const’ qualifier from pointer target 
type [-Wcast-qual]
jsonapi.c:2171:52: warning: cast discards ‘const’ qualifier from pointer target 
type [-Wcast-qual]
jsonapi.c:2172:54: warning: cast discards ‘const’ qualifier from pointer target 
type [-Wcast-qual]
jsonapi.c:2170:53: warning: cast discards ‘const’ qualifier from pointer target 
type [-Wcast-qual]
jsonapi.c:2171:52: warning: cast discards ‘const’ qualifier from pointer target 
type [-Wcast-qual]
jsonapi.c:2172:54: warning: cast discards ‘const’ qualifier from pointer target 
type [-Wcast-qual]
ginbulk.c:247:62: warning: cast discards ‘const’ qualifier from pointer target 
type [-Wcast-qual]
ginbulk.c:247:79: warning: cast discards ‘const’ qualifier from pointer target 
type [-Wcast-qual]
parser.c:265:51: warning: cast discards ‘const’ qualifier from pointer target 
type [-Wcast-qual]

and looks ok.

I can see a "volatile" one though:

vacuum.c:1885:46: warning: cast discards ‘volatile’ qualifier from pointer 
target type [-Wcast-qual]

worth to "fix" like in the attached while at it? (It's not really a fix as it
moves the warning from vacuum.c to c.h, but that's consistent with 481018f2804).

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
commit b2fe0f92698cad74cd072a254d3c943b6f51d43d
Author: Bertrand Drouvot <[email protected]>
Date:   Mon Feb 23 09:30:25 2026 +0000

    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.

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",

Reply via email to